-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Jenkins 47225: Fix ProcStarter #236
Conversation
Looks good at first glance. Could you please try to reproduce the problems that @scoheb had with this, ideally in a test? I think I reproduced it using |
Sure thing - I'll include it in this PR as well.
Thanks for all the help in getting this work into a good spot!
…On Mon, Oct 16, 2017 at 2:38 PM, Martin Sander ***@***.***> wrote:
Looks good at first glance.
Could you please try to reproduce the problems
<#218 (comment)>
that @scoheb <https://github.com/scoheb> had with this, ideally in a test?
I think I reproduced it using withEnv(["a.b=c"]). Checking with sh 'env'
on the jnlp slave, the "invalid" environment variable a.b was not
exported either. So I guess we can safely ignore those invalid environment
variables in the container as well.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#236 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAUwfdjiWAibCoQhbXIt7C61Hrjkzv5pks5ss7DDgaJpZM4P7DAC>
.
|
Looks like the error is getting swallowed up in the k8s client. Looks like the best approach will be to just detect "invalid" environment variables and skip trying to export them. I'm guessing implement something like this - https://stackoverflow.com/a/2821183 |
I would vote for fixing them rather than skipping them...that way at least users can see what has happened by doing an 'env'...or we log warnings if we skip them. How about this: https://paste.fedoraproject.org/paste/6vTS7Gv4RD9qBY~VkA8EMg |
Fixing it is fine by me, though the current behavior on a regular executor is to skip that environment variable. |
In that case, let's go with what the current behavior is! |
ffacd8d
to
3d05e03
Compare
3d05e03
to
f77c947
Compare
Fixed that broken build - Let me know if there's anything else this PR needs! |
).getBytes(StandardCharsets.UTF_8) | ||
); | ||
} | ||
//Check that key is bash compliant. |
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 personally would go "uncle bob style" and extract a method with a nice name instead of commenting:
if (isLegalShellVariableName(entry.getKey()) {
...
Comments are very prone to code rot.
There seems to be something wrong with this (which I unfortunately only recognized AFTER I merged this).
|
Odd. Is this with the existing test & key or another key? If it's another
key, can you send a gist of it to test out?
…On Oct 30, 2017 8:59 AM, "Martin Sander" ***@***.***> wrote:
@MattLud <https://github.com/mattlud>:
There seems to be something wrong with this (which I unfortunately only
recognized AFTER I merged this).
Seems like the exit code is not picked up correctly:
Executing shell script inside container [ssh-client] of pod [jenkins-slave-r7hwz-mlgt4]
Executing command: "ssh-agent"
printf "EXITCODE %3d" $?; exit
SSH_AUTH_SOCK=/tmp/ssh-s0bZApqhjHuY/agent.15; export SSH_AUTH_SOCK;
SSH_AGENT_PID=16; export SSH_AGENT_PID;
echo Agent pid 16;
EXITCODE 0SSH_AUTH_SOCK=/tmp/ssh-s0bZApqhjHuY/agent.15
SSH_AGENT_PID=16
Executing shell script inside container [ssh-client] of pod [jenkins-slave-r7hwz-mlgt4]
Executing command: "ssh-add" ***@***.***/private_key_5661184397489639826.key"
printf "EXITCODE %3d" $?; exit
EXITCODE 0EXITCODE 0Identity added: ***@***.***/private_key_5661184397489639826.key ***@***.***/private_key_5661184397489639826.key)
Identity added: ***@***.***/private_key_5661184397489639826.key ***@***.***/private_key_5661184397489639826.key)
[Pipeline] // sshagent
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
ERROR: Failed to run ssh-add
Finished: FAILURE
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#236 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAUwfWBjeUfpAxc2VUvr1rLE1C0EnCogks5sxdY7gaJpZM4P7DAC>
.
|
Also, what is the jnlp image/pod template being used? |
@MattLud: I used the pipeline and key from the test, but I was also able to reproduce using other keys. My current suspicion is that the output of "ssh-agent" and the "printf "EXITCODE %3d" $?" (which is introduced by the kubernetes plugin) are interleaved (I don't know why). I guess this will all change completely with #239 |
#242 might be related as well |
Yep - you're right that they are interleaved - We finally bumped into the issue related to this and it seems to be race condition sensitive - For failures, your log will show
|
After further testing, including #242, I still could not find a fix. Adding a |
|
||
//check if the cmd is sourced from Jenkins, rather than another plugin; if so, skip cmdEnvs as we are getting other environment variables | ||
for (String cmd : cmdEnvs) { | ||
if (cmd.startsWith(JENKINS_HOME)) { |
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.
why was this introduced? It is preventing environment variable injecting wrappers to inject env into sh steps.
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.
From #232 - "One issue that cropped up was that when executing sh commands, we would get the jnlp agent's injected environment variables as well, causing obvious problems such as JAVA_HOME being overwritten. The unsatisfying answer was to check for the presence of JENKINS_HOME in the cmdenvs and skip if 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.
might this help in this situation?
https://github.com/jenkinsci/kubernetes-plugin/pull/242/files#diff-8a1ab34452b01252e89ffeee0b2eda45R278
Guys, do you have any updates on the exicode issue above? I had to downgrade to the previous version of the plugin because of failed ssh-add. |
I'll update my PR to te latest master today.
…On Dec 13, 2017 11:36, "Aleksandr Tolstikov" ***@***.***> wrote:
Guys, do you have any updates on the exicode issue above? I had to
downgrade to the previous version of the plugin because of failed ssh-add.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#236 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACvMmN2AjVBfbI75FzOZxjWfYOF4AvYiks5s_6ixgaJpZM4P7DAC>
.
|
Addressed to allow fixes for #232