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

'could not parse reference' for cached builds with UPPERCASE stage names #519

Closed
dinvlad opened this issue Jan 9, 2019 · 5 comments · Fixed by #983
Closed

'could not parse reference' for cached builds with UPPERCASE stage names #519

dinvlad opened this issue Jan 9, 2019 · 5 comments · Fixed by #983
Assignees
Labels
area/dockerfile-command For all bugs related to dockerfile file commands area/multi-stage builds issues related to kaniko multi-stage builds in progress kind/bug Something isn't working priority/p1 Basic need feature compatibility with docker build. we should be working on this next.

Comments

@dinvlad
Copy link

dinvlad commented Jan 9, 2019

Actual behavior
Multi-stage builds fail with

error building image: getting stage builder for stage 2: could not parse reference

if --cache=true and stage names contain UPPERCASE letters.

Expected behavior
Cached builds should succeed irregardless of character case in stage names.

To Reproduce
Steps to reproduce the behavior:

  1. Set up CloudBuild builds based on https://github.com/broadinstitute/kaniko-stage-naming-bug
    (the builds are trigged with --cache=true).
  2. The build should fail with
    WARN[0011] Error while retrieving image from cache: could not parse reference 
    error building image: getting stage builder for stage 2: could not parse reference
    

Stage 2 is the one trying to use the previous stage named with uppercase letters (see below). The build succeeds for stage 1, which refers to stage 0 with only lowercase letters and _.

Additional Information

  • Dockerfile
    FROM alpine as base_stage
    
    RUN echo base_stage
    
    
    FROM base_stage as BUG_stage
    
    RUN echo BUG_stage
    
    
    FROM BUG_stage as final_stage
    
    RUN echo final_stage
  • Build Context
    Does not apply.
  • Kaniko Image (fully qualified with digest)
    gcr.io/kaniko-project/executor@sha256:a3e1a4ac0fc9625ce0eb2f74094e4e801cb1164c93a1dd6b8d2306f6efee7d9a
@donmccasland donmccasland added area/multi-stage builds issues related to kaniko multi-stage builds priority/p1 Basic need feature compatibility with docker build. we should be working on this next. labels Sep 20, 2019
@cvgw cvgw added area/dockerfile-command For all bugs related to dockerfile file commands kind/bug Something isn't working labels Dec 23, 2019
@faiq
Copy link

faiq commented Jan 9, 2020

I've experienced this issue not only with stage build names but building docker images that start with an all caps from image.

ie:

FROM CENTOS
RUN ls 

fails for me.

@cvgw cvgw added this to the GA Release v1.0.0 milestone Jan 10, 2020
@cvgw
Copy link
Contributor

cvgw commented Jan 20, 2020

FROM CENTOS
RUN ls

I don't believe CENTOS is a valid image name. AFAIK only lowercase letters, _, and - are allowed.

Looking into the issue with stage aliases

@cvgw
Copy link
Contributor

cvgw commented Jan 20, 2020

I believe the issue is with this line

if stage.Name == stages[currentStage].BaseName {

as stage.Name will be all lowercase while stages[currentStage].BaseName will be the original case

like such

stage name bug_stage current stage idx 2 current stage base name BUG_stage

@cvgw
Copy link
Contributor

cvgw commented Jan 20, 2020

also here

if stage.BaseName == stages[index].Name {

@cvgw
Copy link
Contributor

cvgw commented Jan 20, 2020

I wonder if this line also should be updated

if stage.Name == target {

cvgw added a commit to cvgw/kaniko that referenced this issue Jan 20, 2020
update stage code so that when comparing the BaseName of
a stage against the recorded, lowercase version of a Stage name
the BaseName is also lowercased.
@cvgw cvgw self-assigned this Jan 20, 2020
tejal29 added a commit that referenced this issue Jan 21, 2020
Fix #519 capital letter in stage names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dockerfile-command For all bugs related to dockerfile file commands area/multi-stage builds issues related to kaniko multi-stage builds in progress kind/bug Something isn't working priority/p1 Basic need feature compatibility with docker build. we should be working on this next.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants