Skip to content

Commit 706f4c1

Browse files
committed
use KubernetesInterface to list pods instead of Lister in currentPod method
Signed-off-by: akihikokuroda <[email protected]>
1 parent 6f59a3b commit 706f4c1

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

pkg/controller/registry/reconciler/configmap.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -214,28 +214,36 @@ func (c *ConfigMapRegistryReconciler) currentRoleBinding(source configMapCatalog
214214

215215
func (c *ConfigMapRegistryReconciler) currentPods(source configMapCatalogSourceDecorator, image string) []*v1.Pod {
216216
podName := source.Pod(image).GetName()
217-
pods, err := c.Lister.CoreV1().PodLister().Pods(source.GetNamespace()).List(labels.SelectorFromSet(source.Selector()))
217+
pods, err := c.OpClient.KubernetesInterface().CoreV1().Pods(source.GetNamespace()).List(context.TODO(), metav1.ListOptions{LabelSelector: labels.SelectorFromSet(source.Selector()).String()})
218218
if err != nil {
219219
logrus.WithField("pod", podName).WithError(err).Debug("couldn't find pod in cache")
220220
return nil
221221
}
222-
if len(pods) > 1 {
222+
if len(pods.Items) > 1 {
223223
logrus.WithField("selector", source.Selector()).Debug("multiple pods found for selector")
224224
}
225-
return pods
225+
ret := make([]*v1.Pod, len(pods.Items))
226+
for i, pod :=range pods.Items {
227+
ret[i] = &pod
228+
}
229+
return ret
226230
}
227231

228232
func (c *ConfigMapRegistryReconciler) currentPodsWithCorrectResourceVersion(source configMapCatalogSourceDecorator, image string) []*v1.Pod {
229233
podName := source.Pod(image).GetName()
230-
pods, err := c.Lister.CoreV1().PodLister().Pods(source.GetNamespace()).List(labels.SelectorFromValidatedSet(source.Labels()))
234+
pods, err := c.OpClient.KubernetesInterface().CoreV1().Pods(source.GetNamespace()).List(context.TODO(), metav1.ListOptions{LabelSelector: labels.SelectorFromValidatedSet(source.Labels()).String()})
231235
if err != nil {
232236
logrus.WithField("pod", podName).WithError(err).Debug("couldn't find pod in cache")
233237
return nil
234238
}
235-
if len(pods) > 1 {
239+
if len(pods.Items) > 1 {
236240
logrus.WithField("selector", source.Labels()).Debug("multiple pods found for selector")
237241
}
238-
return pods
242+
ret := make([]*v1.Pod, len(pods.Items))
243+
for i, pod :=range pods.Items {
244+
ret[i] = &pod
245+
}
246+
return ret
239247
}
240248

241249
// EnsureRegistryServer ensures that all components of registry server are up to date.

0 commit comments

Comments
 (0)