mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
sources/custom: convert static rules to new format
Also add a log message warning about legacy rule format.
This commit is contained in:
parent
51c79fea9e
commit
b1b3061738
2 changed files with 18 additions and 13 deletions
|
@ -134,6 +134,7 @@ func (s *customSource) GetLabels() (source.FeatureLabels, error) {
|
||||||
|
|
||||||
func (r *CustomRule) execute(features *nfdv1alpha1.Features) (nfdv1alpha1.RuleOutput, error) {
|
func (r *CustomRule) execute(features *nfdv1alpha1.Features) (nfdv1alpha1.RuleOutput, error) {
|
||||||
if r.LegacyRule != nil {
|
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()
|
ruleOut, err := r.LegacyRule.execute()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nfdv1alpha1.RuleOutput{}, fmt.Errorf("failed to execute legacy rule %s: %w", r.LegacyRule.Name, err)
|
return nfdv1alpha1.RuleOutput{}, fmt.Errorf("failed to execute legacy rule %s: %w", r.LegacyRule.Name, err)
|
||||||
|
|
|
@ -18,7 +18,6 @@ package custom
|
||||||
|
|
||||||
import (
|
import (
|
||||||
nfdv1alpha1 "sigs.k8s.io/node-feature-discovery/pkg/apis/nfd/v1alpha1"
|
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
|
// getStaticFeatures returns statically configured custom features to discover
|
||||||
|
@ -26,12 +25,14 @@ import (
|
||||||
func getStaticFeatureConfig() []CustomRule {
|
func getStaticFeatureConfig() []CustomRule {
|
||||||
return []CustomRule{
|
return []CustomRule{
|
||||||
{
|
{
|
||||||
LegacyRule: &LegacyRule{
|
Rule: &Rule{
|
||||||
Name: "rdma.capable",
|
nfdv1alpha1.Rule{
|
||||||
MatchOn: []LegacyMatcher{
|
Name: "RDMA capable static rule",
|
||||||
{
|
Labels: map[string]string{"rdma.capable": "true"},
|
||||||
PciID: &rules.PciIDRule{
|
MatchFeatures: nfdv1alpha1.FeatureMatcher{
|
||||||
MatchExpressionSet: nfdv1alpha1.MatchExpressionSet{
|
nfdv1alpha1.FeatureMatcherTerm{
|
||||||
|
Feature: "pci.device",
|
||||||
|
MatchExpressions: nfdv1alpha1.MatchExpressionSet{
|
||||||
"vendor": nfdv1alpha1.MustCreateMatchExpression(nfdv1alpha1.MatchIn, "15b3"),
|
"vendor": nfdv1alpha1.MustCreateMatchExpression(nfdv1alpha1.MatchIn, "15b3"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -40,12 +41,14 @@ func getStaticFeatureConfig() []CustomRule {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
LegacyRule: &LegacyRule{
|
Rule: &Rule{
|
||||||
Name: "rdma.available",
|
nfdv1alpha1.Rule{
|
||||||
MatchOn: []LegacyMatcher{
|
Name: "RDMA available static rule",
|
||||||
{
|
Labels: map[string]string{"rdma.available": "true"},
|
||||||
LoadedKMod: &rules.LoadedKModRule{
|
MatchFeatures: nfdv1alpha1.FeatureMatcher{
|
||||||
MatchExpressionSet: nfdv1alpha1.MatchExpressionSet{
|
nfdv1alpha1.FeatureMatcherTerm{
|
||||||
|
Feature: "kernel.loadedmodule",
|
||||||
|
MatchExpressions: nfdv1alpha1.MatchExpressionSet{
|
||||||
"ib_uverbs": nfdv1alpha1.MustCreateMatchExpression(nfdv1alpha1.MatchExists),
|
"ib_uverbs": nfdv1alpha1.MustCreateMatchExpression(nfdv1alpha1.MatchExists),
|
||||||
"rdma_ucm": nfdv1alpha1.MustCreateMatchExpression(nfdv1alpha1.MatchExists),
|
"rdma_ucm": nfdv1alpha1.MustCreateMatchExpression(nfdv1alpha1.MatchExists),
|
||||||
},
|
},
|
||||||
|
@ -55,4 +58,5 @@ func getStaticFeatureConfig() []CustomRule {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue