Skip to content

Commit

Permalink
Merge pull request #1988 from Kavinraja-G/feat/skip-nodes
Browse files Browse the repository at this point in the history
Remove errors for nodes without NodeFeatures
  • Loading branch information
k8s-ci-robot authored Dec 20, 2024
2 parents 2fbd8a8 + 97345a4 commit a0a8e3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pkg/apis/nfd/nodefeaturerule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ func evaluateFeatureMatcher(m *nfdv1alpha1.FeatureMatcher, features *nfdv1alpha1
fA, okA := features.Attributes[featureName]
fI, okI := features.Instances[featureName]
if !okF && !okA && !okI {
return false, nil, fmt.Errorf("feature %q not available", featureName)
klog.V(2).InfoS("feature not available", "featureName", featureName)
return false, nil, nil
}

if term.MatchExpressions != nil {
Expand Down
12 changes: 8 additions & 4 deletions pkg/apis/nfd/nodefeaturerule/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ func TestRule(t *testing.T) {
assert.Nilf(t, err, "unexpected error: %v", err)
assert.Equal(t, r1.Labels, m.Labels, "empty matcher should have matched empty features")

_, err = Execute(r2, f, true)
assert.Error(t, err, "matching against a missing feature should have returned an error")
m, err = Execute(r2, f, true)
assert.NoError(t, err, "matching against a missing feature should not have returned an error")
assert.Empty(t, m.Labels)
assert.Empty(t, m.Vars)

// Test properly initialized empty features
f = nfdv1alpha1.NewFeatures()
Expand All @@ -64,8 +66,10 @@ func TestRule(t *testing.T) {
assert.Equal(t, r1.Labels, m.Labels, "empty matcher should have matched empty features")
assert.Empty(t, r1.Vars, "vars should be empty")

_, err = Execute(r2, f, true)
assert.Error(t, err, "matching against a missing feature type should have returned an error")
m, err = Execute(r2, f, true)
assert.NoError(t, err, "matching against a missing feature should not have returned an error")
assert.Empty(t, m.Labels)
assert.Empty(t, m.Vars)

// Test empty feature sets
f.Flags["domain-1.kf-1"] = nfdv1alpha1.NewFlagFeatures()
Expand Down

0 comments on commit a0a8e3e

Please sign in to comment.