Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: Filter rs that are not part of the current Deployement #191

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}
// 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) {
zhengjr9 marked this conversation as resolved.
Show resolved Hide resolved
ownedRSs = append(ownedRSs, rs)
}
}
return ownedRSs, nil
}

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