-
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: debug scripts are not mounted to steps with no scripts #4776
fix: debug scripts are not mounted to steps with no scripts #4776
Conversation
Hi @yuzp1996. 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. |
/ok-to-test |
b97c1cd
to
41f2844
Compare
41f2844
to
adb43ec
Compare
/retest |
adb43ec
to
e7d18df
Compare
/retest |
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.
/cc @waveywaves
@vdemeester @bobcatfish @jerop @waveywaves I am sorry to bother you guys. If you have time to help review this PR I will be very appreciative! Thank you! If there is anything I need to do please tell me. Thank you again! |
Hey, thanks for the PR ! I'll take a look at it today. |
Again, thanks for the PR. I can see that debug is mounted if scripts are not present as well. I have tested this with the
|
// If breakpoint is not nil then should add the init container | ||
// to write debug script files |
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.
✨
pkg/pod/pod_test.go
Outdated
InitContainers: []corev1.Container{placeToolsInit, tektonDirInit(images.EntrypointImage, []v1beta1.Step{{Container: corev1.Container{Name: "name"}}})}, | ||
RestartPolicy: corev1.RestartPolicyNever, | ||
InitContainers: []corev1.Container{placeToolsInit, tektonDirInit(images.EntrypointImage, []v1beta1.Step{{Container: corev1.Container{Name: "name"}}}), | ||
{ |
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 you extract this Container as it's own variable called placeScriptsInit
as you have done for containerVolumeMounts
? It would look much cleaner.
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.
Good idea!
Hi, this is the task and taskrun I use to reproduce the error in a local deployment environment that is deployed with the latest commit from the master branch Task with script
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: hello
spec:
steps:
- name: hello
image: ubuntu
env:
- name: WORKSPACE_SOURCE_PATH
value: $(workspaces.source.path)
- name: WORKSPACE_ARTIFACTS_PATH
value: $(workspaces.artifacts.path)
script: |
#!/usr/bin/env bash
echodd "Hello from Bash!"
Task with args and command
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: hello
spec:
steps:
- name: hello
image: ubuntu
env:
- name: WORKSPACE_SOURCE_PATH
value: $(workspaces.source.path)
- name: WORKSPACE_ARTIFACTS_PATH
value: $(workspaces.artifacts.path)
command:
- echodd
args:
- "Hello from Bash!"
Above tasks can be referred to by the same taskrun
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: hello-run-arg-
spec:
debug:
breakpoint: [ "onFailure" ]
taskRef:
name: hello this is the result that I get. @waveywaves |
When the step script is empty then the logic which mounts the debug script will skip for the container and the signal of placeScripts will be the default value false which causes no debug script volume will be mounted. Now it will check the breakpoint first, if the breakpoint is not null then will add volume Mount for container no matter weather the script is empty or not. And if the breakpoint is not null then will set the signal placeScripts to be true while it used to be true only when the script is not empty. related issue: tektoncd#4613 Signed-off-by: yuzhipeng <yuzp1996@qq.com>
e7d18df
to
87a4d99
Compare
Because there were some conflict changes I spend some time fixing that. Now I have modified the code and the PR is ready to be merged. I will be very appreciative if you can review this PR. I am not good at English now If there is any offence please forgive me and tell me. Thanks again! @waveywaves |
/retest |
@@ -371,7 +371,7 @@ func makeLabels(s *v1beta1.TaskRun) map[string]string { | |||
return labels | |||
} | |||
|
|||
// shouldAddReadyAnnotationonPodCreate returns a bool indicating whether the | |||
// shouldAddReadyAnnotationOnPodCreate returns a bool indicating whether the |
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 find that the comment does not start with the function name, so I change it.
@@ -130,9 +130,18 @@ func convertScripts(shellImageLinux string, shellImageWin string, steps []v1beta | |||
func convertListOfSteps(steps []v1beta1.Step, initContainer *corev1.Container, placeScripts *bool, breakpoints []string, namePrefix string) []corev1.Container { | |||
containers := []corev1.Container{} | |||
for i, s := range steps { | |||
// Add debug mounts if breakpoints are present |
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 move the logic of adding debug script before judging the script make sure it can work well no matter s.Script is empty or not.
Hi @waveywaves, I am sorry to bother you again. I fixed the code conflict and add some comments to help understand the change I made. I would be very grateful if you could take the time to help me review this PR and give me your valuable suggestions. Thanks! |
Hey @yuzp1996 /lgtm |
Thanks for your lgtm! It is important to me! @waveywaves Is there anything else I need to do to merge this PR? Maybe an approval? @waveywaves @vdemeester Sorry, I don't know if I should be in such a hurry. If there is anything I did that made you feel not good please tell me and I will be happy to accept your suggestions. Thanks again! |
/assign |
[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 |
Changes
Update debug script mount logic
When the step script is empty then the logic which mounts the debug
script will skip for the container and the signal of placeScripts
will be the default value false which causes no debug script volume
will be mounted.
Now it will check the breakpoint first, if the breakpoint is not null
then will add volume Mount for container no matter the script
is empty or not.
And if the breakpoint is not null then will set the signal placeScripts
to be true while it used to be true only when the script is not empty.
related issue: #4613
/kind bug
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
(if there are no user facing changes, use release note "NONE")
Release Notes