Skip to content

Commit

Permalink
pkg/nfd-master/nfd-master.go: Fix duplicated import
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
  • Loading branch information
ArangoGutierrez committed Mar 28, 2023
1 parent 2c1f56d commit 4dcbd2d
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions pkg/nfd-master/nfd-master.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ import (
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/peer"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
label "k8s.io/apimachinery/pkg/labels"
k8sLabels "k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -525,7 +524,7 @@ func (m *nfdMaster) SetLabels(c context.Context, r *pb.SetLabelsRequest) (*pb.Se
annotations := Annotations{m.instanceAnnotation(nfdv1alpha1.WorkerVersionAnnotation): r.NfdVersion}

// Create labels et al
if err := m.refreshNodeFeatures(cli, r.NodeName, annotations, nil, r.GetLabels(), r.GetFeatures()); err != nil {
if err := m.refreshNodeFeatures(cli, r.NodeName, annotations, r.GetLabels(), r.GetFeatures()); err != nil {
return &pb.SetLabelsReply{}, err
}
}
Expand Down Expand Up @@ -555,7 +554,7 @@ func (m *nfdMaster) nfdAPIUpdateAllNodes() error {
}

func (m *nfdMaster) nfdAPIUpdateOneNode(nodeName string) error {
sel := labels.SelectorFromSet(labels.Set{nfdv1alpha1.NodeFeatureObjNodeNameLabel: nodeName})
sel := k8sLabels.SelectorFromSet(k8sLabels.Set{nfdv1alpha1.NodeFeatureObjNodeNameLabel: nodeName})
objs, err := m.nfdController.featureLister.List(sel)
if err != nil {
return fmt.Errorf("failed to get NodeFeature resources for node %q: %w", nodeName, err)
Expand Down Expand Up @@ -614,17 +613,14 @@ func (m *nfdMaster) nfdAPIUpdateOneNode(nodeName string) error {
if err != nil {
return err
}
if err := m.refreshNodeFeatures(cli, nodeName, annotations, nil, features.Labels, &features.Features); err != nil {
if err := m.refreshNodeFeatures(cli, nodeName, annotations, features.Labels, &features.Features); err != nil {
return err
}

return nil
}

func (m *nfdMaster) refreshNodeFeatures(cli *kubernetes.Clientset, nodeName string, annotations Annotations, extendedResources ExtendedResources, labels map[string]string, features *nfdv1alpha1.Features) error {
if extendedResources == nil {
extendedResources = make(map[string]string)
}
func (m *nfdMaster) refreshNodeFeatures(cli *kubernetes.Clientset, nodeName string, annotations Annotations, labels map[string]string, features *nfdv1alpha1.Features) error {

if labels == nil {
labels = make(map[string]string)
Expand All @@ -639,7 +635,7 @@ func (m *nfdMaster) refreshNodeFeatures(cli *kubernetes.Clientset, nodeName stri

// Remove labels which are intended to be extended resources or their NS
// is not whitelisted
labels, extendedResources = m.filterFeatureLabels(labels, crExtendedResources)
labels, extendedResources := m.filterFeatureLabels(labels, crExtendedResources)

var taints []corev1.Taint
if m.args.EnableTaints {
Expand Down Expand Up @@ -768,7 +764,7 @@ func (m *nfdMaster) processNodeFeatureRule(features *nfdv1alpha1.Features) ([]st
extendedResources := []string{}
labels := make(map[string]string)
var taints []corev1.Taint
ruleSpecs, err := m.nfdController.ruleLister.List(label.Everything())
ruleSpecs, err := m.nfdController.ruleLister.List(k8sLabels.Everything())
sort.Slice(ruleSpecs, func(i, j int) bool {
return ruleSpecs[i].Name < ruleSpecs[j].Name
})
Expand Down

0 comments on commit 4dcbd2d

Please sign in to comment.