diff --git a/api/generated/clientset/versioned/clientset.go b/api/generated/clientset/versioned/clientset.go index 44f1292010..72ec0f5e1a 100644 --- a/api/generated/clientset/versioned/clientset.go +++ b/api/generated/clientset/versioned/clientset.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/fake/clientset_generated.go b/api/generated/clientset/versioned/fake/clientset_generated.go index 635125b6ac..aff6b01f40 100644 --- a/api/generated/clientset/versioned/fake/clientset_generated.go +++ b/api/generated/clientset/versioned/fake/clientset_generated.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/fake/doc.go b/api/generated/clientset/versioned/fake/doc.go index c8342d4bda..ac8c1ec9e2 100644 --- a/api/generated/clientset/versioned/fake/doc.go +++ b/api/generated/clientset/versioned/fake/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/fake/register.go b/api/generated/clientset/versioned/fake/register.go index 3c4d45a31f..4b8db01ff4 100644 --- a/api/generated/clientset/versioned/fake/register.go +++ b/api/generated/clientset/versioned/fake/register.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/scheme/doc.go b/api/generated/clientset/versioned/scheme/doc.go index 0fe2de9138..9e531af565 100644 --- a/api/generated/clientset/versioned/scheme/doc.go +++ b/api/generated/clientset/versioned/scheme/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/scheme/register.go b/api/generated/clientset/versioned/scheme/register.go index f822ef6087..fbdcdfca90 100644 --- a/api/generated/clientset/versioned/scheme/register.go +++ b/api/generated/clientset/versioned/scheme/register.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/doc.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/doc.go index ecc5462210..71824ed54e 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/doc.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/doc.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/doc.go index d9bd9db276..18420d4527 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/doc.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nfd_client.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nfd_client.go index e84e6e3e13..5ce0c4ad38 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nfd_client.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nfd_client.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeature.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeature.go index a7356c9c8c..efe9f63bcd 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeature.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeature.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeaturegroup.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeaturegroup.go index cc4ae10706..94e2ea8907 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeaturegroup.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeaturegroup.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeaturerule.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeaturerule.go index 6986116dc9..515a027334 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeaturerule.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/fake/fake_nodefeaturerule.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/generated_expansion.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/generated_expansion.go index 02d3e35186..2e25d3c7c9 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/generated_expansion.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/generated_expansion.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/nfd_client.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/nfd_client.go index 4776a6c83c..1529f40c6a 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/nfd_client.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/nfd_client.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeature.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeature.go index 70b8540467..9da5dbf7af 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeature.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeature.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -39,6 +39,8 @@ type NodeFeaturesGetter interface { type NodeFeatureInterface interface { Create(ctx context.Context, nodeFeature *nfdv1alpha1.NodeFeature, opts v1.CreateOptions) (*nfdv1alpha1.NodeFeature, error) Update(ctx context.Context, nodeFeature *nfdv1alpha1.NodeFeature, opts v1.UpdateOptions) (*nfdv1alpha1.NodeFeature, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, nodeFeature *nfdv1alpha1.NodeFeature, opts v1.UpdateOptions) (*nfdv1alpha1.NodeFeature, error) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error Get(ctx context.Context, name string, opts v1.GetOptions) (*nfdv1alpha1.NodeFeature, error) diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeaturegroup.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeaturegroup.go index cdee1eb7b9..ab226adf23 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeaturegroup.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeaturegroup.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeaturerule.go b/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeaturerule.go index cf0719ad17..e976325b24 100644 --- a/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeaturerule.go +++ b/api/generated/clientset/versioned/typed/nfd/v1alpha1/nodefeaturerule.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/informers/externalversions/factory.go b/api/generated/informers/externalversions/factory.go index 0bc947593c..0174d7fd49 100644 --- a/api/generated/informers/externalversions/factory.go +++ b/api/generated/informers/externalversions/factory.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/informers/externalversions/generic.go b/api/generated/informers/externalversions/generic.go index 1422eb95cf..45f55ec36c 100644 --- a/api/generated/informers/externalversions/generic.go +++ b/api/generated/informers/externalversions/generic.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/informers/externalversions/internalinterfaces/factory_interfaces.go b/api/generated/informers/externalversions/internalinterfaces/factory_interfaces.go index 7f11537412..6197665908 100644 --- a/api/generated/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/api/generated/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/informers/externalversions/nfd/interface.go b/api/generated/informers/externalversions/nfd/interface.go index 8c68358319..b83e407ce1 100644 --- a/api/generated/informers/externalversions/nfd/interface.go +++ b/api/generated/informers/externalversions/nfd/interface.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/informers/externalversions/nfd/v1alpha1/interface.go b/api/generated/informers/externalversions/nfd/v1alpha1/interface.go index ea861a472f..47163ad89b 100644 --- a/api/generated/informers/externalversions/nfd/v1alpha1/interface.go +++ b/api/generated/informers/externalversions/nfd/v1alpha1/interface.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/informers/externalversions/nfd/v1alpha1/nodefeature.go b/api/generated/informers/externalversions/nfd/v1alpha1/nodefeature.go index 34e14e4340..4341709a74 100644 --- a/api/generated/informers/externalversions/nfd/v1alpha1/nodefeature.go +++ b/api/generated/informers/externalversions/nfd/v1alpha1/nodefeature.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/informers/externalversions/nfd/v1alpha1/nodefeaturegroup.go b/api/generated/informers/externalversions/nfd/v1alpha1/nodefeaturegroup.go index 30559f5cee..3011236073 100644 --- a/api/generated/informers/externalversions/nfd/v1alpha1/nodefeaturegroup.go +++ b/api/generated/informers/externalversions/nfd/v1alpha1/nodefeaturegroup.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/informers/externalversions/nfd/v1alpha1/nodefeaturerule.go b/api/generated/informers/externalversions/nfd/v1alpha1/nodefeaturerule.go index 37ad15dce8..bc83a1480e 100644 --- a/api/generated/informers/externalversions/nfd/v1alpha1/nodefeaturerule.go +++ b/api/generated/informers/externalversions/nfd/v1alpha1/nodefeaturerule.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/listers/nfd/v1alpha1/expansion_generated.go b/api/generated/listers/nfd/v1alpha1/expansion_generated.go index 5890048ee1..943ba3d55e 100644 --- a/api/generated/listers/nfd/v1alpha1/expansion_generated.go +++ b/api/generated/listers/nfd/v1alpha1/expansion_generated.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/listers/nfd/v1alpha1/nodefeature.go b/api/generated/listers/nfd/v1alpha1/nodefeature.go index f670b6e8ae..348d294a21 100644 --- a/api/generated/listers/nfd/v1alpha1/nodefeature.go +++ b/api/generated/listers/nfd/v1alpha1/nodefeature.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/listers/nfd/v1alpha1/nodefeaturegroup.go b/api/generated/listers/nfd/v1alpha1/nodefeaturegroup.go index a59e53684d..1f38d88783 100644 --- a/api/generated/listers/nfd/v1alpha1/nodefeaturegroup.go +++ b/api/generated/listers/nfd/v1alpha1/nodefeaturegroup.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/generated/listers/nfd/v1alpha1/nodefeaturerule.go b/api/generated/listers/nfd/v1alpha1/nodefeaturerule.go index 77cdcf0cb3..4faea9b701 100644 --- a/api/generated/listers/nfd/v1alpha1/nodefeaturerule.go +++ b/api/generated/listers/nfd/v1alpha1/nodefeaturerule.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/api/nfd/v1alpha1/types.go b/api/nfd/v1alpha1/types.go index 67dfc1b06c..ab82e396ff 100644 --- a/api/nfd/v1alpha1/types.go +++ b/api/nfd/v1alpha1/types.go @@ -43,6 +43,7 @@ type NodeFeature struct { // Specification of the NodeFeature, containing features discovered for a node. Spec NodeFeatureSpec `json:"spec"` + Status NodeFeatureStatus `json:"status"` } // NodeFeatureSpec describes a NodeFeature object. @@ -55,6 +56,22 @@ type NodeFeatureSpec struct { Labels map[string]string `json:"labels"` } +// Status of a NodeFeature object. +type NodeFeatureStatus struct { + // UTC time when the NodeFeature object was last updated. + // +optional + LastAppliedAt metav1.Time `json:"lastAppliedAt,omitempty"` + // +optional + // Number of features discovered. + NumberOfFeatures int `json:"numberOfFeatures,omitempty"` + // +optional + // Number of errors during last feature discovery. + NumberOfFeatureErrors int `json:"numberOfFeatureErrors,omitempty"` + // +optional + // Number of labels created. + NumberOfLabels int `json:"numberOfLabels,omitempty"` +} + // Features is the collection of all discovered features. type Features struct { // Flags contains all the flag-type features of the node. diff --git a/api/nfd/v1alpha1/zz_generated.deepcopy.go b/api/nfd/v1alpha1/zz_generated.deepcopy.go index 491d9866c4..79cce590db 100644 --- a/api/nfd/v1alpha1/zz_generated.deepcopy.go +++ b/api/nfd/v1alpha1/zz_generated.deepcopy.go @@ -2,7 +2,7 @@ // +build !ignore_autogenerated /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -379,6 +379,7 @@ func (in *NodeFeature) DeepCopyInto(out *NodeFeature) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) return } @@ -645,6 +646,23 @@ func (in *NodeFeatureSpec) DeepCopy() *NodeFeatureSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeFeatureStatus) DeepCopyInto(out *NodeFeatureStatus) { + *out = *in + in.LastAppliedAt.DeepCopyInto(&out.LastAppliedAt) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeFeatureStatus. +func (in *NodeFeatureStatus) DeepCopy() *NodeFeatureStatus { + if in == nil { + return nil + } + out := new(NodeFeatureStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Rule) DeepCopyInto(out *Rule) { *out = *in diff --git a/deployment/base/nfd-crds/nfd-api-crds.yaml b/deployment/base/nfd-crds/nfd-api-crds.yaml index 9f62da6f6c..da698e91b3 100644 --- a/deployment/base/nfd-crds/nfd-api-crds.yaml +++ b/deployment/base/nfd-crds/nfd-api-crds.yaml @@ -115,8 +115,26 @@ spec: be created. type: object type: object + status: + description: Status of a NodeFeature object. + properties: + lastAppliedAt: + description: UTC time when the NodeFeature object was last updated. + format: date-time + type: string + numberOfFeatureErrors: + description: Number of errors during last feature discovery. + type: integer + numberOfFeatures: + description: Number of features discovered. + type: integer + numberOfLabels: + description: Number of labels created. + type: integer + type: object required: - spec + - status type: object served: true storage: true diff --git a/deployment/helm/node-feature-discovery/crds/nfd-api-crds.yaml b/deployment/helm/node-feature-discovery/crds/nfd-api-crds.yaml index 9f62da6f6c..da698e91b3 100644 --- a/deployment/helm/node-feature-discovery/crds/nfd-api-crds.yaml +++ b/deployment/helm/node-feature-discovery/crds/nfd-api-crds.yaml @@ -115,8 +115,26 @@ spec: be created. type: object type: object + status: + description: Status of a NodeFeature object. + properties: + lastAppliedAt: + description: UTC time when the NodeFeature object was last updated. + format: date-time + type: string + numberOfFeatureErrors: + description: Number of errors during last feature discovery. + type: integer + numberOfFeatures: + description: Number of features discovered. + type: integer + numberOfLabels: + description: Number of labels created. + type: integer + type: object required: - spec + - status type: object served: true storage: true diff --git a/pkg/nfd-worker/nfd-worker.go b/pkg/nfd-worker/nfd-worker.go index 21ececf152..c9980bf6d5 100644 --- a/pkg/nfd-worker/nfd-worker.go +++ b/pkg/nfd-worker/nfd-worker.go @@ -113,17 +113,18 @@ type ConfigOverrideArgs struct { } type nfdWorker struct { - args Args - configFilePath string - config *NFDConfig - kubernetesNamespace string - healthServer *grpc.Server - k8sClient k8sclient.Interface - nfdClient nfdclient.Interface - stop chan struct{} // channel for signaling stop - featureSources []source.FeatureSource - labelSources []source.LabelSource - ownerReference []metav1.OwnerReference + args Args + configFilePath string + config *NFDConfig + kubernetesNamespace string + healthServer *grpc.Server + k8sClient k8sclient.Interface + nfdClient nfdclient.Interface + stop chan struct{} // channel for signaling stop + featureSources []source.FeatureSource + numberOfFeatureSourceErrors int + labelSources []source.LabelSource + ownerReference []metav1.OwnerReference } // This ticker can represent infinite and normal intervals. @@ -242,9 +243,11 @@ func (w *nfdWorker) startGrpcHealthServer(errChan chan<- error) error { // Run feature discovery. func (w *nfdWorker) runFeatureDiscovery() error { discoveryStart := time.Now() + w.numberOfFeatureSourceErrors = 0 for _, s := range w.featureSources { currentSourceStart := time.Now() if err := s.Discover(); err != nil { + w.numberOfFeatureSourceErrors++ klog.ErrorS(err, "feature discovery failed", "source", s.Name()) } klog.V(3).InfoS("feature discovery completed", "featureSource", s.Name(), "duration", time.Since(currentSourceStart)) @@ -667,6 +670,13 @@ func (m *nfdWorker) updateNodeFeatureObject(labels Labels) error { } klog.InfoS("creating NodeFeature object", "nodefeature", klog.KObj(nfr)) + nfr.Status = nfdv1alpha1.NodeFeatureStatus{ + LastAppliedAt: metav1.Time{Time: time.Now().UTC()}, + NumberOfFeatures: len(m.featureSources), + NumberOfFeatureErrors: m.numberOfFeatureSourceErrors, + NumberOfLabels: len(m.labelSources), + } + nfrCreated, err := cli.NfdV1alpha1().NodeFeatures(namespace).Create(context.TODO(), nfr, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("failed to create NodeFeature object %q: %w", nfr.Name, err) @@ -684,7 +694,12 @@ func (m *nfdWorker) updateNodeFeatureObject(labels Labels) error { Features: *features, Labels: labels, } - + nfrUpdated.Status = nfdv1alpha1.NodeFeatureStatus{ + LastAppliedAt: metav1.Time{Time: time.Now().UTC()}, + NumberOfFeatures: len(m.featureSources), + NumberOfFeatureErrors: m.numberOfFeatureSourceErrors, + NumberOfLabels: len(m.labelSources), + } if !apiequality.Semantic.DeepEqual(nfr, nfrUpdated) { klog.InfoS("updating NodeFeature object", "nodefeature", klog.KObj(nfr)) nfrUpdated, err = cli.NfdV1alpha1().NodeFeatures(namespace).Update(context.TODO(), nfrUpdated, metav1.UpdateOptions{}) diff --git a/test/e2e/node_feature_discovery_test.go b/test/e2e/node_feature_discovery_test.go index 54c3b14581..a1f2485a24 100644 --- a/test/e2e/node_feature_discovery_test.go +++ b/test/e2e/node_feature_discovery_test.go @@ -479,6 +479,19 @@ var _ = NFDDescribe(Label("nfd-master"), func() { } eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchLabels(expectedLabels, nodes)) + By("Verifying the CRD status") + nf, err := nfdClient.NfdV1alpha1().NodeFeatures(f.Namespace.Name).Get(ctx, targetNodeName, metav1.GetOptions{}) + Expect(err).NotTo(HaveOccurred(), "Error getting NodeFeature object: %q", err) + + expectedStatus := nfdv1alpha1.NodeFeatureStatus{ + LastAppliedAt: nf.Status.LastAppliedAt, + NumberOfFeatures: nf.Status.NumberOfFeatures, + NumberOfFeatureErrors: 0, + NumberOfLabels: len(expectedLabels[targetNodeName]) - 1, + } + isEqual := (expectedStatus == nf.Status) + Expect(isEqual).To(BeTrue()) + By("Deleting nfd-worker daemonset") err = f.ClientSet.AppsV1().DaemonSets(f.Namespace.Name).Delete(ctx, workerDS.Name, metav1.DeleteOptions{}) Expect(err).NotTo(HaveOccurred())