pod-files rule checks 1 pod per owner reference group#43
Merged
dimityrmirchev merged 4 commits intogardener:mainfrom Oct 9, 2023
Merged
pod-files rule checks 1 pod per owner reference group#43dimityrmirchev merged 4 commits intogardener:mainfrom
pod-files rule checks 1 pod per owner reference group#43dimityrmirchev merged 4 commits intogardener:mainfrom
Conversation
dimityrmirchev
requested changes
Oct 9, 2023
Member
dimityrmirchev
left a comment
There was a problem hiding this comment.
I left some initial minor comments
Comment on lines
+322
to
+323
| // GroupMinimalPodsByNodes groups pods by their nodes. Includes only one pod per reference group while trying | ||
| // to return a minimal number of groups. |
Member
There was a problem hiding this comment.
Suggested change
| // GroupMinimalPodsByNodes groups pods by their nodes. Includes only one pod per reference group while trying | |
| // to return a minimal number of groups. | |
| // SelectPodOfReferenceGroup returns a single pod per owner reference group | |
| // as well as groups the returned pods by the nodes they are scheduled on. | |
| // Pods that do not have an owner reference will always be selected. | |
| // It tries to pick the pods in a way that fewer nodes will be selected. |
Member
There was a problem hiding this comment.
We can also move this to internal/utils
| groupedPodsByNodes := map[string][]corev1.Pod{} | ||
| groupedPodsByReferences := map[string][]corev1.Pod{} | ||
| for _, pod := range pods { | ||
| podTarget := target.With("name", pod.Name, "namespace", pod.Namespace, "kind", "pod") |
Member
There was a problem hiding this comment.
This can be moved closer to its usage
| }) | ||
|
|
||
| for _, key := range keys { | ||
| pods := groupedPodsByReferences[key] |
Member
There was a problem hiding this comment.
Suggested change
| pods := groupedPodsByReferences[key] | |
| // we start from the smaller ref group because of fewer options to chose nodes from | |
| pods := groupedPodsByReferences[key] |
| return ok | ||
| }) | ||
|
|
||
| if podOnUsedNodeIdx < 0 { |
Member
There was a problem hiding this comment.
Suggested change
| if podOnUsedNodeIdx < 0 { | |
| // if none of the pods match already selected node | |
| // selected the node and add a single pod of the reference group for checking | |
| if podOnUsedNodeIdx < 0 { |
| continue | ||
| } | ||
|
|
||
| pod := pods[podOnUsedNodeIdx] |
Member
There was a problem hiding this comment.
Suggested change
| pod := pods[podOnUsedNodeIdx] | |
| // if there is a pod of the reference group which is scheduled on a selected node | |
| // then add this pod to the "to-be-checked" pods | |
| pod := pods[podOnUsedNodeIdx] |
pod-files rule checks 1 pod per reference grouppod-files rule checks 1 pod per owner reference group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Release note: