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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 [Skaffold Profiles] - Profile Dependencies Failing to Resolve When Specified Individually but Succeeding in Composite Profile #9346

Closed
theobolo opened this issue Mar 15, 2024 · 1 comment

Comments

@theobolo
Copy link

theobolo commented Mar 15, 2024

Expected behavior

When running Skaffold with multiple profiles specified individually, all of which include dependencies on other configurations, I expect Skaffold to fetch and deploy all dependencies as it successfully does when a composite profile containing the same dependencies is used.

Actual behavior

When running Skaffold with the individual profiles (e.g., skaffold dev -p profile-a,profile-b,profile-c), one of the dependencies specified in the individual profiles is consistently not fetched and deployed. However, when a composite profile that wraps these individual profiles together is used, all dependencies are correctly fetched and deployed.

Information

  • Skaffold version: v2.10.1
  • Operating system: Ubuntu 23.10 / Kernel 6.7.8
  • Installed via: Github Latest Release
  • Contents of skaffold.yaml:

Main skaffold.yaml - service-main

apiVersion: skaffold/v4beta5
kind: Config
metadata:
  name: service-main

requires:
  - configs: ["deps-services"]
    git:
      repo: git@github.com:exampleuser/deps-services.git
    activeProfiles:
      - name: dev
        activatedBy: [dev]

profiles:
  - name: dev
    build:
      tagPolicy:
        sha256: {}
      artifacts:
        - image: gcr.io/my-project/service-main
          context: .
          docker:
            buildArgs: { PROFILE: dev }
            secrets:
              - id: GITHUB_TOKEN
                env: GITHUB_TOKEN
      local:
        concurrency: 0
        useBuildkit: true
    manifests:
      rawYaml:
        - k8s/development/service-main/*.yaml
    deploy:
      kubectl: {}
    portForward:
      - resourceType: service
        resourceName: service-main-http
        port: 80
        localPort: 60001
    activation:
      - kubeContext: minikube

  - name: profile-a
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-a"]
            git:
              repo: git@github.com:exampleuser/service-a.git
              ref: main

  - name: profile-b
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-b"]
            git:
              repo: git@github.com:exampleuser/service-b.git
              ref: main

  - name: profile-c
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-c"]
            git:
              repo: git@github.com:exampleuser/service-c.git
              ref: main

  - name: composite-profile
    requires:
      - configs: ["service-a"]
        git:
          repo: git@github.com:exampleuser/service-a.git
          ref: main
      - configs: ["service-b"]
        git:
          repo: git@github.com:exampleuser/service-b.git
          ref: main
      - configs: ["service-c"]
        git:
          repo: git@github.com:exampleuser/service-c.git
          ref: main

Remote skaffold.yaml - service-a

apiVersion: skaffold/v4beta5
kind: Config
metadata:
  name: service-a

requires:
  - configs: ["deps-services"]
    git:
      repo: git@github.com:exampleuser/deps-services.git
    activeProfiles:
      - name: dev
        activatedBy: [dev]

profiles:
  - name: dev
    build:
      tagPolicy:
        sha256: {}
      artifacts:
        - image: gcr.io/my-project/service-a
          context: .
          docker:
            dockerfile: Dockerfile.dev
            secrets:
              - id: GITHUB_TOKEN
                env: GITHUB_TOKEN
      local:
        concurrency: 0
        useBuildkit: true
    manifests:
      rawYaml:
        - k8s/development/service-a/*.yaml
    deploy:
      kubectl: {}
    portForward:
      - resourceType: service
        resourceName: service-a-http
        port: 80
        localPort: 60002
    activation:
      - kubeContext: minikube

  - name: service-b
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-b"]
            git:
              repo: git@github.com:exampleuser/service-b.git
              ref: main

  - name: service-c
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-c"]
            git:
              repo: git@github.com:exampleuser/service-c.git
              ref: main
 
  - name: service-main
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-main"]
            git:
              repo: git@github.com:exampleuser/service-main.git
              ref: main

Remote skaffold.yaml - service-b

apiVersion: skaffold/v4beta5
kind: Config
metadata:
  name: service-b

requires:
  - configs: ["deps-services"]
    git:
      repo: git@github.com:exampleuser/deps-services.git
    activeProfiles:
      - name: dev
        activatedBy: [dev]

profiles:
  - name: dev
    build:
      tagPolicy:
        sha256: {}
      artifacts:
        - image: gcr.io/my-project/service-b
          context: .
          docker:
            dockerfile: Dockerfile.dev
            secrets:
              - id: GITHUB_TOKEN
                env: GITHUB_TOKEN
      local:
        concurrency: 0
        useBuildkit: true
    manifests:
      rawYaml:
        - k8s/development/service-b/*.yaml
    deploy:
      kubectl: {}
    portForward:
      - resourceType: service
        resourceName: service-b-http
        port: 80
        localPort: 60003
    activation:
      - kubeContext: minikube
      
  - name: service-a
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-a"]
            git:
              repo: git@github.com:exampleuser/service-a.git
              ref: main

  - name: service-c
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-c"]
            git:
              repo: git@github.com:exampleuser/service-c.git
              ref: main
 
  - name: service-main
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-main"]
            git:
              repo: git@github.com:exampleuser/service-main.git
              ref: main

Remote skaffold.yaml - service-c

apiVersion: skaffold/v4beta5
kind: Config
metadata:
  name: service-c

requires:
  - configs: ["deps-services"]
    git:
      repo: git@github.com:exampleuser/deps-services.git
    activeProfiles:
      - name: dev
        activatedBy: [dev]

profiles:
  - name: dev
    build:
      tagPolicy:
        sha256: {}
      artifacts:
        - image: gcr.io/my-project/service-c
          context: .
          docker:
            dockerfile: Dockerfile.dev
            secrets:
              - id: GITHUB_TOKEN
                env: GITHUB_TOKEN
      local:
        concurrency: 0
        useBuildkit: true
    manifests:
      rawYaml:
        - k8s/development/service-c/*.yaml
    deploy:
      kubectl: {}
    portForward:
      - resourceType: service
        resourceName: service-c-http
        port: 80
        localPort: 60004
    activation:
      - kubeContext: minikube

  - name: service-a
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-a"]
            git:
              repo: git@github.com:exampleuser/service-a.git
              ref: main

  - name: service-b
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-b"]
            git:
              repo: git@github.com:exampleuser/service-b.git
              ref: main
 
  - name: service-main
    patches:
      - op: add
        path: /requires
        value:
          - configs: ["service-main"]
            git:
              repo: git@github.com:exampleuser/service-main.git
              ref: main

Remote skaffold.yaml - dep-service

apiVersion: skaffold/v4beta5
kind: Config
metadata:
  name: deps-services

requires:
  - configs: ["database"]
    path: ./database
    activeProfiles: &dev_and_cloud_profiles
      - name: dev
        activatedBy: [dev]

  - configs: ["messaging"]
    path: ./messaging
    activeProfiles: *dev_and_cloud_profiles

  - configs: ["storage"]
    path: ./storage
    activeProfiles: *dev_and_cloud_profiles

profiles:
  - name: dev
    build:
      local:
        concurrency: 0
        useBuildkit: true
    activation:
      - kubeContext: minikube

Steps to reproduce the behavior

  1. Clone the repository which includes the generic service-main Skaffold configuration.
  2. Run skaffold dev -p profile-a,profile-b,profile-c (profile names are placeholders for the generic services used in this issue report).
  3. Observe that not all specified dependencies are deployed, one dependency (e.g., service-a) is missing.
  4. Run skaffold dev -p composite-profile which includes all dependencies as a comparison.
  5. Observe that when using the composite profile, all dependencies (service-a, service-b, and service-c) are deployed as expected.

Logs for the failing behavior when individual profiles are specified (ensure you鈥檝e redacted any sensitive information):

ghosty@ghosty-1337:~/Documents/Projects/service-main$ skaffold dev -p profile-a,profile-b,profile-c
Generating tags...
 - gcr.io/my-project/service-b -> gcr.io/my-project/service-b:latest
 - gcr.io/my-project/service-c -> gcr.io/my-project/service-c:latest
 - gcr.io/my-project/service-main -> gcr.io/my-project/service-main:latest

Logs for the successful behavior when using the composite profile:

ghosty@ghosty-1337:~/Documents/Projects/service-main$ skaffold dev -p composite-profile
Generating tags...
 - gcr.io/my-project/service-a -> gcr.io/my-project/service-a:latest
 - gcr.io/my-project/service-b -> gcr.io/my-project/service-b:latest
 - gcr.io/my-project/service-c -> gcr.io/my-project/service-c:latest
 - gcr.io/my-project/service-main -> gcr.io/my-project/service-main:latest
@theobolo theobolo changed the title [Skaffold Profiles] - 馃悰Profile Dependencies Failing to Resolve When Specified Individually but Succeeding in Composite Profile 馃悰 [Skaffold Profiles] - Profile Dependencies Failing to Resolve When Specified Individually but Succeeding in Composite Profile Mar 15, 2024
@renzodavid9
Copy link
Contributor

From conversation with @theobolo, for this specific case we can change the way the patches are defined to:

...
  - name: profile-a
    patches:
      - op: add
         path: /requires/-
         value:
            configs: ["service-a"]
            git:
              repo: git@github.com:exampleuser/service-a.git
              ref: main

  - name: profile-b
    patches:
      - op: add
         path: /requires/-
         value:
           configs: ["service-b"]
           git:
             repo: git@github.com:exampleuser/service-b.git
             ref: main

  - name: profile-c
    patches:
       - op: add
          path: /requires/-
          value:
            configs: ["service-c"]
            git:
              repo: git@github.com:exampleuser/service-c.git
              ref: main

I'll proceed to close this. Thanks!

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

No branches or pull requests

2 participants