-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: add PodAdmissionFailed reason to avoid confusing failed status #6295
fix: add PodAdmissionFailed reason to avoid confusing failed status #6295
Conversation
|
Hi @kinsolee. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/kind bug |
/ok-to-test |
Thanks for the PR, wondering if the messages would necessarily need to be the release notes since it is not indicating to be user-facing. |
The following is the coverage report on the affected files.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vdemeester The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
0d90cf5
to
1eec7c3
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
/release-note-none |
@kinsolee: you can only set the release note label to release-note-none if the release-note block in the PR body text is empty or "none". In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
1. add PodAdmissionFailed to indicates status failed from failing validating admission 2. use PodCreationFailed to indicates unknown reason of failed status Closes tektoncd#5693 Signed-off-by: Jingzhao Li <jzli@alauda.io>
1eec7c3
to
8175948
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
@bobcatfish @dibyom Can anyone give a lgtm so that I can merge this PR? |
@@ -813,6 +815,11 @@ func isTaskRunValidationFailed(err error) bool { | |||
return err != nil && strings.Contains(err.Error(), "TaskRun validation failed") | |||
} | |||
|
|||
func isPodAdmissionFailed(err error) bool { | |||
return err != nil && k8serrors.IsForbidden(err) && (strings.Contains(err.Error(), "violates PodSecurity") || | |||
strings.Contains(err.Error(), "security context constraint")) |
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.
Using strings.Contains
feels a little brittle since if the string content changes then it could break this logic. Is there a way to compare it better using errors.Is
?
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.
Actually, inside k8serrors.IsForbidden(err)
, errors.As
has been used to convert err to StatusError.
In this case, StatusError.StatusReason is Forbidden
, StatusError.Code is 403 and Status.Message shows the detail of error. The StatusError is from webhook as REST API server response which is the source of error.
Using strings.Contains
seems to be a common way to identify error. As you can see, other funcs in this file such as isExceededResourceQuotaError
, isTaskRunValidationFailed
are also using strings.Contains
.
LBNL, we can't find another field from StatusError to identify such similar error cases.
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.
I see.
/lgtm |
This commit removes the unused pod.ReasonCouldntGetTask. ReasonCouldntGetTask has been moved from reconciler to pod/status pkg via tektoncd#1627. The reference to it has been removed since tektoncd#6295. /kind cleanup
This commit removes the unused pod.ReasonCouldntGetTask. ReasonCouldntGetTask has been moved from reconciler to pod/status pkg via tektoncd#1627. The reference to it has been removed since tektoncd#6295. /kind cleanup
This commit removes the unused pod.ReasonCouldntGetTask. ReasonCouldntGetTask has been moved from reconciler to pod/status pkg via tektoncd#1627. The reference to it has been removed since tektoncd#6295. /kind cleanup
This commit removes the unused pod.ReasonCouldntGetTask. ReasonCouldntGetTask has been moved from reconciler to pod/status pkg via tektoncd#1627. The reference to it has been removed since tektoncd#6295. /kind cleanup
Closes #5693
Signed-off-by: Jingzhao Li jzli@alauda.io
Changes
Currently
CouldntGetTask
is used as default case of describing reason of failed status which confuses users when unknown error occurs but the reason has nothing to do with getting task.This PR fix this bug by replacing
CouldntGetTask
withPodCreationFailed
as default error reason.Reason
PodAdmissionFailed
is added to describing errors cause by validating pod addmission, including K8S PodSecurity and Openshift SCC.Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes