Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "nfd-master: use only unbuffered chans in the nfd api-controller" #2097

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/nfd-master/nfd-api-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ func init() {
func newNfdController(config *restclient.Config, nfdApiControllerOptions nfdApiControllerOptions) (*nfdController, error) {
c := &nfdController{
stopChan: make(chan struct{}),
updateAllNodesChan: make(chan struct{}),
updateAllNodesChan: make(chan struct{}, 1),
updateOneNodeChan: make(chan string),
updateAllNodeFeatureGroupsChan: make(chan struct{}),
updateAllNodeFeatureGroupsChan: make(chan struct{}, 1),
updateNodeFeatureGroupChan: make(chan string),
}

Expand Down
1 change: 1 addition & 0 deletions test/e2e/data/nodefeature-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ spec:
fake.instance:
elements:
- attributes:
name: "instance-x"
attr_1: "true"
attr_2: "9"
# Labels to be created
Expand Down
54 changes: 54 additions & 0 deletions test/e2e/data/nodefeaturegroup-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: nfd.k8s-sigs.io/v1alpha1
kind: NodeFeatureGroup
metadata:
name: e2e-test-2
spec:
featureGroupRules:
- name: "e2e-matchany-test-1"
vars:
e2e-matchany-test-1: "true"
matchAny:
- matchFeatures:
- feature: "fake.instance"
matchExpressions:
"attr_1": {op: In, value: ["nomatch"]}
- matchFeatures:
- feature: "fake.instance"
matchExpressions:
"attr_3": {op: In, value: ["100"]}

#
# Test templating
#
- name: "e2e-template-test-1"
varsTemplate: |
{{ range .fake.instance }}e2e-template-test-1-{{ .name }}=found
{{ end }}
matchFeatures:
- feature: "fake.instance"
matchExpressions:
"attr_1": {op: In, value: ["true"]}

- name: "e2e-template-test-2"
varsTemplate: |
{{ range .fake.attribute }}e2e-template-test-2-{{ .Name }}={{ .Value }}
{{ end }}
matchFeatures:
- feature: "fake.attribute"
matchExpressions:
# expect attr_2 overridden from nodefeature-1.yaml
"attr_2": {op: IsTrue}
matchName: {op: In, value: ["attr_3"]}

#
# Test backreference
#
- name: "e2e-backreference-test-1"
matchFeatures:
- feature: "rule.matched"
matchExpressions:
"e2e-matchany-test-1:": {op: IsTrue}
"e2e-template-test-1-instance_1": {op: In, value: ["found"]}
"e2e-template-test-1-instance_2": {op: Exists}
"e2e-template-test-2-attr_2": {op: IsTrue}
"e2e-template-test-2-attr_3": {op: In, value: ["10"]}
30 changes: 30 additions & 0 deletions test/e2e/node_feature_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,36 @@ core:
}
return reflect.DeepEqual(group.Status, expectedGroup.Status)
}, 5*time.Minute, 5*time.Second).Should(BeTrue())

// Deploy node feature object to have one different node
targetNodeName := nodes[0].Name
By("Creating NodeFeature object")
nodeFeatures, err := testutils.CreateOrUpdateNodeFeaturesFromFile(ctx, nfdClient, "nodefeature-1.yaml", f.Namespace.Name, targetNodeName)
Expect(err).NotTo(HaveOccurred())

By("Creating NodeFeatureGroups #2")
Expect(testutils.CreateNodeFeatureGroupsFromFile(ctx, nfdClient, f.Namespace.Name, "nodefeaturegroup-2.yaml")).NotTo(HaveOccurred())

By("Verifying NodeFeatureGroups #2")
Eventually(func() bool {
group, err := nfdClient.NfdV1alpha1().NodeFeatureGroups(f.Namespace.Name).Get(ctx, "e2e-test-2", metav1.GetOptions{})
if err != nil {
return false
}
return len(group.Status.Nodes) == 1 && group.Status.Nodes[0].Name == targetNodeName
}, 1*time.Minute, 5*time.Second).Should(BeTrue())

By("Deleting NodeFeature object")
err = nfdClient.NfdV1alpha1().NodeFeatures(f.Namespace.Name).Delete(ctx, nodeFeatures[0], metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())

Eventually(func() bool {
group, err := nfdClient.NfdV1alpha1().NodeFeatureGroups(f.Namespace.Name).Get(ctx, "e2e-test-2", metav1.GetOptions{})
if err != nil {
return false
}
return len(group.Status.Nodes) == 0
}, 1*time.Minute, 5*time.Second).Should(BeTrue())
})
})

Expand Down