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

Fail Helm deployments early with missing templated values #5158

Merged
merged 5 commits into from
Dec 21, 2020

Conversation

briandealwis
Copy link
Member

Fixes #5072

Description

Fails Helm deployments early when release or namespaces reference missing templated values.

User facing changes (remove if N/A)
Helm deployments fail if the release name or namespaces are templated with missing values.

- error if the release name or namespaces have missing template values
- align formatting in cmd_helper to make it easier to compare error strings
@briandealwis briandealwis requested a review from a team as a code owner December 16, 2020 03:27
@briandealwis briandealwis requested a review from nkubala December 16, 2020 03:27
@google-cla google-cla bot added the cla: yes label Dec 16, 2020
@codecov
Copy link

codecov bot commented Dec 16, 2020

Codecov Report

Merging #5158 (b90381b) into master (ff0d65c) will decrease coverage by 0.41%.
The diff coverage is 86.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5158      +/-   ##
==========================================
- Coverage   72.32%   71.90%   -0.42%     
==========================================
  Files         382      384       +2     
  Lines       13589    13730     +141     
==========================================
+ Hits         9828     9873      +45     
- Misses       3040     3131      +91     
- Partials      721      726       +5     
Impacted Files Coverage Δ
pkg/skaffold/schema/latest/config.go 58.82% <ø> (ø)
pkg/skaffold/util/env_template.go 95.45% <66.66%> (-4.55%) ⬇️
pkg/skaffold/deploy/helm/deploy.go 75.60% <100.00%> (+3.83%) ⬆️
pkg/skaffold/deploy/helm/util.go 78.49% <100.00%> (ø)
pkg/skaffold/instrumentation/meter.go 23.02% <0.00%> (-41.50%) ⬇️
cmd/skaffold/app/tips/tips.go 54.54% <0.00%> (-12.13%) ⬇️
cmd/skaffold/app/cmd/util.go 65.71% <0.00%> (-0.96%) ⬇️
pkg/skaffold/runner/runner.go 0.00% <0.00%> (ø)
pkg/skaffold/initializer/build/util.go 100.00% <0.00%> (ø)
cmd/skaffold/app/cmd/test.go 53.84% <0.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff0d65c...b90381b. Read the comment docs.

return nil, userErr(fmt.Sprintf("deploying %q", releaseName), err)
}

// collect namespaces
for _, r := range results {
var namespace string
namespace, err = util.ExpandEnvTemplate(r.Namespace, nil)
// `<no value>` is not allowed within a namespace
namespace, err = util.ExpandEnvTemplateOrFail(r.Namespace, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

shd we move this check before deploy for config helm.releases[x].Namespace ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This namespace is actually expanded and checked in deployRelease() itself. So we're good on that front.

But this should be using h.releaseNamespace(r) since the user could override the namespace on the command-line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, we're ignoring the returned namespaces in our test.

_, err = deployer.Deploy(context.Background(), ioutil.Discard, test.builds)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, this should be the deployed artifact's namespace, and so should be expanded. Looking into this further.

Copy link
Member Author

Choose a reason for hiding this comment

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

We should just be using the namespace returned from Helm.

This code path isn't tested, but let me see if I can add some tests for this.

pkg/skaffold/deploy/helm/deploy.go Show resolved Hide resolved
@pull-request-size pull-request-size bot added size/L and removed size/M labels Dec 17, 2020
@tejal29 tejal29 merged commit 3597306 into GoogleContainerTools:master Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fail fast in Helm Templated fields
2 participants