Deployment/util: Filter by ControllerRef.

The list functions in deployment/util are used outside the Deployment
controller itself. Therefore, they don't do actual adoption/orphaning.
However, they still need to avoid listing things that don't belong.
This commit is contained in:
Anthony Yeh
2017-02-26 15:26:33 -08:00
parent 92d75cbb23
commit 887acb07ea
4 changed files with 95 additions and 16 deletions

View File

@@ -3515,7 +3515,22 @@ func WaitForDeploymentWithCondition(c clientset.Interface, ns, deploymentName, r
func logPodsOfDeployment(c clientset.Interface, deployment *extensions.Deployment) {
minReadySeconds := deployment.Spec.MinReadySeconds
podList, err := deploymentutil.ListPods(deployment,
rsList, err := deploymentutil.ListReplicaSets(deployment,
func(namespace string, options metav1.ListOptions) ([]*extensions.ReplicaSet, error) {
rsList, err := c.Extensions().ReplicaSets(namespace).List(options)
if err != nil {
return nil, err
}
ret := make([]*extensions.ReplicaSet, 0, len(rsList.Items))
for i := range rsList.Items {
ret = append(ret, &rsList.Items[i])
}
return ret, nil
})
if err != nil {
Logf("Failed to list ReplicaSets of Deployment %s: %v", deployment.Name, err)
}
podList, err := deploymentutil.ListPods(deployment, rsList,
func(namespace string, options metav1.ListOptions) (*v1.PodList, error) {
return c.Core().Pods(namespace).List(options)
})