Skip to content

Commit

Permalink
Merge pull request #1116 from jcmoraisjr/jm-node-discovery
Browse files Browse the repository at this point in the history
Fix label generation for node discovery
  • Loading branch information
jcmoraisjr authored May 4, 2024
2 parents c71f3a8 + 9963ba9 commit 10a90d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 10 additions & 2 deletions pkg/common/k8s/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,18 @@ func GetPodDetails(kubeClient clientset.Interface) (*PodInfo, error) {
return nil, fmt.Errorf("unable to get POD information")
}

podNodeIP := GetNodeIP(kubeClient, pod.Spec.NodeName, true)
podLabels := pod.GetLabels()

// remove labels that uniquely identify a pod
delete(podLabels, "controller-revision-hash")
delete(podLabels, "pod-template-generation")
delete(podLabels, "pod-template-hash")

return &PodInfo{
Name: podName,
Namespace: podNs,
NodeIP: GetNodeIP(kubeClient, pod.Spec.NodeName, true),
Labels: pod.GetLabels(),
NodeIP: podNodeIP,
Labels: podLabels,
}, nil
}
9 changes: 8 additions & 1 deletion pkg/controller/services/svcstatusing.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,17 @@ func (s *svcStatusIng) getControllerPodList(ctx context.Context) ([]api.Pod, err
if err := s.cli.Get(ctx, types.NamespacedName{Namespace: s.cfg.PodNamespace, Name: s.cfg.PodName}, &pod); err != nil {
return nil, err
}

// remove labels that uniquely identify a pod
podLabels := pod.GetLabels()
delete(podLabels, "controller-revision-hash")
delete(podLabels, "pod-template-generation")
delete(podLabels, "pod-template-hash")

// read all controller's pod
podList := api.PodList{}
if err := s.cli.List(ctx, &podList, &client.ListOptions{
LabelSelector: labels.SelectorFromSet(pod.GetLabels()),
LabelSelector: labels.SelectorFromSet(podLabels),
Namespace: s.cfg.PodNamespace,
}); err != nil {
return nil, err
Expand Down

0 comments on commit 10a90d2

Please sign in to comment.