63 Commits

Author SHA1 Message Date
dandds
0b5acde4c4 Stream-parse CRLs for caching file locations.
AT-AT needs to maintain a key-value CRL cache where each key is the DER
byte-string of the issuer and the value is a dictionary of the CRL file
path and expiration. This way when it checks a client certificate, it
can load the correct CRL by comparing the issuers. This is preferable to
loading all of the CRLs in-memory. However, it still requires that AT-AT
load and parse each CRL when the application boots. Because of the size
of the CRLs and their parsed, in-memory size, this leads to the
application spiking to use nearly 900MB of memory (resting usage is
around 50MB).

This change introduces a small function to ad-hoc parse the CRL and
obtain the information in the CRL we need: the issuer and the
expiration. It does this by reading the CRL byte-by-byte until it
reaches the ASN1 sequence that corresponds to the issuer, and then looks
ahead to find the nextUpdate field (i.e., the expiration date). The
CRLCache class uses this function to build its cache and JSON-serializes
the cache to disk. If another AT-AT application process finds the
serialized version, it will load that copy instead of rebuilding it. It
also entails a change to the function signature for the init method of
CRLCache: now it expects the CRL directory as its second argument,
instead of a list of locations.

The Python script invoked by `script/sync-crls` will rebuild the
location cache each time it's run. This means that when the Kubernetes
CronJob for CRLs runs, it will refresh the cache each time. When a new
application container boots, it will get the refreshed cache.

This also adds a nightly CircleCI job to sync the CRLs and test that the
ad-hoc parsing function returns the same result as a proper parsing
using the Python cryptography library. This provides extra insurance
that the function is returning correct results on real data.
2019-11-04 08:36:03 -05:00
dandds
23c4ba32eb CI/CD uses Docker containers exclusively and removes CircleCI Orbs.
The CircleCI Orbs were useful for getting started, but now that we only
have to deploy to one provider our pipeline should be tailored to
efficiently push to just that environment. This inlines all the relevant
pieces from the Orbs we were relying on as bash/sh commands instead.

This builds the Docker images upfront. Since we have a multi-stage
Dockerfile, it builds the first stage as a separate image and then
proceeds to build the complete image. This is done so that the first
stage (called "builder") can be used for testing. It retains executables
like pipenv that we need to install development dependencies needed for
tests.

Other notes:
- CircleCI does not persist Docker images between jobs. As a
  work-around, we use the CircleCI caching mechanism to create a named
  cache with *.tar copies of the images. Subsequent jobs use the cache
  and load the images.
- Both the test and integration-tests jobs need to make minor
  modifications to the container to run correctly. The test job needs to
  install the development Python dependencies, and the integration-tests
  job needs to rebuild the JS bundle so that it uses the mock uploader
  (the container is build to use the Azure uploader by default).
- The test and integration-tests jobs run in parallel.
- This adjusts the Dockerfile so that the TZ environment variable is set
  for both stages of the build.
2019-10-30 12:04:21 -04:00
dandds
85da084cd7 Update CI and remove AWS config.
This does the following:
- Consolidates the app_setup and test jobs into one. The test job was
  only one additional step, so it's not worth separating.
- Updates the Postgres image used to reflect what we're using for the
  deployed version of the site (i.e., v 10).
- Removes some unnecessary steps from the first job.
- Removes all AWS config so that CD will only push to the Azure
  container registry, run migrations against the Azure-hosted database,
  and rotate the container images in the Azure k8s cluster.
2019-10-27 15:07:23 -04:00
dandds
62657b36ae Seed roles in the container used for integration tests. 2019-10-21 15:24:07 -04:00
dandds
7949c64b9b Initial set up for Ghost Inspector integration tests.
Adds a CircleCI integration for Ghost Inspector
(https://ghostinspector.com), a headless browser testing SaaS. The
README is updated with details about how to run GI locally.

Removes the bootstrap setup for Selenium testing with BrowserStack.
2019-10-14 16:32:38 -04:00
dandds
67ff70201e Add beat worker to the deployment.
We will run a separate pod for the beat worker. There should only ever
be a single beat worker (to avoid redundant work) so the number of
replicas needs to be managed independently.

This adds both the Kubernetes config for the new pod and additional
CircleCI config to swap a new image into the pod during CD.
2019-09-18 16:34:56 -04:00
dandds
78948797a8 Add prefix to Docker image tags.
With a prefix, it is easier to automatically sort and expire images
within the container registry.
2019-09-11 15:48:12 -04:00
dandds
ace222fe95 Push multiple Docker tags for image in CD.
This will allow Kubernetes resources that only pull images occasionally
(i.e., k8s jobs) to point to a static tag name, "latest", that is updated
regularly. It also means we can refer to that image in the k8s config
tracked in the repo, instead of out-of-date images.
2019-09-11 15:37:09 -04:00
dandds
485f578c78 Apply config changes for CSP file uploads.
This applies configuration changes for the Flask app and adds changes to
the Dockerfile so that the build can make a CSP-specific JS bundle. It
adds `write_dotenv` script that creates the appropriate `.env` file for
the `parcel` bundler depending on how the `CSP` environment variable is
set.

- Configure K8s environment variables for Flask CSP usage
- Supply default CSP config setting to Flask app
- Declare the CSP arg in the Dockerfile
- Supply extra Docker build args to CD
- Fix top-level reference to boto3 in file_upload module
- Add back missing sample NGINX config for docker-compose build
2019-08-09 08:05:20 -04:00
dandds
f3e032fc03 Finalize CD config and add k8s job for migrations.
Add CircleCI config for both CSPs to:
- build the Docker image and push it to the registry
- run a short-lived k8s job to apply migrations and see data
- update the images for the Flask pods and rq worker pods
2019-07-31 11:58:43 -04:00
dandds
4c70d59c5d Add k8s networking.
- bind static azure IPs
- Add load balancers for both CSPs
2019-07-31 11:58:08 -04:00
dandds
d056191b01 Working config for CD.
This adds the AWS and Azure CircleCI orbs for updating container images
in a cluster. It installs the clients for both CSPs, configures kubectl
with a programmatic user's auth information, and executes a `kubectl set
image` command to reset the cluster image to the one that was just
pushed to the container registry.
2019-07-31 11:58:08 -04:00
dandds
89852346f8 Push images to CSP registries during CD.
Add config (CircleCI Orb recipes) for building Docker images and pushing
the results to both AWS and Azure Docker registries.
2019-07-16 15:47:50 -04:00
dandds
6abbf4bac0 Upgrade Python to 3.7.3 and add PyYAML.
We should try and track mainline Python as much as possible.

PyYAML was a sub-dependency of a dev dependency but was being included
in the translations utility. Bundling only the production Python
dependencies was not working because of this.
2019-06-20 06:26:08 -04:00
dandds
99abf011d7 Remove CircleCI cache for now 2019-06-10 11:25:00 -04:00
dandds
b7b07ce89c Simpler CircleCI config for CI.
This relies on a CircleCI-supplied base image and removes CD for now.
2019-06-10 10:48:59 -04:00
dandds
75e863c671 update docker registry domain 2019-04-15 10:55:34 -04:00
dandds
c534ceda59 remove CRL caching from CircleCI config 2019-02-27 05:51:50 -05:00
dandds
725042ab76 modify crl storage config:
- make local container for libcloud storage if it does not exist
- separate config variables for CRL storage
2019-02-27 05:51:50 -05:00
Devon Mackay
ed418b61ba Pull the manifest for the newly pushed image 2019-01-17 12:51:49 -05:00
Devon Mackay
6dae283805 Dissuade docker push fomr using dynamicy output 2019-01-17 12:49:43 -05:00
Patrick Smith
88339e9d36 Use updated pip when building on CircleCI 2018-12-14 10:39:15 -05:00
dandds
f3c294659a refine test environment sample data script, add k8s role and role binding for updating sample data 2018-12-04 16:12:23 -05:00
dandds
bd0b7b9dcd script for rotating sample data on test env 2018-12-04 09:42:47 -05:00
dandds
bbeef23c45 test testing build 2018-12-03 16:34:39 -05:00
dandds
b54e3147c3 try scheduling nightly deploys for test env with CircleCI config 2018-12-03 09:11:25 -05:00
Patrick Smith
be632e0d4a Drop -circleci from generated image names 2018-10-25 15:58:09 -04:00
dandds
60cc49275b update circle ci build config 2018-10-24 11:21:22 -04:00
Patrick Smith
1f07b0fa33 Revert "Deploy this branch"
This reverts commit 2e4a8520a9a1f8a21ac5d2148f9902755663a850. `master`
will now be deployed.
2018-10-15 16:04:19 -04:00
Patrick Smith
0f658d5036 Add build step to generate build info 2018-10-15 16:02:35 -04:00
Patrick Smith
2e4a8520a9 Deploy this branch 2018-10-15 15:04:58 -04:00
Devon Mackay
b077ad9bac Make circleci image name unique 2018-10-15 14:48:03 -04:00
Devon Mackay
d52e92fddf Convert to only deploying master branch 2018-10-15 14:48:02 -04:00
Devon Mackay
f684990666 Set working directory to match final app location (fix venv issue) 2018-10-15 14:48:02 -04:00
Devon Mackay
43057e2fc0 Flush CRL cache 2018-10-15 14:48:02 -04:00
Devon Mackay
f6fdb44a87 Ensure permissions are preserved 2018-10-15 14:48:02 -04:00
Devon Mackay
1a68458a12 And also include /usr/bin, since the bin stubs for pip installed packages live there 2018-10-15 14:48:02 -04:00
Devon Mackay
82517e67d7 Fix site-packages reference 2018-10-15 14:48:02 -04:00
Devon Mackay
38c86362b0 Ensure system packages get copied to prod container 2018-10-15 14:48:02 -04:00
Devon Mackay
28d5544cef Add GIT_SHA env var for use by atst-update-deploy.sh 2018-10-15 14:48:02 -04:00
Devon Mackay
3c5ee0b65d Toggle CD on for the circleci-cd branch for testing 2018-10-15 14:48:02 -04:00
Devon Mackay
771db0dfdd Update image name 2018-10-15 14:48:02 -04:00
Devon Mackay
a9bdf45ac6 Finalize deploy and switch to master branch only 2018-10-15 14:48:02 -04:00
Devon Mackay
bbea6d66b5 Variablize image name 2018-10-15 14:48:02 -04:00
Devon Mackay
a07cc6d524 Fix syntax 2018-10-15 14:48:02 -04:00
Devon Mackay
b72269bf21 Change var name to match deploy script 2018-10-15 14:48:02 -04:00
Devon Mackay
d0cc4da9f0 Add deploy stage to the build 2018-10-15 14:48:02 -04:00
Devon Mackay
2ec2a22db0 Remove IMAGE_NAME output since it does not work properly 2018-10-15 14:48:02 -04:00
Devon Mackay
db522a2913 Add image building and pushing stage 2018-10-15 14:48:02 -04:00
Devon Mackay
d77383ad9a Convert to using workslow with separate jobs
- Split build into app_setup and test jobs
- Add workflow sequence info
- Add DB reset to cibuild since it uses a fresh DB in a new build stage
2018-10-15 14:48:02 -04:00