-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
False-positive cache-hit on COPY --from #870
Comments
I experience this problem too. Current workaround for me is using |
Just found this having the exact same issue using kaniko on cloud build. will try suggested work aorund/roll back. |
@cvgw Any movement on getting that fix merged? |
@mcfedr hoping to get merged this week |
I can also confirm this does not exist in This is how I recreated the issue locally using a test Dockerfile and AWS ECR as a Cache repo TestingWe can replicate this bug on our machine using Docker
# set some variables
docker_image="gcr.io/kaniko-project/executor:debug-v0.14.0"
ecr_endpoint="YOUR_AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com"
ecr_repo="YOUR_ECR_REPO_NAME"
# create our test Dockerfile
mkdir -p ./tmp/
cat <<'EOF' > ./tmp/Dockerfile
FROM busybox:latest as builder
COPY ./date.txt /tmp/date.txt
FROM busybox:latest
COPY --from=builder /tmp/date.txt /tmp/test.txt
EOF
# run kaniko debug image with some env vars
docker run \
--tty \
--interactive \
--rm \
--volume "$(pwd)/tmp:/app" \
--volume "$HOME/.aws":/root/.aws \
--env "AWS_DEFAULT_REGION=us-east-1" \
--env "ECR_ENDPOINT=${ecr_endpoint}" \
--env "ECR_REPO=${ecr_repo}" \
--entrypoint "" \
"${docker_image}" \
sh
# create ECR config file for kaniko
mkdir -p /kaniko/.docker/
cat <<EOF > /kaniko/.docker/config.json
{
"credHelpers": {
"${ECR_ENDPOINT}": "ecr-login"
}
}
EOF
# Create first image
echo $(date) > /app/date.txt
ecr_tag="test-$(date +%s)"
/kaniko/executor \
--context "/app" \
--dockerfile "/app/Dockerfile" \
--destination "${ECR_ENDPOINT}/${ECR_REPO}:${ecr_tag}" \
--cache-repo "${ECR_ENDPOINT}/${ECR_REPO}/cache" \
--cache=true \
--cleanup
echo "docker run -it --rm ${ECR_ENDPOINT}/${ECR_REPO}:${ecr_tag} cat /tmp/test.txt > image1.txt"
# Create 2nd Image
echo $(date) > /app/date.txt
ecr_tag="test-$(date +%s)"
/kaniko/executor \
--context "/app" \
--dockerfile "/app/Dockerfile" \
--destination "${ECR_ENDPOINT}/${ECR_REPO}:${ecr_tag}" \
--cache-repo "${ECR_ENDPOINT}/${ECR_REPO}/cache" \
--cache=true \
--cleanup
echo "docker run -it --rm ${ECR_ENDPOINT}/${ECR_REPO}:${ecr_tag} cat /tmp/test.txt > image2.txt"
# Create 3rd Image w/o Cache
echo $(date) > /app/date.txt
ecr_tag="test-$(date +%s)"
/kaniko/executor \
--context "/app" \
--dockerfile "/app/Dockerfile" \
--destination "${ECR_ENDPOINT}/${ECR_REPO}:${ecr_tag}" \
--cache-repo "${ECR_ENDPOINT}/${ECR_REPO}/cache" \
--cache=false \
--cleanup
echo "docker run -it --rm ${ECR_ENDPOINT}/${ECR_REPO}:${ecr_tag} cat /tmp/test.txt > image3.txt"
$ cat image{1..3}.txt
cat image1.
Tue Dec 10 14:30:10 UTC 2019
Tue Dec 10 14:30:10 UTC 2019
Tue Dec 10 15:09:24 UTC 2019
How to fix:Lets try again to build but with docker image
# Run Kaniko Image 0.13.0
docker_image="gcr.io/kaniko-project/executor:debug-v0.13.0"
# run kaniko debug image with some env vars
docker run \
--tty \
--interactive \
--rm \
--volume "$(pwd)/tmp:/app" \
--volume "$HOME/.aws":/root/.aws \
--env "AWS_DEFAULT_REGION=us-east-1" \
--env "ECR_ENDPOINT=${ecr_endpoint}" \
--env "ECR_REPO=${ecr_repo}" \
--entrypoint "" \
"${docker_image}" \
sh
# create ECR config file for kaniko
mkdir -p /kaniko/.docker/
cat <<EOF > /kaniko/.docker/config.json
{
"credHelpers": {
"${ECR_ENDPOINT}": "ecr-login"
}
}
EOF
echo $(date) > /app/date.txt
ecr_tag="test-$(date +%s)"
/kaniko/executor \
--context "/app" \
--dockerfile "/app/Dockerfile" \
--destination "${ECR_ENDPOINT}/${ECR_REPO}:${ecr_tag}" \
--cache-repo "${ECR_ENDPOINT}/${ECR_REPO}/cache" \
--cache=true \
--cleanup
echo "docker run -it --rm ${ECR_ENDPOINT}/${ECR_REPO}:${ecr_tag} cat /tmp/test.txt > image4.txt"
echo $(date) > /app/date.txt
ecr_tag="test-$(date +%s)"
/kaniko/executor \
--context "/app" \
--dockerfile "/app/Dockerfile" \
--destination "${ECR_ENDPOINT}/${ECR_REPO}:${ecr_tag}" \
--cache-repo "${ECR_ENDPOINT}/${ECR_REPO}/cache" \
--cache=true \
--cleanup
echo "docker run -it --rm ${ECR_ENDPOINT}/${ECR_REPO}:${ecr_tag} cat /tmp/test.txt > image5.txt"
$ cat image{4..5}.txt
Tue Dec 10 15:32:45 UTC 2019
cat image5. Tue Dec 10 15:35:38 UTC 2019
|
Once #899 is fixed this issue should be resolved |
This should be fixed as of master@a675098 Some assistance verifying that it is fixed would be appreciated. Thank you |
Is there a prebuilt image from master that I can test with? it looks like |
@mcfedr I think you can use the git hash, like |
@mcfedr you can check image versions in GCR https://console.cloud.google.com/gcr/images/kaniko-project/GLOBAL/executor?gcrImageListsize=30 |
@cvgw fix is working on the latest version for me. Dockerfile
kaniko output running multiple builds, changing source code |
@cvgw works for me too. Thanks! |
Thanks everyone for the help solving and verifying this issue. Closing, but feel free to reopen if it isn't 100% fixed |
Any info on when release version lands(0.15.0?)? (I can test commit based version, but won't be able to use non-release version in production.) |
@stroncium plan is to release v0.15.0 this week |
Hey folks, we're seeing the same issue on the most recent |
Also seeing this in |
Also seeing this in 1.6, examples described here #1348 as well. |
Actual behavior
I have a two stage docker image that first build sphinx docs and then copies it to the second nginx image:
I build it on Google Cloud Build using
gcr.io/kaniko-project/executor:latest
builder.The problem is the last copy instruction - even through generated HTML files differ from the previously built revision, kaniko still prefers to use the cached version:
Expected behavior
Detect that stage 0 image files' have changes and discard cache for
COPY --from
directive in the stage 1.To Reproduce
Steps to reproduce the behavior:
Then add the above Dockerfile under
docs/
.docs/index.rst
, commit, trigger new build and see that resulting images still has the old version of the docsAdditional Information
Triage Notes for the Maintainers
--cache
flagThe text was updated successfully, but these errors were encountered: