-
Notifications
You must be signed in to change notification settings - Fork 40.9k
Commonize filtering of Pods by Owner with all orphans in namespace #132615
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
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mimowo The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/sig apps |
LGTM. |
/cc @wojtek-t |
/lgtm Thanks @mimowo |
LGTM label has been added. Git tree hash: 1c94a333d2b70694ed6187acec26169e0641cba1
|
result := []*v1.Pod{} | ||
// Iterate over two keys: | ||
// - the UID of the owner, which identifies Pods that are controlled by the owner | ||
// - the OrphanPodIndexKey, which identifies orphaned Pods in the owner's namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// - the OrphanPodIndexKey, which identifies orphaned Pods in the owner's namespace | |
// - the OrphanPodIndexKey, which identifies orphaned Pods in the owner's namespace and might be adopted by the owner later |
@@ -1112,6 +1113,29 @@ func AddPodControllerUIDIndexer(podInformer cache.SharedIndexInformer) error { | |||
}) | |||
} | |||
|
|||
// FilterPodsByOwner gets the Pods managed by an owner or orphan Pods in the owner's namespace | |||
func FilterPodsByOwner(podIndexer cache.Indexer, owner *metav1.ObjectMeta) ([]*v1.Pod, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we take this refactoring as an opportunity to introduce a simple unit test?
/triage accepted |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
DRY principle, as part of #130767
Which issue(s) this PR is related to:
Special notes for your reviewer:
The duplication was observed when solving subtle issues in previous PR
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: