Skip to content

Commit a0a8e3e

Browse files
authored
Merge pull request #1988 from Kavinraja-G/feat/skip-nodes
Remove errors for nodes without NodeFeatures
2 parents 2fbd8a8 + 97345a4 commit a0a8e3e

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pkg/apis/nfd/nodefeaturerule/rule.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ func evaluateFeatureMatcher(m *nfdv1alpha1.FeatureMatcher, features *nfdv1alpha1
268268
fA, okA := features.Attributes[featureName]
269269
fI, okI := features.Instances[featureName]
270270
if !okF && !okA && !okI {
271-
return false, nil, fmt.Errorf("feature %q not available", featureName)
271+
klog.V(2).InfoS("feature not available", "featureName", featureName)
272+
return false, nil, nil
272273
}
273274

274275
if term.MatchExpressions != nil {

pkg/apis/nfd/nodefeaturerule/rule_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ func TestRule(t *testing.T) {
5353
assert.Nilf(t, err, "unexpected error: %v", err)
5454
assert.Equal(t, r1.Labels, m.Labels, "empty matcher should have matched empty features")
5555

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

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

67-
_, err = Execute(r2, f, true)
68-
assert.Error(t, err, "matching against a missing feature type should have returned an error")
69+
m, err = Execute(r2, f, true)
70+
assert.NoError(t, err, "matching against a missing feature should not have returned an error")
71+
assert.Empty(t, m.Labels)
72+
assert.Empty(t, m.Vars)
6973

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

0 commit comments

Comments
 (0)