Skip to content

Enable unprefixed label setting via feature gate #2114

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fmuyassarov
Copy link
Member

@fmuyassarov fmuyassarov commented Mar 28, 2025

Currently, unprefixed labels are not allowed, despite the existence of the DisableAutoPrefix feature gate, which is intended for this purpose. This change ensures that when DisableAutoPrefix is set to True, the namespace addition is skipped, allowing unprefixed labels.
Fixes: #2074

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 28, 2025
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 28, 2025
Copy link

netlify bot commented Mar 28, 2025

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
🔨 Latest commit 881642e
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-nfd/deploys/67ed80ab6a44e80008b080af
😎 Deploy Preview https://deploy-preview-2114--kubernetes-sigs-nfd.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@fmuyassarov
Copy link
Member Author

/cc @marquiz

@k8s-ci-robot k8s-ci-robot requested a review from marquiz March 28, 2025 08:35
Copy link
Contributor

@marquiz marquiz left a comment

Choose a reason for hiding this comment

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

Thank you @fmuyassarov for working on this 🙏 Would it be possible to add some testing for this. E.g. in e2e tests enable feature gate in some test and check that unprefixed label gets created or smth?

@fmuyassarov
Copy link
Member Author

Thank you @fmuyassarov for working on this 🙏 Would it be possible to add some testing for this. E.g. in e2e tests enable feature gate in some test and check that unprefixed label gets created or smth?

Absolutely!

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 28, 2025
Currently, unprefixed labels are not allowed, despite the existence of the
DisableAutoPrefix feature gate, which is intended for this purpose. This
change ensures that when DisableAutoPrefix is set to True, the namespace
addition is skipped, allowing unprefixed labels.

Signed-off-by: Feruzjon Muyassarov <[email protected]>
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables unprefixed labels when the DisableAutoPrefix feature gate is set to true, bypassing the namespace addition for such labels.

  • Adjusts error handling in filterFeatureLabel to allow unprefixed labels when the feature gate is enabled.
  • Updates documentation to clarify the behavior of label prefixing with and without the feature gate.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/nfd-master/nfd-master.go Refactored error handling in filterFeatureLabel to bypass errors for unprefixed labels when the feature gate is enabled.
docs/reference/feature-gates.md Updated the description of label prefixing behavior to align with the new feature gate functionality.
Comments suppressed due to low confidence (1)

pkg/nfd-master/nfd-master.go:506

  • [nitpick] The compound conditional here could be refactored for better clarity; consider assigning sub-conditions to well-named variables or adding inline comments to explain the logic of bypassing the error when the feature gate is enabled.
if !nfdfeatures.NFDFeatureGate.Enabled(nfdfeatures.DisableAutoPrefix) || err != validate.ErrUnprefixedKeysNotAllowed {

@ArangoGutierrez
Copy link
Contributor

Thank you @fmuyassarov for working on this 🙏 Would it be possible to add some testing for this. E.g. in e2e tests enable feature gate in some test and check that unprefixed label gets created or smth?

LGTM will come after testing. PR looks good

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 2, 2025
Copy link
Contributor

@marquiz marquiz left a comment

Choose a reason for hiding this comment

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

Thank you @fmuyassarov for this PR.

I think that a similar treatment for annotations and extended resources, for consistency 🧐

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fmuyassarov, marquiz

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 2, 2025
@fmuyassarov
Copy link
Member Author

Thank you @fmuyassarov for this PR.

I think that a similar treatment for annotations and extended resources, for consistency 🧐

Sure, will do that.

@fmuyassarov
Copy link
Member Author

ping @ArangoGutierrez

1 similar comment
@marquiz
Copy link
Contributor

marquiz commented Apr 17, 2025

ping @ArangoGutierrez

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unprefixed keys are not allowed
4 participants