-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARROW-10798: [CI] Made certain workflows be less triggered on changes of dockerfiles #8824
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ on: | |
push: | ||
paths: | ||
- '.github/workflows/ruby.yml' | ||
- 'ci/docker/**' | ||
- 'ci/docker/linux-apt-ruby.dockerfile' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would need to list all dockerfiles used in the parent images, in this case:
though if we wan't to run
This hierarchy is encoded in the docker-compose.yml depending on the env variables as well. |
||
- 'ci/scripts/c_glib_*' | ||
- 'ci/scripts/cpp_*' | ||
- 'ci/scripts/msys2_*' | ||
|
@@ -33,7 +33,7 @@ on: | |
pull_request: | ||
paths: | ||
- '.github/workflows/ruby.yml' | ||
- 'ci/docker/**' | ||
- 'ci/docker/linux-apt-ruby.dockerfile' | ||
- 'ci/scripts/c_glib_*' | ||
- 'ci/scripts/cpp_*' | ||
- 'ci/scripts/msys2_*' | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to add this one (or similar) to the R, Python, and Ruby jobs too. Their dockerfiles generally build on the cpp images (you can trace through the
base
parameter in docker-compose.yml, e.g. https://github.com/apache/arrow/blob/master/docker-compose.yml#L430)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it took me so long to go through this comment. I actually think that this PR is correct, but it surfaces a bigger problem present in master.
Let's say that we have an image X (typically build via
archery build X
), that depends on abase
image (typically build viaarchery build base
).Let's analyze what happens in the following 4 cases:
Let's also call the hash of the current base image in the registry as
base_v1
.push to PR with no change to base image's dockerfile
When a PR is open, image X is built using the dockerfile on the PR for that image, and it uses
base_v1
from the registry to base its build from.push to master with no change to base image's dockerfile
Same as before.
push to PR with a change to base image's dockerfile
In this situation, the PR triggers two CI jobs: the build of image
X
and the build imagebase
. Since these two jobs are independent workflows, imageX
will pickbase_v1
, while the base image job will buildbase_v2
.This happens because
docker-compose run X
does not know thatX
depends on the compose jobbase
to create the imagebase
, and instead has that image available from the remote docker registry${REPO}
.Because PRs do not push images to the registry, a new push to the PR will not alter this behavior: the image
X
will continue to be built based onbase_v1
. Thus, any error derived from building imageX
from the new imagebase_v2
will not surface.push to master with a change to base image's dockerfile (e.g. PR is merged)
In this situation, there is a race condition (undefined behavior): image X will be built using
base_v1
if it starts running before the flowbuild image base
finishes (the likely scenario), or it picksbase_v2
if the other flow has finished.Thus, atm, whenever a PR changes both dockerfiles,
X
andbase
, the image X on the registry is based ofbase_v1
, butbase:latest
points tobase_v2
.Thus, even if the new dockerfile is incompatible with
base_v2
, the CI will actually pass in master because it picksbase_v1
. On the next push to master that triggersX
to be built, it will pickbase_v2
, and the error surfaces 🤯Summary
In both cases where the dockerfile of
base
changes, that change is not propagated to the build ofX
. Therefore, IMO this PR is correct: changes to thedockerfile
of imagebase
do not require to trigger a change to the build of the imageX
, because there are no constraints in the jobs to buildX
to wait for the build of imagebase
.This issue seems to indicate that our builds based of docker images that depend on other docker images that are build using
docker-compose build
may be too complex as there is hidden state through the registry.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's correct but maybe @kszucs can weigh in definitively. My understanding of how docker works (which may be wrong) is that if image
Y
is based dockerfiley
, andy
is changed, thenY
gets rebuilt locally indocker-compose build Y
. Ify
is based on imageX
(and therefore dockerfilex
), andx
is changed, buildingY
will first buildX
and then proceed usingy
to buildY
.I see a few options:
The risks entailed by #3 are probably low--these files change infrequently, and unless we're doing a wholesale refactor of docker images, they're probably low risk changes. At the same time, the cost of doing #2 is also very low and prevents the surprise failures that #3 could later cause. Given the low costs (and my hesitance to make definitive statements about how docker/docker-compose handles dependent dockerfiles), I still advocate for option #2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion: I agree with you and I do think that we should use 2 regardless, I side-tracked into a potential issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did a quick check to verify this, and AFAI can tell my hypothesis holds:
My understanding is that docker has no idea about
docker-compose
and how images get built; it only knows about where images are located, via registries. To declare such a dependency of image builds, Docker uses Multi-stage builds. Furthermore, docker-compose also does not declare image dependencies, only service dependencies (i.e. containers, not images).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, neither does docker nor docker-compose have an idea about the image hierarchy but archery does.
archery build
andarchery run
commands are idempotent, meaning that the produced docker images are going to be the same for the same input configuration regardless of the state in the docker registry.See the commands called underneath the
archery docker run
command: