Skip to content

Conversation

ozhuraki
Copy link
Contributor

@ozhuraki ozhuraki commented Aug 5, 2025

Closes: #2026

Copy link

netlify bot commented Aug 5, 2025

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
🔨 Latest commit e41822c
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-nfd/deploys/68c04089a5ac300009191301
😎 Deploy Preview https://deploy-preview-2255--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 project configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 5, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @ozhuraki. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 5, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ozhuraki
Once this PR has been reviewed and has the lgtm label, please assign marquiz for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 5, 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.

Thanks @ozhuraki for starting to work on this.

I have two main comments:

  1. The main motivation for this feature is decreasing the size of the NodeFeature object(s). We need filtering for the "raw" features that get into those CRs. For the labels we have adequate controls (I think).
  2. We need some more expressive mechanism than one-regexp-to-rule-them-all. Like Only show cpu.cpuid.AVX512* and cpu.cpuid.AMX but nothing else or Filter out all PCI devices with class 08

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 30, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 9, 2025
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 adds feature allowlist and denylist functionality to the nfd-worker component, providing granular control over which features are published to the Kubernetes API server. This addresses issue #2026 by implementing regex-based filtering for feature names.

  • Adds FeatureAllowList and FeatureDenyList configuration options to the core config
  • Implements filtering logic to check features against both allowlist and denylist patterns
  • Adds command-line flags for configuring the new filter options

Reviewed Changes

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

File Description
pkg/nfd-worker/nfd-worker.go Adds core filtering functionality with config fields and filter logic
cmd/nfd-master/main.go Adds command-line flag support for the new filtering options

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

ExtraLabelNs: &utils.StringSetVal{},
ResyncPeriod: &utils.DurationVal{Duration: time.Duration(1) * time.Hour},
LabelWhiteList: &utils.RegexpVal{},
FeatureAlowList: &utils.RegexpVal{},
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

Typo in field name: 'FeatureAlowList' should be 'FeatureAllowList' (missing 'l').

Suggested change
FeatureAlowList: &utils.RegexpVal{},
FeatureAllowList: &utils.RegexpVal{},

Copilot uses AI. Check for mistakes.

klog.InfoS("feature matches the denylist", "feature", name, "regexp", featureDenyList.String())
}

if !(!denied && allowed) {
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

The logic condition !(!denied && allowed) is unnecessarily complex and hard to read. It should be simplified to denied || !allowed using De Morgan's law for better clarity.

Suggested change
if !(!denied && allowed) {
if denied || !allowed {

Copilot uses AI. Check for mistakes.


allowed := featureAllowList.MatchString(name)
if !allowed {
klog.InfoS("feature does not match the allowlist", "feature", name, "regexp", featureAllowList.String())
Copy link
Preview

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

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

Logging when a feature doesn't match the allowlist will generate excessive log entries for every filtered feature. Consider only logging at debug level or when verbose logging is enabled to avoid log spam.

Suggested change
klog.InfoS("feature does not match the allowlist", "feature", name, "regexp", featureAllowList.String())
klog.V(1).InfoS("feature does not match the allowlist", "feature", name, "regexp", featureAllowList.String())

Copilot uses AI. Check for mistakes.

Comment on lines +142 to +143
flagset.Var(overrides.FeatureDenyList, "feature-denylist",
"Regular expression to filter out feature names")
Copy link
Contributor

Choose a reason for hiding this comment

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

We need something more structured than plain regexp. I'd suggest to drop the command line flags and make this a config-file only option.

Klog klogutils.KlogConfigOpts
LabelWhiteList utils.RegexpVal
FeatureAllowList utils.RegexpVal
FeatureDenyList utils.RegexpVal
Copy link
Contributor

Choose a reason for hiding this comment

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

We need something more structured. One idea could be to follow something we have in NodeFeatureRules. We have stuff organized in hierarchy like <source>.<feature>.<element>. So following the NodeFeatureRule model we could have

featureDenyList:
  - feature: "kernel.config"

and then more refined configuration

featureDenyList:
  - feature: "pci.device"
    class: {op: In, value: ["0880"]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. 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.

Ability to white list feature attributes on the NodeFeature object
3 participants