-
Notifications
You must be signed in to change notification settings - Fork 277
feat: add ability to export feature labels for static node #2170
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
// boolOrStringValue is a custom flag type that can be a boolean or a non-empty string. | ||
// We need it to support nfd-worker --export, which can be set (true) or accept | ||
// an export value (--export=file.json). It satisfies the flag.Value interface. | ||
type boolOrStringValue struct { | ||
// Fistinguish "not set" (false) from "set as a boolean" (true). | ||
IsSet bool | ||
|
||
// Value holds the string provided. | ||
// If the flag is used as a boolean (e.g., -flag), this value will be "true". | ||
Value string | ||
} | ||
|
||
// String is the method to format the flag's value for printing. | ||
// It's part of the flag.Value interface. | ||
func (b *boolOrStringValue) String() string { | ||
if !b.IsSet { | ||
// Represents the "not set" state | ||
return "" | ||
} | ||
return b.Value | ||
} | ||
|
||
// Set parses the flag's value from the command line. | ||
func (b *boolOrStringValue) Set(s string) error { | ||
// When Set is called, we know the flag was present on the command line. | ||
b.IsSet = true | ||
b.Value = s | ||
return nil | ||
} | ||
|
||
// IsBoolFlag is an optional method that makes the flag behave like a boolean. | ||
func (b *boolOrStringValue) IsBoolFlag() bool { | ||
return true | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's better to keep the worker k8s centric (as it implements the logic for updating k8s resources), operate on raw features rather than labels, and add a new subcommand to the nfd client for dumping features.
Raw features can easily be transformed into labels if needed. However, since labels are derived from raw features and the worker configuration, relying solely on labels may cause certain node capabilities to be missed due to default or custom configurations.
The same principle applies to the image compatibility implementation in NFD, where comparisons are performed by checking the features (not the labels).
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree - I'll update the PR this week. Thanks @mfranczy!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I tend to agree as well. Mostly because much of the nfd-worker code is currently heavily based on the assumption that we're running in a kubernetes environment. Starting from the assumption that a kubeconfig must be found... Wiring the export functionality nicely into nfd-worker would require heavy refactoring, I believe, and it's much easier to put the stuff into the nfd client (I believe) as @mfranczy suggested. Especially if/when you're not interested in all the config options of nfd-worker.