Repository navigation
fix(cli): find the pods of a cronjob - #15806
Open
BahaaMattar wants to merge 1 commit into
Open
BahaaMattar wants to merge 1 commit into
BahaaMattar wants to merge 1 commit into
Conversation
Problem `k8s.GetPodsFor` resolves a `cronjob/<name>` argument by listing the jobs of the namespace and keeping the ones that the cronjob owns. The owner check passed the UID of the job itself, so it asked whether the job owns itself, which is never true. The cronjob was not even looked up by name. As a result the function always returned no pods for a cronjob. The CLI commands that resolve workloads with this function showed nothing for cronjobs: `linkerd diagnostics proxy-metrics cronjob/<name>` printed no output and exited successfully, and `linkerd authz cronjob` listed no authorizations. Solution Get the cronjob by name, like the other workload kinds, and keep the jobs whose owner references contain the UID of that cronjob, as the controller's own GetPodsFor already does. Looking the cronjob up also gives a not found error for a name that does not exist. Validation Added `TestGetPodsForCronJob` with two cronjobs and a standalone job, each with a pod. It fails without the change (no pods are returned) and passes with it. go test ./pkg/k8s/ Fixes linkerd#15805 Signed-off-by: Bahaa Mattar <bahaa.kmattar@gmail.com>
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.
Problem
k8s.GetPodsForresolves acronjob/<name>argument by listing thejobs of the namespace and keeping the ones that the cronjob owns. The
owner check passed the UID of the job itself, so it asked whether the
job owns itself, which is never true. The cronjob was not even looked
up by name. As a result the function always returned no pods for a
cronjob.
The CLI commands that resolve workloads with this function showed
nothing for cronjobs:
linkerd diagnostics proxy-metrics cronjob/<name>printed no output and exited successfully, and
linkerd authz cronjoblisted no authorizations.
Solution
Get the cronjob by name, like the other workload kinds, and keep the
jobs whose owner references contain the UID of that cronjob, as the
controller's own GetPodsFor already does. Looking the cronjob up also
gives a not found error for a name that does not exist.
Validation
Added
TestGetPodsForCronJobwith two cronjobs and a standalone job,each with a pod. It fails without the change (no pods are returned) and
passes with it.
go test ./pkg/k8s/
Fixes #15805