diff --git a/.github/workflows/e2e-deployment-1.19.yaml b/.github/workflows/e2e-deployment-1.19.yaml index 22e7f606..045885d7 100644 --- a/.github/workflows/e2e-deployment-1.19.yaml +++ b/.github/workflows/e2e-deployment-1.19.yaml @@ -10,7 +10,7 @@ on: env: # Common versions - GO_VERSION: '1.17' + GO_VERSION: '1.19' KIND_IMAGE: 'kindest/node:v1.19.16' KIND_CLUSTER_NAME: 'ci-testing' @@ -107,4 +107,4 @@ jobs: kubectl get pod -n kruise-rollout --no-headers| awk '{print $1}' | xargs kubectl logs -p -n kruise-rollout exit 1 fi - exit $retVal + exit $retVal \ No newline at end of file diff --git a/pkg/controller/deployment/deployment_controller.go b/pkg/controller/deployment/deployment_controller.go index 6150942e..7a6392b5 100644 --- a/pkg/controller/deployment/deployment_controller.go +++ b/pkg/controller/deployment/deployment_controller.go @@ -81,7 +81,22 @@ func (dc *DeploymentController) getReplicaSetsForDeployment(ctx context.Context, } // List all ReplicaSets to find those we own but that no longer match our // selector. They will be orphaned by ClaimReplicaSets(). - return dc.rsLister.ReplicaSets(d.Namespace).List(deploymentSelector) + allRSs, err := dc.rsLister.ReplicaSets(d.Namespace).List(deploymentSelector) + if err != nil { + return nil, fmt.Errorf("list %s/%s rs failed:%v", d.Namespace, d.Name, err) + } + // select rs owner by current deployment + ownedRSs := make([]*apps.ReplicaSet, 0) + for _, rs := range allRSs { + if !rs.DeletionTimestamp.IsZero() { + continue + } + + if metav1.IsControlledBy(rs, d) { + ownedRSs = append(ownedRSs, rs) + } + } + return ownedRSs, nil } // syncDeployment will sync the deployment with the given key.