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

Avoid nil panic on non-GKE GCP clusters (K3s) #957

Merged
merged 2 commits into from
Oct 1, 2021

Conversation

michaelmdresser
Copy link
Contributor

What does this PR change?

A user running K3s on GCP is encountering a nil panic
caused by our parsing logic for the node.kubernetes.io/instance-type
label. On GCP, we expect GCP node type formats (xx-xx-xx) with
one or two dashes. The K3s cluster sets this value as just "k3s" in the
user's cluster.

By adding a guard on the length of the parsed result we avoid the panic.

Does this PR rely on any other PRs?

N/A

How does this PR impact users? (This is the kind of thing that goes in release notes!)

Fix a bug where a nil panic would occur when running on K3s clusters on GCP.

Links to Issues or ZD tickets this PR addresses or fixes

How was this PR tested?

Deployed to a GKE cluster to confirm nothing broke (no errors observed) and added unit test for the user's specific case.

Have you made an update to documentation?

N/A

A user running K3s on GCP is encountering a nil panic
caused by our parsing logic for the node.kubernetes.io/instance-type
label. On GCP, we expect GCP node type formats (xx-xx-xx) with
two dashes. The K3s cluster sets this value as just "k3s" in the
user's cluster.

By adding a guard on the length of the parsed result we avoid the panic.
Copy link
Contributor

@mbolt35 mbolt35 left a comment

Choose a reason for hiding this comment

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

LGTM

@michaelmdresser michaelmdresser merged commit 8c7206a into develop Oct 1, 2021
@michaelmdresser michaelmdresser deleted the mmd/fix-gcp-provider-k3s-panic branch October 1, 2021 20:18
@michaelmdresser michaelmdresser restored the mmd/fix-gcp-provider-k3s-panic branch October 1, 2021 20:18
@michaelmdresser michaelmdresser deleted the mmd/fix-gcp-provider-k3s-panic branch October 1, 2021 20:18
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

Successfully merging this pull request may close these issues.

2 participants