Skip to content

Fix panic in node role determination#209

Open
jrauh01 wants to merge 1 commit into
mainfrom
fix/false-node-roles-determination
Open

Fix panic in node role determination#209
jrauh01 wants to merge 1 commit into
mainfrom
fix/false-node-roles-determination

Conversation

@jrauh01
Copy link
Copy Markdown
Collaborator

@jrauh01 jrauh01 commented Mar 25, 2026

The previous implementation used strings.SplitAfter and accessed index [1] unconditionally, causing an index out of range panic for labels like "node-role: master" that don't contain a "/".

Use strings.Cut to safely extract the role from the label name when a "/" is present, and fall back to the label value otherwise. This correctly handles both node-role.kubernetes.io/control-plane: "", node-role.kubernetes.io/control-plane: true, and node-role: master style labels.

The previous implementation used `strings.SplitAfter` and accessed index [1]
unconditionally, causing an index out of range panic for labels like
"node-role: master" that don't contain a "/".

Use `strings.Cut` to safely extract the role from the label name when a "/" is
present, and fall back to the label value otherwise. This correctly handles both
`node-role.kubernetes.io/control-plane: ""`,
`node-role.kubernetes.io/control-plane: true`, and `node-role: master` style
labels.
@jrauh01 jrauh01 self-assigned this Mar 25, 2026
@cla-bot cla-bot Bot added the cla/signed CLA is signed by all contributors of a PR label Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla/signed CLA is signed by all contributors of a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant