Skip to content
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

remove build args from composite key and replace all build args #1085

Merged

Conversation

tejal29
Copy link
Member

@tejal29 tejal29 commented Feb 28, 2020

Fixes #1008

Description

In this change, we remove all the build-args being added to composite key.

With --cache flag true, kaniko will try to optimize the builds. It will execute all the metadata command like "ENV", "ARG" and update the config.Env to find dependencies between stage.
It discards the updated config changes after the optimize phase.

In this PR, I added a change

  1. remove builds args seeded to composite cache key.
  2. Replace the command string with any ARG/ENV command which got executed before.

This will ensure, only layers which actually use the ARG will change if ARG value changes.

Added tests for the same.
Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes unit tests
  • [X ] Adds integration tests if needed.

See the contribution guide for more details.

Reviewer Notes

  • The code flow looks good.
  • Unit tests and or integration tests added.

Release Notes

Describe any changes here so maintainer can include it in the release notes, or delete this block.

`--build-args` will now be added to layer cache key only if it is used in the dockerfile command for that layer.

@googlebot googlebot added the cla: yes CLA signed by all commit authors label Feb 28, 2020
@tejal29 tejal29 requested a review from cvgw February 28, 2020 19:48
@cvgw
Copy link
Contributor

cvgw commented Mar 3, 2020

Would you mind expanding the Test_stageBuilder_build tests to cover this change by asserting that the cache key received by the mock only contain the correct values. Thanks

Copy link
Contributor

@cvgw cvgw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few questions and more tests

Copy link
Member Author

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering comments

pkg/executor/build.go Show resolved Hide resolved
pkg/executor/build.go Show resolved Hide resolved
pkg/executor/build.go Show resolved Hide resolved
@tejal29 tejal29 force-pushed the rm_buildargs_from_cache_key branch from 4bf24ed to b9f4c4b Compare March 5, 2020 00:57
@tejal29
Copy link
Member Author

tejal29 commented Mar 7, 2020

@cvgw Please take another look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes CLA signed by all commit authors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is there a way not to include build-args in the cache key?
3 participants