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

Kaniko allows to access undefined variables when cache is enabled #1912

Closed
apollo13 opened this issue Feb 2, 2022 · 0 comments · Fixed by #1915
Closed

Kaniko allows to access undefined variables when cache is enabled #1912

apollo13 opened this issue Feb 2, 2022 · 0 comments · Fixed by #1915

Comments

@apollo13
Copy link
Contributor

apollo13 commented Feb 2, 2022

Note to maintainers: Attached a patch in #1915 -- not sure how to test that though, hints welcome.

Actual behavior
Kaniko allows to access ARGS/ENV variables that are not yet defined when --cache=true is used

Expected behavior
Undefined variables should behave as one would expect from a shell

To Reproduce

  1. Use this dockerfile:
FROM alpine as build
ARG TEST=123
RUN echo $TESTNOTSET
ARG TESTNOTSET=ups
  1. Run with & without --cache

Without cache:

INFO[0002] Running: [/bin/sh -c echo $TESTNOTSET]       

INFO[0002] Taking snapshot of full filesystem...        

with cache:

INFO[0002] Running: [/bin/sh -c echo $TESTNOTSET]       
ups
INFO[0002] Taking snapshot of full filesystem...        

Additional Information

  • Dockerfile: see above
  • Build Context: empty
  • Kaniko Image (fully qualified with digest) gcr.io/kaniko-project/executor:bde904349e9b7797d14f12c7a2657bf79145d18e-debug

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use --cache flag
Please check if your dockerfile is a multistage dockerfile

Note, this is probably related to #1910 because optimize() accumulates all ENV/ARG variables before they should be used

imjasonh pushed a commit that referenced this issue Feb 9, 2022
* Restore build args after optimize. Fixes #1910, #1912.

* Apply review suggestions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant