@@ -12,7 +12,6 @@ import (
1212
1313 corev1 "k8s.io/api/core/v1"
1414 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15- "k8s.io/apimachinery/pkg/labels"
1615 "k8s.io/apimachinery/pkg/runtime"
1716 "k8s.io/apimachinery/pkg/types"
1817 "k8s.io/apimachinery/pkg/util/strategicpatch"
@@ -62,12 +61,11 @@ type Interface interface {
6261 PatchNode (old , new * corev1.Node ) error
6362 UpdateNodeStatus (node * corev1.Node ) error
6463 UpdatePodStatus (pod * corev1.Pod ) error
65- GetAnnotationsOnPod (namespace , name string ) (map [string ]string , error )
66- GetNodes () ([]* corev1.Node , error )
67- GetNamespaces (labelSelector metav1.LabelSelector ) ([]* corev1.Namespace , error )
68- GetPods (namespace string , opts metav1.ListOptions ) ([]* corev1.Pod , error )
69- GetPod (namespace , name string ) (* corev1.Pod , error )
70- GetNode (name string ) (* corev1.Node , error )
64+ // GetPodsForDBChecker should only be used by legacy DB checker. Use watchFactory instead to get pods.
65+ GetPodsForDBChecker (namespace string , opts metav1.ListOptions ) ([]* corev1.Pod , error )
66+ // GetNodeForWindows should only be used for windows hybrid overlay binary and never in linux code
67+ GetNodeForWindows (name string ) (* corev1.Node , error )
68+ GetNodesForWindows () ([]* corev1.Node , error )
7169 Events () kv1core.EventInterface
7270}
7371
@@ -201,7 +199,7 @@ func (k *Kube) SetAnnotationsOnService(namespace, name string, annotations map[s
201199
202200// SetTaintOnNode tries to add a new taint to the node. If the taint already exists, it doesn't do anything.
203201func (k * Kube ) SetTaintOnNode (nodeName string , taint * corev1.Taint ) error {
204- node , err := k .GetNode (nodeName )
202+ node , err := k .GetNodeForWindows (nodeName )
205203 if err != nil {
206204 klog .Errorf ("Unable to retrieve node %s for tainting %s: %v" , nodeName , taint .ToString (), err )
207205 return err
@@ -234,7 +232,7 @@ func (k *Kube) SetTaintOnNode(nodeName string, taint *corev1.Taint) error {
234232// RemoveTaintFromNode removes all the taints that have the same key and effect from the node.
235233// If the taint doesn't exist, it doesn't do anything.
236234func (k * Kube ) RemoveTaintFromNode (nodeName string , taint * corev1.Taint ) error {
237- node , err := k .GetNode (nodeName )
235+ node , err := k .GetNodeForWindows (nodeName )
238236 if err != nil {
239237 klog .Errorf ("Unable to retrieve node %s for tainting %s: %v" , nodeName , taint .ToString (), err )
240238 return err
@@ -324,32 +322,8 @@ func (k *Kube) UpdatePodStatus(pod *corev1.Pod) error {
324322 return err
325323}
326324
327- // GetAnnotationsOnPod obtains the pod annotations from kubernetes apiserver, given the name and namespace
328- func (k * Kube ) GetAnnotationsOnPod (namespace , name string ) (map [string ]string , error ) {
329- pod , err := k .KClient .CoreV1 ().Pods (namespace ).Get (context .TODO (), name , metav1.GetOptions {})
330- if err != nil {
331- return nil , err
332- }
333- return pod .ObjectMeta .Annotations , nil
334- }
335-
336- // GetNamespaces returns the list of all Namespace objects matching the labelSelector
337- func (k * Kube ) GetNamespaces (labelSelector metav1.LabelSelector ) ([]* corev1.Namespace , error ) {
338- list := []* corev1.Namespace {}
339- err := pager .New (func (ctx context.Context , opts metav1.ListOptions ) (runtime.Object , error ) {
340- return k .KClient .CoreV1 ().Namespaces ().List (ctx , opts )
341- }).EachListItem (context .TODO (), metav1.ListOptions {
342- LabelSelector : labels .Set (labelSelector .MatchLabels ).String (),
343- ResourceVersion : "0" ,
344- }, func (obj runtime.Object ) error {
345- list = append (list , obj .(* corev1.Namespace ))
346- return nil
347- })
348- return list , err
349- }
350-
351- // GetPods returns the list of all Pod objects in a namespace matching the options
352- func (k * Kube ) GetPods (namespace string , opts metav1.ListOptions ) ([]* corev1.Pod , error ) {
325+ // GetPodsForDBChecker returns the list of all Pod objects in a namespace matching the options. Only used by the legacy db checker.
326+ func (k * Kube ) GetPodsForDBChecker (namespace string , opts metav1.ListOptions ) ([]* corev1.Pod , error ) {
353327 list := []* corev1.Pod {}
354328 opts .ResourceVersion = "0"
355329 err := pager .New (func (ctx context.Context , opts metav1.ListOptions ) (runtime.Object , error ) {
@@ -361,13 +335,8 @@ func (k *Kube) GetPods(namespace string, opts metav1.ListOptions) ([]*corev1.Pod
361335 return list , err
362336}
363337
364- // GetPod obtains the pod from kubernetes apiserver, given the name and namespace
365- func (k * Kube ) GetPod (namespace , name string ) (* corev1.Pod , error ) {
366- return k .KClient .CoreV1 ().Pods (namespace ).Get (context .TODO (), name , metav1.GetOptions {})
367- }
368-
369- // GetNodes returns the list of all Node objects from kubernetes
370- func (k * Kube ) GetNodes () ([]* corev1.Node , error ) {
338+ // GetNodesForWindows returns the list of all Node objects from kubernetes. Only used by windows binary.
339+ func (k * Kube ) GetNodesForWindows () ([]* corev1.Node , error ) {
371340 list := []* corev1.Node {}
372341 err := pager .New (func (ctx context.Context , opts metav1.ListOptions ) (runtime.Object , error ) {
373342 return k .KClient .CoreV1 ().Nodes ().List (ctx , opts )
@@ -380,8 +349,8 @@ func (k *Kube) GetNodes() ([]*corev1.Node, error) {
380349 return list , err
381350}
382351
383- // GetNode returns the Node resource from kubernetes apiserver, given its name
384- func (k * Kube ) GetNode (name string ) (* corev1.Node , error ) {
352+ // GetNodeForWindows returns the Node resource from kubernetes apiserver, given its name. Only used by windows binary.
353+ func (k * Kube ) GetNodeForWindows (name string ) (* corev1.Node , error ) {
385354 return k .KClient .CoreV1 ().Nodes ().Get (context .TODO (), name , metav1.GetOptions {})
386355}
387356
0 commit comments