mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-22 01:56:16 +00:00
Add some extra checking around a call to list pods.
This commit is contained in:
parent
ca6de16df7
commit
2d4e72f1fa
@ -347,7 +347,17 @@ func (r *Registry) WatchControllers(ctx api.Context, label, field labels.Selecto
|
|||||||
}
|
}
|
||||||
match := label.Matches(labels.Set(controller.Labels))
|
match := label.Matches(labels.Set(controller.Labels))
|
||||||
if match {
|
if match {
|
||||||
pods, _ := r.ListPods(ctx, labels.Set(controller.Spec.Selector).AsSelector())
|
pods, err := r.ListPods(ctx, labels.Set(controller.Spec.Selector).AsSelector())
|
||||||
|
if err != nil {
|
||||||
|
glog.Warningf("Error listing pods: %v", err)
|
||||||
|
// No object that's useable so drop it on the floor
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if pods == nil {
|
||||||
|
glog.Warningf("Pods list is nil. This should never happen...")
|
||||||
|
// No object that's useable so drop it on the floor
|
||||||
|
return false
|
||||||
|
}
|
||||||
controller.Status.Replicas = len(pods.Items)
|
controller.Status.Replicas = len(pods.Items)
|
||||||
}
|
}
|
||||||
return match
|
return match
|
||||||
|
Loading…
Reference in New Issue
Block a user