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

Wrong image is tagged on subsequent skaffold build #2694

Closed
demisx opened this issue Aug 21, 2019 · 9 comments · Fixed by #2728
Closed

Wrong image is tagged on subsequent skaffold build #2694

demisx opened this issue Aug 21, 2019 · 9 comments · Fixed by #2728
Assignees
Labels
area/build area/cache kind/bug Something isn't working priority/p1 High impact feature/bug.

Comments

@demisx
Copy link
Contributor

demisx commented Aug 21, 2019

Expected behavior

Subsequent skaffold build executions upon unchanged codebase do not tag wrong images.

Actual behavior

The first time I run skaffold build -p dev command I get 3 images built and tagged as expected. When I run the same command for the second time, wrong image gets retagged with "init-db" tag. Later when my app pulls these images from local repo it fails to bootstrap because the wrong image is tagged with "init-db:..." tag now. This does not happen in v0.31

Information

  • Skaffold version: 0.36
  • Operating system: MacOs 10.4.6
  • Contents of skaffold.yaml:
apiVersion: skaffold/v1beta13
kind: Config
profiles:
  - name: dev
    activation:
      - command: dev
    deploy:
      kubectl:
        manifests:
          - api/app/k8s/dev/api.k8s-config.yaml
          ... 
    build:
      artifacts:
        # Logstash data ingestor service
        - image: dl-logstash
          context: .
          sync:
            manual:
              - src: 'api/app/logstash/config/dev/pipeline/*'
                dest: pipeline
          docker:
            dockerfile: api/app/logstash/Dockerfile
            target: dev-env
       # Bootstrapping DB
        - image: init-db
          context: .
          docker:
            dockerfile: api/Dockerfile
            target: init-db
            buildArgs:
              DL_ORG_DEV_NAMESPACE: '{{.DL_ORG_DEV_NAMESPACE}}'
        # API service
        - image: dl-api.dev
          context: .
          sync:
            manual:
              - src: 'api/app/src/**/*.ts'
                dest: .
                strip: 'api'
              - src: 'api/app/src/**/*.json'
                dest: .
                strip: 'api'
          docker:
            dockerfile: api/Dockerfile
            target: dev-env
            buildArgs:
              # These vars are different per each developer and cannot be part of ConfigMap in git
              DL_ORG_DEV_NAMESPACE: '{{.DL_ORG_DEV_NAMESPACE}}'
              DL_ORG_AWS_ACCOUNT_ID: '{{.DL_ORG_AWS_ACCOUNT_ID}}'
              DL_ORG_AWS_IAM_APP_USER_ACCESS_KEY_ID: '{{.DL_ORG_AWS_IAM_APP_USER_ACCESS_KEY_ID}}'
              DL_ORG_AWS_IAM_APP_USER_SECRET_ACCESS_KEY: '{{.DL_ORG_AWS_IAM_APP_USER_SECRET_ACCESS_KEY}}'

Additional docs

Screen Shot 2019-08-20 at 6 18 15 PM

Screen Shot 2019-08-20 at 6 10 24 PM

Skaffold Run log:

double-skaffold-build-output.txt

@balopat balopat added area/build area/cache kind/bug Something isn't working priority/p1 High impact feature/bug. labels Aug 21, 2019
@balopat
Copy link
Contributor

balopat commented Aug 21, 2019

Thank you for filing, @demisx!
This looks like a bug in artifact caching. Is it an option for you turn it off with --cache-artifacts=false?

@demisx
Copy link
Contributor Author

demisx commented Aug 21, 2019

Hi @balopat. Thank you for your usual prompt response! I thought caching was off by default. Looking at the skaffold build -h output:

--cache-artifacts=true: Set to true to enable caching of artifacts

it sounds like I need to pass this option to enable caching. Am I reading it wrong?

@demisx
Copy link
Contributor Author

demisx commented Aug 21, 2019

I've confirmed that this issue doesn't happen in v0.36 if I run with --cache-artifacts=false flag:

skaffold build --cache-artifacts=false -p dev

@balopat
Copy link
Contributor

balopat commented Aug 22, 2019

Yeah, we switched it on by default with v0.36 - thank you for verifying the behavior!

@demisx
Copy link
Contributor Author

demisx commented Aug 22, 2019

Got it. Maybe the help output should be updated globally as well to be a little more clear:

--cache-artifacts=false: Set to false to disable default caching of artifacts

If this is just a matter of search & replace (I'm not a Go programmer yet), I can do it myself and submit a PR. Let me know

@balopat
Copy link
Contributor

balopat commented Aug 22, 2019

I think that's a good idea to make the default value a bit clearer! ideally an automated way would be the best - i.e. the text should pick up the default value from the Flag and we should use that. It's a good first issue to tackle as a go programmer ;) It's a bit tricky though to do it uniformly because not all default values make sense to put in the usage, e.g.:

https://github.com/GoogleContainerTools/skaffold/blob/master/cmd/skaffold/app/cmd/flags.go#L232-L240

We'll have to think about that a bit - but maybe "" -> "not set" and we could prefix all Usage with something like fmt.Sprintf("(default value: %s) %s", Def, Usage) in a loop

@demisx
Copy link
Contributor Author

demisx commented Aug 22, 2019

Agreed. That would be nice. In the meantime, please see if this update is still better than the status quo GH-2711

@balopat
Copy link
Contributor

balopat commented Aug 23, 2019

Thanks for that, it's going in now!

@dgageot
Copy link
Contributor

dgageot commented Aug 27, 2019

Here's the issue:

  • two of the images are created from the same sources but built with a different target.
  • The caching uses the digest of the input files as a key
  • So, skaffold thinks the first and second images should be the same...

Let me fix that.

@dgageot dgageot self-assigned this Aug 27, 2019
dgageot added a commit to dgageot/skaffold that referenced this issue Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build area/cache kind/bug Something isn't working priority/p1 High impact feature/bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants