mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-31 04:04:51 +00:00
Merge pull request #999 from marquiz/fixes/nodefeature-missing
nfd-master: update node if no NodeFeature objects are present
This commit is contained in:
commit
28a5daa338
1 changed files with 23 additions and 20 deletions
|
@ -504,10 +504,7 @@ func (m *nfdMaster) nfdAPIUpdateAllNodes() error {
|
||||||
func (m *nfdMaster) nfdAPIUpdateOneNode(nodeName string) error {
|
func (m *nfdMaster) nfdAPIUpdateOneNode(nodeName string) error {
|
||||||
sel := labels.SelectorFromSet(labels.Set{nfdv1alpha1.NodeFeatureObjNodeNameLabel: nodeName})
|
sel := labels.SelectorFromSet(labels.Set{nfdv1alpha1.NodeFeatureObjNodeNameLabel: nodeName})
|
||||||
objs, err := m.nfdController.featureLister.List(sel)
|
objs, err := m.nfdController.featureLister.List(sel)
|
||||||
if len(objs) == 0 {
|
if err != nil {
|
||||||
klog.Infof("no NodeFeature object exists for node %q, skipping...", nodeName)
|
|
||||||
return nil
|
|
||||||
} else if err != nil {
|
|
||||||
return fmt.Errorf("failed to get NodeFeature resources for node %q: %w", nodeName, err)
|
return fmt.Errorf("failed to get NodeFeature resources for node %q: %w", nodeName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,26 +531,32 @@ func (m *nfdMaster) nfdAPIUpdateOneNode(nodeName string) error {
|
||||||
|
|
||||||
klog.V(1).Infof("processing node %q, initiated by NodeFeature API", nodeName)
|
klog.V(1).Infof("processing node %q, initiated by NodeFeature API", nodeName)
|
||||||
|
|
||||||
// Merge in features
|
features := &nfdv1alpha1.NodeFeatureSpec{}
|
||||||
//
|
|
||||||
// NOTE: changing the rule api to support handle multiple objects instead
|
|
||||||
// of merging would probably perform better with lot less data to copy.
|
|
||||||
features := objs[0].Spec.DeepCopy()
|
|
||||||
for _, o := range objs[1:] {
|
|
||||||
o.Spec.MergeInto(features)
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.KlogDump(4, "Composite NodeFeatureSpec after merge:", " ", features)
|
|
||||||
|
|
||||||
annotations := Annotations{}
|
annotations := Annotations{}
|
||||||
if objs[0].Namespace == m.namespace && objs[0].Name == nodeName {
|
|
||||||
// This is the one created by nfd-worker
|
if len(objs) > 0 {
|
||||||
if v := objs[0].Annotations[nfdv1alpha1.WorkerVersionAnnotation]; v != "" {
|
// Merge in features
|
||||||
annotations[nfdv1alpha1.WorkerVersionAnnotation] = v
|
//
|
||||||
|
// NOTE: changing the rule api to support handle multiple objects instead
|
||||||
|
// of merging would probably perform better with lot less data to copy.
|
||||||
|
features = objs[0].Spec.DeepCopy()
|
||||||
|
for _, o := range objs[1:] {
|
||||||
|
o.Spec.MergeInto(features)
|
||||||
|
}
|
||||||
|
|
||||||
|
utils.KlogDump(4, "Composite NodeFeatureSpec after merge:", " ", features)
|
||||||
|
|
||||||
|
if objs[0].Namespace == m.namespace && objs[0].Name == nodeName {
|
||||||
|
// This is the one created by nfd-worker
|
||||||
|
if v := objs[0].Annotations[nfdv1alpha1.WorkerVersionAnnotation]; v != "" {
|
||||||
|
annotations[nfdv1alpha1.WorkerVersionAnnotation] = v
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create labels et al
|
// Update node labels et al. This may also mean removing all NFD-owned
|
||||||
|
// labels (et al.), for example in the case no NodeFeature objects are
|
||||||
|
// present.
|
||||||
cli, err := m.apihelper.GetClient()
|
cli, err := m.apihelper.GetClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue