Skip to content

Commit

Permalink
bugfix: Filter rs that are not part of the current Deployement
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengjr9 committed Dec 26, 2023
1 parent 8620408 commit 48c4c8f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/controller/deployment/deployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 86 in pkg/controller/deployment/deployment_controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/controller/deployment/deployment_controller.go#L86

Added line #L86 was not covered by tests
}
// select rs owner by current deployment
ownedRSs := make([]*apps.ReplicaSet, 0)
for _, rs := range allRSs {
if !rs.DeletionTimestamp.IsZero() {
continue

Check warning on line 92 in pkg/controller/deployment/deployment_controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/controller/deployment/deployment_controller.go#L92

Added line #L92 was not covered by tests
}

if metav1.IsControlledBy(rs, d) {
ownedRSs = append(ownedRSs, rs)
}
}
return ownedRSs, nil
}

// syncDeployment will sync the deployment with the given key.
Expand Down

0 comments on commit 48c4c8f

Please sign in to comment.