Skip to content

fix: add upgrade logic to inject a kubectl deployer when an old kustomize deployer is detected#8457

Merged
renzodavid9 merged 5 commits into
GoogleContainerTools:mainfrom
renzodavid9:issue-8423
Mar 7, 2023
Merged

fix: add upgrade logic to inject a kubectl deployer when an old kustomize deployer is detected#8457
renzodavid9 merged 5 commits into
GoogleContainerTools:mainfrom
renzodavid9:issue-8423

Conversation

@renzodavid9

Copy link
Copy Markdown
Contributor

Fixes: #8423

Description
New logic to create a kubectl deployer when an old kustomize deployer is present during upgrade. The logic creates a new kubectl deployer and merge the values from the old kustomize deployer into it. When a kubectl deployer is already present, we try to merge it with the configuration from the old kustomize deployer. Code will error if the defaultNamespace or flags.disableValidation are present in both and are different.

@codecov

codecov Bot commented Feb 22, 2023

Copy link
Copy Markdown

Codecov Report

Merging #8457 (577d102) into main (290280e) will decrease coverage by 5.22%.
The diff coverage is 55.30%.

@@            Coverage Diff             @@
##             main    #8457      +/-   ##
==========================================
- Coverage   70.48%   65.26%   -5.22%     
==========================================
  Files         515      602      +87     
  Lines       23150    29935    +6785     
==========================================
+ Hits        16317    19537    +3220     
- Misses       5776     8932    +3156     
- Partials     1057     1466     +409     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/completion.go 13.04% <0.00%> (-1.25%) ⬇️
cmd/skaffold/app/cmd/config/list.go 65.21% <ø> (ø)
cmd/skaffold/app/cmd/config/set.go 88.72% <ø> (ø)
cmd/skaffold/app/cmd/config/util.go 54.28% <ø> (ø)
cmd/skaffold/app/cmd/credits.go 100.00% <ø> (ø)
cmd/skaffold/app/cmd/credits/export.go 0.00% <0.00%> (ø)
cmd/skaffold/app/cmd/deploy.go 40.90% <0.00%> (-12.94%) ⬇️
cmd/skaffold/app/cmd/generate_pipeline.go 60.00% <ø> (ø)
cmd/skaffold/app/cmd/inspect_modules.go 65.00% <ø> (ø)
cmd/skaffold/app/cmd/inspect_profiles.go 66.66% <ø> (ø)
... and 426 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@renzodavid9 renzodavid9 marked this pull request as ready for review February 22, 2023 15:55
@renzodavid9 renzodavid9 requested review from a team and aaron-prindle February 22, 2023 15:55
@aaron-prindle aaron-prindle requested review from gsquared94 and removed request for aaron-prindle February 23, 2023 07:18
Comment thread pkg/skaffold/schema/v2beta29/upgrade.go Outdated
kubectlDeployerWasInjected = true
}

if err := mergeKustomizeIntoKubectlDeployer(newPL.Deploy.KubectlDeploy, oldPL.Deploy.KustomizeDeploy, kubectlDeployerWasInjected); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will doing mergeKustomizeIntoKubectlDeployer(oldPL *Pipeline, newPL *next.Pipeline) simplify this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I moved all the logic to the new function I created, removing the third parameter used before. Let me know what do you think.

Comment thread pkg/skaffold/schema/v2beta29/upgrade.go Outdated
}
}

func mergeKustomizeIntoKubectlDeployer(newKubectlDeployer *next.KubectlDeploy, oldKustomizeDeployer *KustomizeDeploy, kubectlDeployerWasInjected bool) error {

@gsquared94 gsquared94 Feb 23, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a good reading about variable names here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks for the reference, I changed the variables name. Let me know what do you think.

@renzodavid9 renzodavid9 merged commit fa1f90a into GoogleContainerTools:main Mar 7, 2023
@BabuRajan002

Copy link
Copy Markdown

We upgraded our Skaffold verstion to latest version 2.3 and Max Schema version is v4beat4.
After that it stopped working during the deployment. Here is the sample file we are using

apiVersion: skaffold/v4beta4
kind: Config
metadata:
  name: sample-app
manifests:
  kustomize:
    paths:
      - </path/base>
profiles:
  - name: test
    manifests:
      kustomize:
        paths:
          - <path/kustomize>
        defaultNamespace: <dummy-namespace>

Our Kustomization's max schema version is "kustomize.config.k8s.io/v1beta1". Please help us to fix this issue. The current version we are using is 1.39 which accepts the above skaffold file with the kustomization version.

@renzodavid9

Copy link
Copy Markdown
Contributor Author

Hey @BabuRajan002, could you please open a new issue in the Skaffold repo with the details of the error you are getting? Also, it will be great if you can include a repo with a minimal version that can be use to reproduce the problem. I think for this case the content of the Kustomization file will be good to understand what's happening. Also, we can use that new issue to continue the discussion. Thanks a lot!

@BabuRajan002

Copy link
Copy Markdown

@renzodavid9 As you mentioned above, I've created a new issue here - #8802. But I did not get any response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants