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

ValidateName always prints empty string as value instead of actual value #1646

Merged

Conversation

cedi
Copy link
Contributor

@cedi cedi commented Nov 23, 2021

What this PR does / why we need it:
This commit fixes an rather annoying issue where ValidateName does not
print the correct value of the invalid cluster name which made the issue
hard to debug.

Background:
I recently upgraded from an earlier KubeOne version to master and my cluster-name contained dots (.).
However since #1641 this is no longer valid.

The output of this validation looked like

$ kubeone apply --manifest kubeone.yaml --credentials credentials.yaml --tfjson output.json --auto-approve --verbose

Error: failed to initialize State: failed to build state: failed to load cluster: unable to load a given KubeOneCluster object: unable to validate the given KubeOneCluster object: name: Invalid value: "": .name should be lowercase and can only contain alphanumeric characters and hyphens(-)

With this commit in place the output looks like this:

$ kubeone install --manifest kubeone.yaml --credentials credentials.yaml --tfjson output.json --verbose
Error: failed to initialize State: failed to build state: failed to load cluster: unable to load a given KubeOneCluster object: unable to validate the given KubeOneCluster object: name: Invalid value: "k8s.cedi.dev": .name should be lowercase and can only contain alphanumeric characters and hyphens(-)

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

This commit fixes an rather annoying issue where `ValidateName` does not
print the correct value of the invalid cluster name which made the issue
hard to debug.

Background:
I recently upgraded from an earlier KubeOne version to master and my cluster-name contained dots (`.`).
However since kubermatic#1641 this is no longer valid.

The output of this validation looked like

```bash
$ kubeone apply --manifest kubeone.yaml --credentials credentials.yaml --tfjson output.json --auto-approve --verbose

Error: failed to initialize State: failed to build state: failed to load cluster: unable to load a given KubeOneCluster object: unable to validate the given KubeOneCluster object: name: Invalid value: "": .name should be lowercase and can only contain alphanumeric characters and hyphens(-)
```

With this commit in place the output looks like this:

```bash
$ kubeone install --manifest kubeone.yaml --credentials credentials.yaml --tfjson output.json --verbose
Error: failed to initialize State: failed to build state: failed to load cluster: unable to load a given KubeOneCluster object: unable to validate the given KubeOneCluster object: name: Invalid value: "k8s.cedi.dev": .name should be lowercase and can only contain alphanumeric characters and hyphens(-)
```

Signed-off-by: Cedric Kienzler <github@cedric-kienzler.de>
@kubermatic-bot kubermatic-bot added dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 23, 2021
@kubermatic-bot
Copy link
Contributor

Hi @cedi. Thanks for your PR.

I'm waiting for a kubermatic member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kubermatic-bot kubermatic-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 23, 2021
@kron4eg
Copy link
Member

kron4eg commented Nov 23, 2021

Thanks @cedi!

/lgtm
/approve

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 23, 2021
@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cedi, kron4eg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: c5a8636f4ed4adc8d40321048eff4efcd79614ed

@kubermatic-bot kubermatic-bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 23, 2021
@kubermatic-triage-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs

Review the full test history

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@kubermatic-bot kubermatic-bot merged commit 152cc4f into kubermatic:master Nov 23, 2021
@kubermatic-bot kubermatic-bot added this to the KubeOne 1.4 milestone Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. lgtm Indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants