1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-06 08:47:04 +00:00

Merge pull request #1988 from Kavinraja-G/feat/skip-nodes

Remove errors for nodes without NodeFeatures
This commit is contained in:
Kubernetes Prow Robot 2024-12-20 09:58:08 +01:00 committed by GitHub
commit a0a8e3ebb0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View file

@ -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 {

View file

@ -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()
@ -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()