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

fix: properly wire deploy.kubectl.defaultNamespace field to be set in SKAFFOLD_NAMESPACES #8129

Merged
merged 1 commit into from
Nov 28, 2022

Conversation

aaron-prindle
Copy link
Contributor

fixes #7995

manually tested using repro skaffold.yaml

apiVersion: skaffold/v4beta1
kind: Config
build:
  artifacts:
  - image: skaffold-example
manifests:
  rawYaml:
  - k8s-pod.yaml
deploy:
  kubectl:
    defaultNamespace: test-ns
    hooks:
      before:
        - host:
            command: [ "sh", "-c", "echo $SKAFFOLD_NAMESPACES" ]
      after:
        - host:
           command: [ "sh", "-c", "echo $SKAFFOLD_NAMESPACES" ]

Before fix:

aprindle@aprindle-ssd ~/testNS $ skaffold dev --default-repo=gcr.io/aprindle-test-cluster
Listing files to watch...
 - skaffold-example
Generating tags...
 - skaffold-example -> gcr.io/aprindle-test-cluster/skaffold-example:latest
Some taggers failed. Rerun with -vdebug for errors.
Checking cache...
 - skaffold-example: Found Remotely
Tags used in deployment:
 - skaffold-example -> gcr.io/aprindle-test-cluster/skaffold-example:latest@sha256:9e84858382575e6f47a5a1162466a378e7ec8a79859095145794ca4df66a1582
Starting deploy...
Starting pre-deploy hooks...

Completed pre-deploy hooks
 - error: the namespace from the provided object "default" does not match the namespace "test-ns". You must pass '--namespace=default' to perform this operation.
Cleaning up...
 - error: the namespace from the provided object "default" does not match the namespace "test-ns". You must pass '--namespace=default' to perform this operation.
WARN[0002] deployer cleanup:kubectl delete: exit status 1  subtask=-1 task=DevLoop
kubectl apply: exit status 1

After fix:

aprindle@aprindle-ssd ~/testNS $ skaffold dev --default-repo=gcr.io/aprindle-test-cluster
Listing files to watch...
 - skaffold-example
Generating tags...
 - skaffold-example -> gcr.io/aprindle-test-cluster/skaffold-example:latest
Some taggers failed. Rerun with -vdebug for errors.
Checking cache...
 - skaffold-example: Found Remotely
Tags used in deployment:
 - skaffold-example -> gcr.io/aprindle-test-cluster/skaffold-example:latest@sha256:9e84858382575e6f47a5a1162466a378e7ec8a79859095145794ca4df66a1582
Starting deploy...
Starting pre-deploy hooks...
test-ns
Completed pre-deploy hooks
 - pod/getting-started created
Waiting for deployments to stabilize...
 - pods is ready.
Deployments stabilized in 3.213 seconds
Starting post-deploy hooks...
test-ns
Completed post-deploy hooks
Waiting for deployments to stabilize...
Deployments stabilized in 34.480275ms
Press Ctrl+C to exit
Watching for changes...
[getting-started] Hello world!

Note: before the fix SKAFFOLD_NAMESPACES is empty in pre/post hook AND deploy fails. Fixed now

@codecov
Copy link

codecov bot commented Nov 22, 2022

Codecov Report

Merging #8129 (1173f9d) into main (290280e) will decrease coverage by 4.19%.
The diff coverage is 53.26%.

@@            Coverage Diff             @@
##             main    #8129      +/-   ##
==========================================
- Coverage   70.48%   66.28%   -4.20%     
==========================================
  Files         515      599      +84     
  Lines       23150    29355    +6205     
==========================================
+ Hits        16317    19459    +3142     
- Misses       5776     8447    +2671     
- Partials     1057     1449     +392     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/completion.go 13.04% <0.00%> (-1.25%) ⬇️
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/test.go 44.44% <0.00%> (ø)
cmd/skaffold/app/exitcode.go 100.00% <ø> (+6.66%) ⬆️
cmd/skaffold/skaffold.go 0.00% <0.00%> (ø)
cmd/skaffold/app/cmd/inspect_tests.go 62.50% <14.28%> (-1.14%) ⬇️
cmd/skaffold/app/cmd/render.go 35.48% <18.18%> (-5.90%) ⬇️
cmd/skaffold/app/cmd/lsp.go 28.12% <28.12%> (ø)
cmd/skaffold/app/cmd/run.go 64.28% <33.33%> (-9.63%) ⬇️
... and 394 more

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

defaultNamespace value is not put in the SKAFFOLD_NAMESPACES environment variable for deploy hook usage
2 participants