Skip to content

Commit

Permalink
Remove error logs for nodes without nodefeatures
Browse files Browse the repository at this point in the history
  • Loading branch information
Kavinraja-G committed Dec 18, 2024
1 parent 9ece76d commit 6b0352a
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 @@ -219,7 +219,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)
assert.Error(t, err, "matching against a missing feature should have returned an error")
m, err = Execute(r2, f)
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)
assert.Error(t, err, "matching against a missing feature type should have returned an error")
m, err = Execute(r2, f)
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 6b0352a

Please sign in to comment.