devspace icon indicating copy to clipboard operation
devspace copied to clipboard

--skip-build uses cached image tag in generated.yaml

Open rvignesh89 opened this issue 3 years ago • 3 comments

What happened? In a project devspace configuration which has an image build section and also a replaceImage config, if we use devspace dev a docker build is performed and the image is tagged with a random value. This value then seems to be stored in .devspace/generated.yaml like below.

# .devspace/generated.yaml
varsEncrypted: true
profiles:
  "":
    images:
      test-project:
        imageName: test-project-image-name
        tag: YZdjOtm
    lastContext:
      namespace: test-project
      context: minikube
# devspace.yaml
version: v1beta10

images:
  test-project:
    image: test-project-image-name
    build:
      custom:
        command: ./docker-build.sh

dev:
  sync:
    - containerName: main
      labelSelector:
        role: app-server
      localSubPath: ./src
      containerPath: /app/src
  replacePods:
  - containerName: main
    labelSelector:
      role: app-server
    replaceImage: test-project-image-name-builder:latest
    patches:
    - op: remove
      path: spec.containers[0].securityContext
    - op: replace
      path: spec.containers[0].args
      value:
        - "sbt"
        - "set reStart / mainClass := Some(\"io.rvignesh.test-project\");~reStart"

The next time if I run devspace dev --skip-build the replaced pod uses the image tag YZdjOtm that was generated from the previous dev run, instead of using the replaceImage configuration in the dev section.

What did you expect to happen instead? If I use devspace dev --skip-build I expect devspace to honor the replaceImage in dev.replacePods section.

How can we reproduce the bug? (as minimally and precisely as possible)

  1. Create a devspace config with image build section and replaceImage configurations
  2. Run devspace dev which should build a new image and use it in the replaced pod
  3. Reset using devspace reset pods
  4. Run devspace dev --skip-build which should use the configuration in the replaceImage but instead it's using the tag from the previous build.

Local Environment:

  • DevSpace Version: 5.17.0
  • Operating System: mac
  • Deployment method: kubectl apply

Kubernetes Cluster:

  • Cloud Provider: aws
  • Kubernetes Version: 1.21

Anything else we need to know?

/kind bug

rvignesh89 avatar Dec 10 '21 01:12 rvignesh89

@rvignesh89 thanks for creating this issue! Could you provide a short example devspace.yaml so that we can reproduce this issue?

FabianKramm avatar Dec 10 '21 09:12 FabianKramm

Updated the issue description.

rvignesh89 avatar Dec 14 '21 00:12 rvignesh89

@rvignesh89 thanks for the update! This works as intended as devspace always prefers the self-built tags configured in images.*.tags. You can use the following configuration which should work:

version: v1beta10

images:
  test-project:
    image: test-project-image-name
    build:
      custom:
        command: ./docker-build.sh

dev:
  sync:
    - containerName: main
      labelSelector:
        role: app-server
      localSubPath: ./src
      containerPath: /app/src
  replacePods:
  - containerName: main
    labelSelector:
      role: app-server
    replaceImage: image(test-project-image-name):latest
    patches:
    - op: remove
      path: spec.containers[0].securityContext
    - op: replace
      path: spec.containers[0].args
      value:
        - "sbt"
        - "set reStart / mainClass := Some(\"io.rvignesh.test-project\");~reStart"

FabianKramm avatar Dec 14 '21 08:12 FabianKramm