Skip to content

Easier deployment of CI Docker containers #3117

Closed

Description

@GMNGeoffrey

Currently we use the prod tag as an indicator of which Docker containers for the CI build. When updating the images, someone usually has to manually push images with the "latest" tag, send their PR changing all instances of :prod to :latest, revert that change before submission, then build and push the images with the new tag. This is super annoying.

It's especially troublesome for #3065, where I actually change the docker image names and want to make atomic updates to other files with the container update.

Our current setup with Kokoro also has Kokoro preload docker images by tag, so we still want some sort of stable tag (as in the tag name doesn't change while what it points to does) that Kokoro can reference to know which image to preload. Even if the tag it's running with docker run doesn't exactly match, it should be a quick pull if the images are actually the same (it should just check the digest). That of course creates slightly more of a GCR dependency in the build stage than we had before, but nothing too bad, since we're pulling the image from there at some point anyway.

We also don't specify tags in the FROM instructions in our Dockerfiles which means they just get the latest for whichever base image. This can cause some confusing non-hermetic behavior.

Things that won't work well:

  1. Make FROM use the sha256 of the image from the registry. This will be super annoying because you'll have to push images to the registry in order to build. Gross.
  2. Make FROM statements use container IDs. This is totally unreadable.
  3. Use the git commit. We don't know the commit on main till a PR is pushed.

My suggestion is to make our Kokoro scripts use the registry digests. We can script something up to assist in updating these. This will ensure that we can make atomic and testable changes to the images. To ensure caching, we should still have a stable tag that points to the image that Kokoro should cache. We should be able to have some sort of automated job that ensures this tag matches the image built from the latest state on main.

FROM statements can use an ARG for the tag to allow the base image to be specified at build time. These will default to latest. Then we make https://github.com/google/iree/blob/main/build_tools/docker/build_and_update_gcr.py specify the tag. For the tag, we can use the git hash of the docker directory git rev-parse HEAD:build_tools/docker. Note that this is not a complete specification of the docker state because Docker does non-hermetic things, but it's the closest we can get without actually building the image and captures any updates we might be doing. I'm using git for hashing since everyone will need it installed anyway and it does some of the heavy lifting for us.

Then we can setup a bot (GitHub action?) that on each commit (can limit to those that touch build_tools/docker) checks for an image tagged with the current directory hash and tags it with "prod" (or we could call it something else). Kokoro uses this tag for caching. We'll want this job because otherwise Kokoro may be caching the wrong images but people no longer need to update it to get whatever they're working on, so are more likely to forget.

Note that this job needs to check for the tag existing because there are other files in that directory (like the README) that might get updated without the state changing. To avoid that issue we could instead pipe git ls-files -s to git hash-object, and create a hash for each Docker directory (already recorded in build_and_update_gcr.py).

So to start with all that needs to happen is to make the Kokoro scripts use the sha256, which I'd previously been hesitant to do because it's annoying to update and might screw up Kokoro caching, but I think will actually be better if we have this path forward.

@phoenix-meadowlark @antiagainst would appreciate your thoughts here.

Activity

  1. self-assigned this
    on Sep 10, 2020
  2. phoenix-meadowlark commented on Nov 18, 2020

    @phoenix-meadowlark
    Contributor

    Geoffrey and I discussed this and one thing that we could do to get rid of the manual post-submit steps is to generate a build_tools/docker/prod_digests.txt file from manage_images.py, and then use that file to tell a CI bot to:

    1. pull each image with the correct digest from GCR
    2. tag each image with :prod
    3. push each image back to GCR

    The digests in this file would be automatically updated by manage_images.py --update_references. New images could probably be automatically added that way as well. If possible it would be nice to avoid having to pull the images from GCR to re-tag them, but that might not be possible.

  3. added
    infrastructure
    on Nov 22, 2020
  4. removed their assignment
    on Jun 2, 2022
  5. benvanik commented on Jul 1, 2022

    @benvanik
    Collaborator

    Closing as obsolete.

  6. moved this to Done in IREEon Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    infrastructure

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions