tiltfile: fix ignores if context dir appears later#6467
Closed
liskin wants to merge 1 commit intotilt-dev:masterfrom
Closed
tiltfile: fix ignores if context dir appears later#6467liskin wants to merge 1 commit intotilt-dev:masterfrom
liskin wants to merge 1 commit intotilt-dev:masterfrom
Conversation
Consider the following (admittedly somewhat unusual) Tiltfile:
trigger_mode(TRIGGER_MODE_MANUAL)
clone_cmd = "test -e tilt-avatars || git clone https://github.com/tilt-dev/tilt-avatars"
custom_build(
"x-clone-repo",
deps = [],
skips_local_docker = True,
command = clone_cmd,
)
docker_build(
"x-build-image",
context = "tilt-avatars",
dockerfile_contents = "\n".join([
"FROM x-clone-repo",
"FROM scratch",
"COPY ./ /opt/app/",
]),
ignore = [
"**/.git",
],
)
k8s_custom_deploy(
name = "x-dummy-resource",
apply_cmd = "true",
delete_cmd = "true",
deps = [],
image_deps = ["x-build-image"],
)
This implements on-demand git cloning — the clone happens during the
build phase of the resource, and thus other builds can proceed
concurrently and this may speed up overall tilt up (and it does in the
quite complex tilt setup that we have).
In current Tilt, however, `ignore` and `only` are completely ignored if
the context directory doesn't exist when the Tiltfile is loaded. This is
quite a strange and seemingly pointless limitation, as everything else
seems to work fine.
The fix is trivial — simply remove the IsDir check from
`dockerignoresFromPathsAndContextFilters`. The code that follows the
check handles the absence of the dockerignore files just fine, so it
seems the IsDir check is simply forgotten there from previous
iterations.
Note that a similar issue exists in the `repoIgnoresForPaths` function
as well. The Tiltfile to reproduce that problem is the same, just
without the `ignore = ["**/.git"]` bit. I'm not entirely sure if that
`isGitRepoBase` check serves any real purpose — would there be any harm
if ".git" was ignored unconditionally (well, we'd need to check for the
empty path like `dockerignoresFromPathsAndContextFilters` does)?
Related: tilt-dev#3048 (comment)
Signed-off-by: Tomas Janousek <tomi@nomi.cz>
3a95022 to
33af3fd
Compare
Contributor
|
hmmm...nice find! i'm not sure this is the right fix. note that the integration tests are failing. AFAIR the problem we ran into is that what if we changed the logic to something like i think that would fix your use-case a bit more narrowly. |
Contributor
|
closing as stale |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Consider the following (admittedly somewhat unusual) Tiltfile:
This implements on-demand git cloning — the clone happens during the build phase of the resource, and thus other builds can proceed concurrently and this may speed up overall tilt up (and it does in the quite complex tilt setup that we have).
In current Tilt, however,
ignoreandonlyare completely ignored if the context directory doesn't exist when the Tiltfile is loaded. This is quite a strange and seemingly pointless limitation, as everything else seems to work fine.The fix is trivial — simply remove the IsDir check from
dockerignoresFromPathsAndContextFilters. The code that follows the check handles the absence of the dockerignore files just fine, so it seems the IsDir check is simply forgotten there from previous iterations.Note that a similar issue exists in the
repoIgnoresForPathsfunction as well. The Tiltfile to reproduce that problem is the same, just without theignore = ["**/.git"]bit. I'm not entirely sure if thatisGitRepoBasecheck serves any real purpose — would there be any harm if ".git" was ignored unconditionally (well, we'd need to check for the empty path likedockerignoresFromPathsAndContextFiltersdoes)?Related: #3048 (comment)