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

sources/custom: convert static rules to new format #1336

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/custom/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (s *customSource) GetLabels() (source.FeatureLabels, error) {

func (r *CustomRule) execute(features *nfdv1alpha1.Features) (nfdv1alpha1.RuleOutput, error) {
if r.LegacyRule != nil {
klog.InfoS("legacy 'matchOn' rule format is deprecated, please convert to the new 'matchFeatures' rule format", "ruleName", r.LegacyRule.Name)
ruleOut, err := r.LegacyRule.execute()
if err != nil {
return nfdv1alpha1.RuleOutput{}, fmt.Errorf("failed to execute legacy rule %s: %w", r.LegacyRule.Name, err)
Expand Down
30 changes: 17 additions & 13 deletions source/custom/static_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ package custom

import (
nfdv1alpha1 "sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1"
"sigs.k8s.io/node-feature-discovery/source/custom/rules"
)

// getStaticFeatures returns statically configured custom features to discover
// e.g RMDA related features. NFD configuration file may extend these custom features by adding rules.
func getStaticFeatureConfig() []CustomRule {
return []CustomRule{
{
LegacyRule: &LegacyRule{
Name: "rdma.capable",
MatchOn: []LegacyMatcher{
{
PciID: &rules.PciIDRule{
MatchExpressionSet: nfdv1alpha1.MatchExpressionSet{
Rule: &Rule{
nfdv1alpha1.Rule{
Name: "RDMA capable static rule",
Labels: map[string]string{"rdma.capable": "true"},
MatchFeatures: nfdv1alpha1.FeatureMatcher{
nfdv1alpha1.FeatureMatcherTerm{
Feature: "pci.device",
MatchExpressions: nfdv1alpha1.MatchExpressionSet{
"vendor": nfdv1alpha1.MustCreateMatchExpression(nfdv1alpha1.MatchIn, "15b3"),
},
},
Expand All @@ -40,12 +41,14 @@ func getStaticFeatureConfig() []CustomRule {
},
},
{
LegacyRule: &LegacyRule{
Name: "rdma.available",
MatchOn: []LegacyMatcher{
{
LoadedKMod: &rules.LoadedKModRule{
MatchExpressionSet: nfdv1alpha1.MatchExpressionSet{
Rule: &Rule{
nfdv1alpha1.Rule{
Name: "RDMA available static rule",
Labels: map[string]string{"rdma.available": "true"},
MatchFeatures: nfdv1alpha1.FeatureMatcher{
nfdv1alpha1.FeatureMatcherTerm{
Feature: "kernel.loadedmodule",
MatchExpressions: nfdv1alpha1.MatchExpressionSet{
"ib_uverbs": nfdv1alpha1.MustCreateMatchExpression(nfdv1alpha1.MatchExists),
"rdma_ucm": nfdv1alpha1.MustCreateMatchExpression(nfdv1alpha1.MatchExists),
},
Expand All @@ -55,4 +58,5 @@ func getStaticFeatureConfig() []CustomRule {
},
},
}

}