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

Add white list #49

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

Add white list #49

wants to merge 2 commits into from

Conversation

ggordaniRed
Copy link
Collaborator

@ggordaniRed ggordaniRed commented Jan 2, 2025

append a new function and config struct for setting pci whitelist

Summary by CodeRabbit

  • New Features
    • Enhanced node feature discovery configuration management
    • Added support for configuring PCI device whitelists and label fields
    • Introduced new configuration structs for CPU, PCI, USB, and custom sources
    • Implemented methods for creating, updating, and converting configurations to YAML

@ggordaniRed ggordaniRed requested a review from wabouhamad January 2, 2025 10:47
@openshift-ci openshift-ci bot requested a review from fabiendupont January 2, 2025 10:47
Copy link

coderabbitai bot commented Jan 2, 2025

Walkthrough

The pull request introduces a new package nfd for node feature discovery configuration management. It adds a comprehensive configuration structure with support for CPU, PCI, USB, and custom sources. A new method UpdatePciDevices is added to the Builder struct in nodefeaturediscovery.go, enabling dynamic updates to PCI device configurations. The changes provide a flexible and structured approach to managing node feature discovery settings through YAML-based configuration handling.

Changes

File Change Summary
pkg/nfd/nodefeaturediscovery.go Added UpdatePciDevices method to Builder struct for updating PCI device configurations
pkg/nfd/nodefeaturediscoveryconfig.go Introduced new package with configuration structs: Config, CPUConfig, PCIDevice, Sources
Added methods NewConfig, SetPciWhitelistConfig, and GetYamlString for configuration management

Sequence Diagram

sequenceDiagram
    participant Builder
    participant Config
    participant YAML Processor

    Builder->>Config: UpdatePciDevices(whitelist, labelFields)
    Config->>Config: SetPciWhitelistConfig
    Config->>YAML Processor: GetYamlString()
    YAML Processor-->>Config: Return YAML configuration
    Config-->>Builder: Return updated configuration
Loading

The sequence diagram illustrates the workflow of updating PCI device configurations, showing how the UpdatePciDevices method interacts with the Config struct and YAML processing to modify and retrieve configuration data.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

openshift-ci bot commented Jan 2, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ggordaniRed

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

Copy link

openshift-ci bot commented Jan 2, 2025

@ggordaniRed: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/lint 46ee30c link true /test lint

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
pkg/nfd/nodefeaturediscoveryconfig.go (2)

45-45: Update the function comment to accurately describe PCI configuration.
The comment says "CPUConfigLabels set cpu blacklist/whitelist" but the function is for PCI device configuration. Updating the comment clarifies its purpose and avoids confusion.

-// CPUConfigLabels set cpu blacklist/whitelist.
+// SetPciWhitelistConfig updates the PCI device whitelist and label fields.

57-63: Helpful method for retrieving the updated config as YAML.
The GetYamlString() function simplifies returning the config in its YAML form. Just keep in mind that any concurrency usage might require additional safeguards if multiple goroutines perform writes and reads in parallel.

pkg/nfd/nodefeaturediscovery.go (1)

267-276: Remove ineffectual assignment to err.
At line 270, the assignment var err error = nil is flagged by static analysis as unnecessary. Simply declare the variable without initializing it to nil.

 func (builder *Builder) UpdatePciDevices(deviceClassWhitelist []string, deviceLabelFields []string) error {
 	cfg := NewConfig(builder.Definition.Spec.WorkerConfig.ConfigData)
 	cfg.SetPciWhitelistConfig(deviceClassWhitelist, deviceLabelFields)
-	var err error = nil
+	var err error
 	builder.Definition.Spec.WorkerConfig.ConfigData, err = cfg.GetYamlString()
 	if err != nil {
 		return err
 	}
 	return nil
 }
🧰 Tools
🪛 golangci-lint (1.62.2)

270-270: ineffectual assignment to err

(ineffassign)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2f04c5 and 46ee30c.

📒 Files selected for processing (2)
  • pkg/nfd/nodefeaturediscovery.go (1 hunks)
  • pkg/nfd/nodefeaturediscoveryconfig.go (1 hunks)
🧰 Additional context used
🪛 golangci-lint (1.62.2)
pkg/nfd/nodefeaturediscovery.go

270-270: ineffectual assignment to err

(ineffassign)

🔇 Additional comments (2)
pkg/nfd/nodefeaturediscoveryconfig.go (2)

36-43: Looks good!
The NewConfig function correctly unmarshals the YAML configuration and handles errors gracefully by logging them.


45-55: Good approach to clearing existing slices before appending new data.
Re-initializing the slice by slicing it to [:0] ensures that stale references are removed. This is a concise and safe pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant