Skip to content

Commit b58d1bd

Browse files
committed
apis/nfd: Add Status to NodeFeature CRD
Signed-off-by: Oleg Zhurakivskyy <[email protected]>
1 parent a7c58b1 commit b58d1bd

File tree

7 files changed

+94
-1
lines changed

7 files changed

+94
-1
lines changed

api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeature.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeature.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/nfd/v1alpha1/types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type NodeFeature struct {
4141
metav1.ObjectMeta `json:"metadata,omitempty"`
4242

4343
Spec NodeFeatureSpec `json:"spec"`
44+
Status NodeFeatureStatus `json:"status"`
4445
}
4546

4647
// NodeFeatureSpec describes a NodeFeature object.
@@ -53,6 +54,18 @@ type NodeFeatureSpec struct {
5354
Labels map[string]string `json:"labels"`
5455
}
5556

57+
// Status of a NodeFeature object.
58+
type NodeFeatureStatus struct {
59+
// +optional
60+
UpdatedAt string `json:"updatedAt"`
61+
// +optional
62+
NumberOfFeatures int `json:"numberOfFeatures"`
63+
// +optional
64+
NumberOfFeatureErrors int `json:"numberOfFeatureErrors"`
65+
// +optional
66+
NumberOfLabels int `json:"numberOfLabels"`
67+
}
68+
5669
// Features is the collection of all discovered features.
5770
//
5871
// +protobuf=true

api/nfd/v1alpha1/zz_generated.deepcopy.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deployment/base/nfd-crds/nfd-api-crds.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,21 @@ spec:
109109
be created.
110110
type: object
111111
type: object
112+
status:
113+
description: Status of a NodeFeature object.
114+
properties:
115+
numberOfFeatureErrors:
116+
type: integer
117+
numberOfFeatures:
118+
type: integer
119+
numberOfLabels:
120+
type: integer
121+
updatedAt:
122+
type: string
123+
type: object
112124
required:
113125
- spec
126+
- status
114127
type: object
115128
served: true
116129
storage: true

deployment/helm/node-feature-discovery/crds/nfd-api-crds.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,21 @@ spec:
109109
be created.
110110
type: object
111111
type: object
112+
status:
113+
description: Status of a NodeFeature object.
114+
properties:
115+
numberOfFeatureErrors:
116+
type: integer
117+
numberOfFeatures:
118+
type: integer
119+
numberOfLabels:
120+
type: integer
121+
updatedAt:
122+
type: string
123+
type: object
112124
required:
113125
- spec
126+
- status
114127
type: object
115128
served: true
116129
storage: true

pkg/nfd-worker/nfd-worker.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ type nfdWorker struct {
132132
nfdClient *nfdclient.Clientset
133133
stop chan struct{} // channel for signaling stop
134134
featureSources []source.FeatureSource
135+
featureSourceErrors int
135136
labelSources []source.LabelSource
136137
}
137138

@@ -218,9 +219,11 @@ func (w *nfdWorker) startGrpcHealthServer(errChan chan<- error) error {
218219
// Run feature discovery.
219220
func (w *nfdWorker) runFeatureDiscovery() error {
220221
discoveryStart := time.Now()
222+
w.featureSourceErrors = 0
221223
for _, s := range w.featureSources {
222224
currentSourceStart := time.Now()
223225
if err := s.Discover(); err != nil {
226+
w.featureSourceErrors++
224227
klog.ErrorS(err, "feature discovery failed", "source", s.Name())
225228
}
226229
klog.V(3).InfoS("feature discovery completed", "featureSource", s.Name(), "duration", time.Since(currentSourceStart))
@@ -765,7 +768,12 @@ func (m *nfdWorker) updateNodeFeatureObject(labels Labels) error {
765768
Features: *features,
766769
Labels: labels,
767770
}
768-
771+
nfrUpdated.Status = nfdv1alpha1.NodeFeatureStatus{
772+
UpdatedAt: fmt.Sprintf("%q", time.Now()),
773+
NumberOfFeatures: len(m.featureSources),
774+
NumberOfFeatureErrors: m.featureSourceErrors,
775+
NumberOfLabels: len(m.labelSources),
776+
}
769777
if !apiequality.Semantic.DeepEqual(nfr, nfrUpdated) {
770778
klog.InfoS("updating NodeFeature object", "nodefeature", klog.KObj(nfr))
771779
nfrUpdated, err = cli.NfdV1alpha1().NodeFeatures(namespace).Update(context.TODO(), nfrUpdated, metav1.UpdateOptions{})

0 commit comments

Comments
 (0)