Find a file
Jennifer Richards 3705bedfcd
feat: Celery support and asynchronous draft submission API (#4037)
* ci: add Dockerfile and action to build celery worker image

* ci: build celery worker on push to jennifer/celery branch

* ci: also build celery worker for main branch

* ci: Add comment to celery Dockerfile

* chore: first stab at a celery/rabbitmq docker-compose

* feat: add celery configuration and test task / endpoint

* chore: run mq/celery containers for dev work

* chore: point to ghcr.io image for celery worker

* refactor: move XML parsing duties into XMLDraft

Move some PlaintextDraft methods into the Draft base class and
implement for the XMLDraft class. Use xml2rfc code from ietf.submit
as a model for the parsing.

This leaves some mismatch between the PlaintextDraft and the Draft
class spec for the get_author_list() method to be resolved.

* feat: add api_upload endpoint and beginnings of async processing

This adds an api_upload() that behaves analogously to the api_submit()
endpoint. Celery tasks to handle asynchronous processing are added but
are not yet functional enough to be useful.

* perf: index Submission table on submission_date

This substantially speeds up submission rate threshold checks.

* feat: remove existing files when accepting a new submission

After checking that a submission is not in progress, remove any files
in staging that have the same name/rev with any extension. This should
guard against stale files confusing the submission process if the
usual cleanup fails or is skipped for some reason.

* refactor: make clear that deduce_group() uses only the draft name

* refactor: extract only draft name/revision in clean() method

Minimizing the amount of validation done when accepting a file. The
data extraction will be moved to asynchronous processing.

* refactor: minimize checks and data extraction in api_upload() view

* ci: fix dockerfiles to match sandbox testing

* ci: tweak celery container docker-compose settings

* refactor: clean up Draft parsing API and usage

  * remove get_draftname() from Draft api; set filename during init
  * further XMLDraft work
    - remember xml_version after parsing
    - extract filename/revision during init
    - comment out long broken get_abstract() method
  * adjust form clean() method to use changed API

* feat: flesh out async submission processing

First basically working pass!

* feat: add state name for submission being validated asynchronously

* feat: cancel submissions that async processing can't handle

* refactor: simplify/consolidate async tasks and improve error handling

* feat: add api_submission_status endpoint

* refactor: return JSON from submission api endpoints

* refactor: reuse cancel_submission method

* refactor: clean up error reporting a bit

* feat: guard against cancellation of a submission while validating

Not bulletproof but should prevent

* feat: indicate that a submission is still being validated

* fix: do not delete submission files after creating them

* chore: remove debug statement

* test: add tests of the api_upload and api_submission_status endpoints

* test: add tests and stubs for async side of submission handling

* fix: gracefully handle (ignore) invalid IDs in async submit task

* test: test process_uploaded_submission method

* fix: fix failures of new tests

* refactor: fix type checker complaints

* test: test submission_status view of submission in "validating" state

* fix: fix up migrations

* fix: use the streamlined SubmissionBaseUploadForm for api_upload

* feat: show submission history event timestamp as mouse-over text

* fix: remove 'manual' as next state for 'validating' submission state

* refactor: share SubmissionBaseUploadForm code with Deprecated version

* fix: validate text submission title, update a couple comments

* chore: disable requirements updating when celery dev container starts

* feat: log traceback on unexpected error during submission processing

* feat: allow secretariat to cancel "validating" submission

* feat: indicate time since submission on the status page

* perf: check submission rate thresholds earlier when possible

No sense parsing details of a draft that is going to be dropped regardless
of those details!

* fix: create Submission before saving to reduce race condition window

* fix: call deduce_group() with filename

* refactor: remove code lint

* refactor: change the api_upload URL to api/submission

* docs: update submission API documentation

* test: add tests of api_submission's text draft consistency checks

* refactor: rename api_upload to api_submission to agree with new URL

* test: test API documentation and submission thresholds

* fix: fix a couple api_submission view renames missed in templates

* chore: use base image + add arm64 support

* ci: try to fix workflow_dispatch for celery worker

* ci: another attempt to fix workflow_dispatch

* ci: build celery image for submit-async branch

* ci: fix typo

* ci: publish celery worker to ghcr.io/painless-security

* ci: install python requirements in celery image

* ci: fix up requirements install on celery image

* chore: remove XML_LIBRARY references that crept back in

* feat: accept 'replaces' field in api_submission

* docs: update api_submission documentation

* fix: remove unused import

* test: test "replaces" validation for submission API

* test: test that "replaces" is set by api_submission

* feat: trap TERM to gracefully stop celery container

* chore: tweak celery/mq settings

* docs: update installation instructions

* ci: adjust paths that trigger celery worker image  build

* ci: fix branches/repo names left over from dev

* ci: run manage.py check when initializing celery container

Driver here is applying the patches. Starting the celery workers
also invokes the check task, but this should cause a clearer failure
if something fails.

* docs: revise INSTALL instructions

* ci: pass filename to pip update in celery container

* docs: update INSTALL to include freezing pip versions

Will be used to coordinate package versions with the celery
container in production.

* docs: add explanation of frozen-requirements.txt

* ci: build image for sandbox deployment

* ci: add additional build trigger path

* docs: tweak INSTALL

* fix: change INSTALL process to stop datatracker before running migrations

* chore: use ietf.settings for manage.py check in celery container

* chore: set uid/gid for celery worker

* chore: create user/group in celery container if needed

* chore: tweak docker compose/init so celery container works in dev

* ci: build mq docker image

* fix: move rabbitmq.pid to writeable location

* fix: clear password when CELERY_PASSWORD is empty

Setting to an empty password is really not a good plan!

* chore: add shutdown debugging option to celery image

* chore: add django-celery-beat package

* chore: run "celery beat" in datatracker-celery image

* chore: fix docker image name

* feat: add task to cancel stale submissions

* test: test the cancel_stale_submissions task

* chore: make f-string with no interpolation a plain string

Co-authored-by: Nicolas Giard <github@ngpixel.com>
Co-authored-by: Robert Sparks <rjsparks@nostrum.com>
2022-08-22 13:29:31 -05:00
.devcontainer chore: improve devcontainer build (#4241) 2022-07-23 10:33:41 -04:00
.github feat: Celery support and asynchronous draft submission API (#4037) 2022-08-22 13:29:31 -05:00
.vscode chore: create separate run config for vite dev (#4221) 2022-07-18 08:40:32 -05:00
.yarn chore: Update bootstrap to 5.2.0 (#4034) 2022-07-21 15:56:27 -05:00
bin fix: reparse last month of rfc-index every 15m until we improve the API for new RFCs (#4314) 2022-08-11 14:20:31 -05:00
client fix: agenda - rename Video Stream tooltip to Full Client with Video (#4287) 2022-07-27 09:36:28 -05:00
cypress fix: set vite base path during deploy build + allow google fonts (#4217) 2022-07-14 18:55:55 -05:00
dev feat: Celery support and asynchronous draft submission API (#4037) 2022-08-22 13:29:31 -05:00
docker feat: Celery support and asynchronous draft submission API (#4037) 2022-08-22 13:29:31 -05:00
ietf feat: Celery support and asynchronous draft submission API (#4037) 2022-08-22 13:29:31 -05:00
media chore: remove deprecated files + add excluded patterns for deploy (#3589) 2022-03-08 08:20:52 -06:00
patch chore: update dependency requirements (#3904) 2022-04-28 11:06:17 -05:00
pyzmail fix: avoid mutables as defaults. Compute date default arguments at runtime rather than loadtime. (#4144) 2022-07-06 14:39:36 -05:00
svn-history chore: capture svn changeset to git commit mapping (#3573) 2022-03-07 13:00:06 -06:00
test Add some ignores 2021-11-09 11:57:49 +00:00
vzic Changed the plain UTC.ics zoneinfo entry from symlink to file. 2020-09-16 18:16:28 +00:00
.dockerignore chore: add .dockerignore (#4027) 2022-05-31 16:47:40 -05:00
.editorconfig feat(ui): new dynamic agenda view (#4086) 2022-07-13 16:20:23 -05:00
.eslintrc.js feat(ui): new dynamic agenda view (#4086) 2022-07-13 16:20:23 -05:00
.gitattributes chore: switch to Yarn 3 (#3819) 2022-04-25 15:54:05 -05:00
.gitignore feat(ui): new dynamic agenda view (#4086) 2022-07-13 16:20:23 -05:00
.pnp.cjs chore: Update bootstrap to 5.2.0 (#4034) 2022-07-21 15:56:27 -05:00
.pnp.loader.mjs chore: Update bootstrap to 5.2.0 (#4034) 2022-07-21 15:56:27 -05:00
.pylintrc Added a pylint rc-file, and fixed or silenced a number of issues found by pylint using the settings .pylintrc (which enable only error checking). 2016-09-08 14:48:59 +00:00
.yarnrc.yml chore: Update bootstrap to 5.2.0 (#4034) 2022-07-21 15:56:27 -05:00
cypress.config.js feat(ui): new dynamic agenda view (#4086) 2022-07-13 16:20:23 -05:00
debug.py chore: Remove six and pathlib2 from deps (#4031) 2022-05-31 09:12:45 -05:00
docker-compose.yml feat: Celery support and asynchronous draft submission API (#4037) 2022-08-22 13:29:31 -05:00
LICENSE docs: fix LICENSE name + years 2022-04-14 14:51:26 -04:00
mypy.ini Added a mypy .ini file 2019-09-30 15:38:22 +00:00
package.json fix: use white ietf text logo in header (#4283) 2022-07-27 15:43:06 -05:00
README.md docs: update frontend instructions 2022-07-13 19:48:43 -04:00
requirements.txt feat: Celery support and asynchronous draft submission API (#4037) 2022-08-22 13:29:31 -05:00
tzparse.py Initial 2to3 patch with added copyright statement updates. 2019-06-27 14:40:54 +00:00
vite.config.js chore: create separate run config for vite dev (#4221) 2022-07-18 08:40:32 -05:00
yarn.lock chore: Update bootstrap to 5.2.0 (#4034) 2022-07-21 15:56:27 -05:00

IETF Datatracker

Release License Code Coverage Nightly Dev DB Image
Python Version Django Version Node Version MariaDB Version

The day-to-day front-end to the IETF database for people who work on IETF standards.

Getting Started

This project is following the standard Git Feature Workflow development model. Learn about all the various steps of the development workflow, from creating a fork to submitting a pull request, in the Contributing guide.

Make sure to read the Styleguides section to ensure a cohesive code format across the project.

You can submit bug reports, enhancement and new feature requests in the discussions area. Accepted tickets will be converted to issues.

Git Cloning Tips

As outlined in the Contributing guide, you will first want to create a fork of the datatracker project in your personal GitHub account before cloning it.

Because of the extensive history of this project, cloning the datatracker project locally can take a long time / disk space. You can speed up the cloning process by limiting the history depth, for example (replace USERNAME with your GitHub username):

  • To fetch only up to the 10 latest commits:
    git clone --depth=10 https://github.com/USERNAME/datatracker.git
    
  • To fetch only up to a specific date:
    git clone --shallow-since=DATE https://github.com/USERNAME/datatracker.git
    

Overview of the datatracker models

A beginning of a walkthrough of the datatracker models was prepared for the IAB AID workshop.

Docker Dev Environment

In order to simplify and reduce the time required for setup, a preconfigured docker environment is available.

Read the Docker Dev Environment guide to get started.

Database & Assets

Nightly database dumps of the datatracker are available at
https://www.ietf.org/lib/dt/sprint/ietf_utf8.sql.gz

Note that this link is provided as reference only. To update the database in your dev environment to the latest version, you should instead run the docker/cleandb script!

Frontend Development

Intro

We now use yarn to manage assets for the Datatracker, and vite/parcel to package them. yarn maintains its node packages under the .yarn directory.

The datatracker uses 2 different build systems, depending on the use case:

  • Vite for Vue 3 pages / components
  • Parcel for legacy pages / jQuery

Vite (Vue 3)

Pages will gradually be updated to Vue 3 components. These components are located under the /client directory.

Each Vue 3 app has its own sub-directory. For example, the agenda app is located under /client/agenda.

The datatracker makes use of the Django-Vite plugin to point to either the Vite.js server or the precompiled production files. The DJANGO_VITE_DEV_MODE flag, found in the ietf/settings_local.py file determines whether the Vite.js server is used or not.

In development mode, you must start the Vite.js development server, in addition to the usual Datatracker server:

yarn dev

Any changes made to the files under /client will automatically trigger a hot-reload of the modified components.

To generate production assets, run the build command:

yarn build

This will create packages under ietf/static/dist-neue, which are then served by the Django development server, and which must be uploaded to the CDN.

Parcel (Legacy/jQuery)

The Datatracker includes these packages from the various Javascript and CSS files in ietf/static/js and ietf/static/css, respectively. Static images are likewise in ietf/static/images.

Whenever changes are made to the files under ietf/static, you must re-run parcel to package them:

yarn legacy:build

This will create packages under ietf/static/dist/ietf, which are then served by the Django development server, and which must be uploaded to the CDN.

Bootstrap

The "new" datatracker uses Twitter Bootstrap for the UI.

Get familiar with https://getbootstrap.com/getting-started/ and use those UI elements, CSS classes, etc. instead of cooking up your own.

Some ground rules:

  • Think hard before tweaking the bootstrap CSS, it will make it harder to upgrade to future releases.
  • No <style> tags in the HTML! Put CSS into the "morecss" block of a template instead.
  • CSS that is used by multiple templates goes into static/css/ietf.css or a new CSS file.
  • Javascript that is only used on one template goes into the "js" block of that template.
  • Javascript that is used by multiple templates goes into static/js/ietf.js or a new js file.
  • Avoid CSS, HTML styling or Javascript in the python code!

Serving Static Files via CDN

Production Mode

If resources served over a CDN and/or with a high max-age don't have different URLs for different versions, then any component upgrade which is accompanied by a change in template functionality will have a long transition time during which the new pages are served with old components, with possible breakage. We want to avoid this.

The intention is that after a release has been checked out, but before it is deployed, the standard django collectstatic management command will be run, resulting in all static files being collected from their working directory location and placed in an appropriate location for serving via CDN. This location will have the datatracker release version as part of its URL, so that after the deployment of a new release, the CDN will be forced to fetch the appropriate static files for that release.

An important part of this is to set up the STATIC_ROOT and STATIC_URL settings appropriately. In 6.4.0, the setting is as follows in production mode:

STATIC_URL = "https://www.ietf.org/lib/dt/%s/"%__version__
STATIC_ROOT = CDN_ROOT + "/a/www/www6s/lib/dt/%s/"%__version__

The result is that all static files collected via the collectstatic command will be placed in a location served via CDN, with the release version being part of the URL.

Development Mode

In development mode, STATIC_URL is set to /static/, and Django's staticfiles infrastructure makes the static files available under that local URL root (unless you set settings.SERVE_CDN_FILES_LOCALLY_IN_DEV_MODE to False). It is not necessary to actually populate the static/ directory by running collectstatic in order for static files to be served when running ietf/manage.py runserver -- the runserver command has extra support for finding and serving static files without running collectstatic.

In order to work backwards from a file served in development mode to the location from which it is served, the mapping is as follows:

Development URL Working copy location
localhost:8000/static/ietf/* ietf/static/ietf/*
localhost:8000/static/secr/* ietf/secr/static/secr/*

Handling of External Javascript and CSS Components

In order to make it easy to keep track of and upgrade external components, these are now handled by a tool called yarn via the configuration in package.json.

To add a new package, simply run (replace <package-name> with the NPM module name):

yarn add <package-name>

Handling of Internal Static Files

Previous to this release, internal static files were located under static/, mixed together with the external components. They are now located under ietf/static/ietf/ and ietf/secr/static/secr, and will be collected for serving via CDN by the collectstatic command. Any static files associated with a particular app will be handled the same way (which means that all admin/ static files automatically will be handled correctly, too).

Changes to Template Files

In order to make the template files refer to the correct versioned CDN URL (as given by the STATIC_URL root) all references to static files in the templates have been updated to use the static template tag when referring to static files. This will automatically result in both serving static files from the right place in development mode, and referring to the correct versioned URL in production mode and the simpler /static/ URLs in development mode.

Deployment

During deployment, it is now necessary to run the management command:

ietf/manage.py collectstatic

before activating a new release.