From 6b0352a190a0bc8dba767a6099c56f16c6fba125 Mon Sep 17 00:00:00 2001 From: Kavin <62742678+Kavinraja-G@users.noreply.github.com> Date: Wed, 18 Dec 2024 23:27:26 +0530 Subject: [PATCH] Remove error logs for nodes without nodefeatures --- pkg/apis/nfd/nodefeaturerule/rule.go | 3 ++- pkg/apis/nfd/nodefeaturerule/rule_test.go | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/apis/nfd/nodefeaturerule/rule.go b/pkg/apis/nfd/nodefeaturerule/rule.go index b9a5629246..4c7f1b59ac 100644 --- a/pkg/apis/nfd/nodefeaturerule/rule.go +++ b/pkg/apis/nfd/nodefeaturerule/rule.go @@ -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 { diff --git a/pkg/apis/nfd/nodefeaturerule/rule_test.go b/pkg/apis/nfd/nodefeaturerule/rule_test.go index 036ad23e9d..28f8d902d0 100644 --- a/pkg/apis/nfd/nodefeaturerule/rule_test.go +++ b/pkg/apis/nfd/nodefeaturerule/rule_test.go @@ -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() @@ -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()