You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am triggering a local Salt state that sometimes requires 30-60 seconds to complete (it is pulling Docker images) and this seems to cause the plugin to wait forever for a response which it either never gets or acknowledges.
I have not set blockbuild: true so I am unsure what causes this. Here is the command I am using:
This does trigger the Salt state I want and Salt successfully completes it according to the event log. However, the saltstack plugin does not seem to see the completion and blocks the build continuously. I also tried adding blockbuild: false but this did not change behavior.
Interesting. The blockbuild toggle, should send off the command to the saltapi, and if the command completes quickly, show the results. If it does not return quickly, it usually results in the salt-api timing out the connection. It's odd that you see a persistent connection and no return.
You should try blockbuild option, as that should cause jenkins to check on the status of the salt action and continue on once it is complete.
I got the same after migration from 1.6.1 into 3.1.2 (Jenkins ver. 2.46.3)
I use salt for deployment action that takes ~2 mins and I need blocking build and get results of execution.
Most of all time (not 100%) salt plugin just wait response from salt master, I even can't cancel the build and jenkins usually crashed after ~10-15 mins 0_o
I checked http logs: plugin send request into master api and wait for response.
I checked this request myself: job finished, all fine.
So maybe will be better check salt api in loop instead of one long live request?..
btw minion timeout didn't changed anything
@Friz-zy can you post the json being sent to the server? If you have the blockbuild box checked, it should perform the poll for completion behavior that you describe.
I'll try to cache it
For some reasons http logger doesn't show anything (I deleted and created it back after last debug try) so I use tcpdump.
What I try:
Client Interface: local
Function: state.sls
Arguments: queue=True
Wait for completion: true
Poll Time: 10
Minion Timeout: 300
One success execution:
plugin sent requests each 10 seconds into api according to tcpdump - that's expected behavior.
but now because of this message
Running jid: 20170922134406426034
Waiting for 2 minions
0 minions are done
Will check status every 10 seconds...
Some minions returned. Waiting 300 seconds
Response on...
I think that 'Minion Timeout' limits execution only after getting first minion answer, otherwise plugin waiting for results forever...
not related, but local cmd.run with Wait for completion gave me
ERROR: Build step failed with exception
net.sf.json.JSONException: JSONObject["jid"] not found.
at net.sf.json.JSONObject.getString(JSONObject.java:2040)
at com.waytta.Builds.getBlockingBuildJid(Builds.java:155)
at com.waytta.SaltAPIBuilder.getJID(SaltAPIBuilder.java:317)
at com.waytta.SaltAPIBuilder.perform(SaltAPIBuilder.java:261)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1728)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:405)
Build step 'Send a message to Salt API' marked build as failure
Regarding the multiple minions, you are correct that the minion timeout parameter should cause jenkins to mark unresponsive minions and move on. See the help "?" button next to the option for more details. With that in place, are you see seeing the wait forever behavior?
The exception is certainly an issue. If you were to run that job from the salt command line, do you get responses back from both minions, or is one timing out? Did anything else occur before the exception, or do you simply run the jenkins job, and after a while the exception is thrown?
Logger worked before but then I tried multiple configurations with different version of salt and plugin and now it doesn't work and I don't have time to debug properly =\
For me expected behavior would be break job by time out even if no one minion was finished\responded...
Is there an ability to do it with current version of plugin?
I can run job multiple times, for example, first two builds was success and third one just can't finish and jenkins fell down. I'll try to debug jenkins, maybe I'll update it into latest version
Update: I updated jenkins and all necessary plugins into latest state.
I saw that jenkins got http answer from api but then - nothing.
Nothing in jenkins logs or "com.waytta.saltstack" logger: there is Sending JSON but no Received response.
I tried strace with -e poll,select,connect,recvfrom,sendto,open,access but didn't saw anything helpful unfortunately.
Is there a way to increase logging of internal logic?
Sounds like you are able to get logs from the saltstack plugin. The only way I've been able to get the http logs from jenkins was to set a default FINEST Jenkins logger, and view "All Logs".
In the case of using a timeout to break the job where no minions return, that is not directly supported by the plugin. There is the build timeout plugin you can use to wrap a build to support a timeout, or the equivelent timeout() command if you use pipelines.
The reasoning for this was to make the general use case easy. A salt job might finish in 30 seconds or 3 hours. So rather than require you to know up front how long a build can be expected to take, the salt plugin will continue to wait for the first minion to respond. At that point, the timeout ticker starts in order to give other minions a chance to return as well. For cases like yours where there is a risk no minions will return, then explicitly specifying a timeout via the existing jenkins timeout commands given above should help.
Does using the build timeout plugin and the block build option generally work for you, or are there other issues here? If you can send over the config for the build which caused the jid error, I can take a look at that as well.
Problem that plugin continue to be in "still waiting for response from salt" state even after getting actual response. I saw that in tcpdump and strace logs, there was no http requests after that but plugin doesn't finish the job. So build step can take hour while salt job itself finished after 1 minute.
So I don't need http logs, I want to debut salt plugin itself. Is there a way to do it without 'stracing' jenkins with all subprocesses?
Jid error config:
Client Interface: local
Function: cmd.run
Arguments: 'rm -rf /tmp/nginx'
Target: G@role:PROXY and G@environment:STAGE
Target Type: glob
Wait for completion: true
Without Wait for completion all works fine
All I am aware of for debugging is simply the logs. For this plugin it simply attempts to lookup the issued JID and return the results.
When the plugin has started a job that it is not getting the return from, could you post the output from salt-run jobs.lookup_jid <job id number> on the salt-master? If it reports that all minions have returned, then there is some bug preventing the Jeknins plugin from noticing.
Okay, there are some info:
I started job at 3:44 and it finished after 18 minutes
salt plugin logs:
Oct 13, 2017 3:44:56 PM FINE com.waytta.saltstack
Discovered netapi: CherryPy/5.1.0
Oct 13, 2017 3:44:56 PM FINE com.waytta.saltstack
Sending JSON: {"client":"local_async","tgt":"API*.**.DEVELOPMENT","expr_form":"glob","fun":"grains.setval","arg":["MCDOTCOM_BUILD",1714],"kwarg":{}}
Oct 13, 2017 3:44:57 PM FINE com.waytta.saltstack
Received response: [{"API01.EU1C.DEVELOPMENT":{"return":{"MCDOTCOM_BUILD":1714},"out":"nested"}}]
Oct 13, 2017 3:44:57 PM FINE com.waytta.saltstack
Discovered netapi: CherryPy/5.1.0
Oct 13, 2017 3:44:57 PM FINE com.waytta.saltstack
Sending JSON: {"client":"local","tgt":"API*.**.DEVELOPMENT","expr_form":"glob","fun":"state.sls","arg":"minicabit.node-minicabit","kwarg":{}}
Oct 13, 2017 4:03:18 PM FINE com.waytta.saltstack
Received response: [{"API01.EU1C.DEVELOPMENT":{<long respond from salt>
at the same time salt jobs actually was finished in ~2 minutes after start.
I checked salt master little later:
[EnvInject] - Loading node environment variables.
Building on master in workspace /data/jenkins/jobs/Node-minicabit.com-Deploy to Dev/workspace
Running jid: 20171013154456098726
Waiting for 1 minions
1 minions are done
Response on grains.setval MCDOTCOM_BUILD 1714 for API*.**.DEVELOPMENT:
[{"API01.EU1C.DEVELOPMENT": {
"return": {"MCDOTCOM_BUILD": 1714},
"out": "nested"
}}]
<loading circle>
I updated jenkins to latest 2.84 version before this test
I'll try to update pipeline plugins too as this is job in long pipeline to see if this would help
Hmm. Perhaps it is something related to the http connection having to get a large json response. While the jenkins plugin can handle the json just fine, perhaps there is a timeout somewhere getting the large content. It seems especially interesting, since your log shows the salt command being sent at 3:44, but while you said the salt command finished 2 minutes later, the jenkins plugin couldn't get the response until 4:03.
Just published the release. It should hit the mirrors within the next 24 hours. Please let me know if you see any improvement or if you still have jobs not being detected as completed.
No, still long execution
Strange, we have some number of pipelines with +- the same configs and deployment process and this problem affects only most oldest repo with 1.7k build cycles, other have < 1k builds and work as expected
I'll try manually clean history of builds just for test
I finally found solution:
I tried clear all old builds in jenkins but it didn't helped.
Then I replaced all file.directory module in all states into cmd script with chown and chmod - and deployment now takes 40 seconds instead of one hour lol
We have a directory with thousands of files ("this is nodejs, baby") and started from 2016 file.directory show changes for each file - tha's produce a huge output that looks like produce a problem.
Thank you for help with it debug :)
Activity
mchugh19 commentedon Aug 13, 2017
Interesting. The blockbuild toggle, should send off the command to the saltapi, and if the command completes quickly, show the results. If it does not return quickly, it usually results in the salt-api timing out the connection. It's odd that you see a persistent connection and no return.
You should try blockbuild option, as that should cause jenkins to check on the status of the salt action and continue on once it is complete.
Friz-zy commentedon Sep 22, 2017
I got the same after migration from 1.6.1 into 3.1.2 (Jenkins ver. 2.46.3)
I use salt for deployment action that takes ~2 mins and I need blocking build and get results of execution.
Most of all time (not 100%) salt plugin just wait response from salt master, I even can't cancel the build and jenkins usually crashed after ~10-15 mins 0_o
I checked http logs: plugin send request into master api and wait for response.
I checked this request myself: job finished, all fine.
So maybe will be better check salt api in loop instead of one long live request?..
btw minion timeout didn't changed anything
mchugh19 commentedon Sep 22, 2017
@Friz-zy can you post the json being sent to the server? If you have the blockbuild box checked, it should perform the poll for completion behavior that you describe.
Friz-zy commentedon Sep 22, 2017
I'll try to cache it
For some reasons http logger doesn't show anything (I deleted and created it back after last debug try) so I use tcpdump.
What I try:
Client Interface: local
Function: state.sls
Arguments: queue=True
Wait for completion: true
Poll Time: 10
Minion Timeout: 300
One success execution:
plugin sent requests each 10 seconds into api according to tcpdump - that's expected behavior.
but now because of this message
I think that 'Minion Timeout' limits execution only after getting first minion answer, otherwise plugin waiting for results forever...
not related, but
local cmd.runwithWait for completiongave memchugh19 commentedon Sep 22, 2017
Try looking at the "Logging Configuration" section of https://wiki.jenkins.io/display/JENKINS/saltstack-plugin. I seemed to have to set a default FINEST Jenkins logger on /jenkins/log/levels
Regarding the multiple minions, you are correct that the minion timeout parameter should cause jenkins to mark unresponsive minions and move on. See the help "?" button next to the option for more details. With that in place, are you see seeing the wait forever behavior?
The exception is certainly an issue. If you were to run that job from the salt command line, do you get responses back from both minions, or is one timing out? Did anything else occur before the exception, or do you simply run the jenkins job, and after a while the exception is thrown?
Friz-zy commentedon Sep 25, 2017
Logger worked before but then I tried multiple configurations with different version of salt and plugin and now it doesn't work and I don't have time to debug properly =\
For me expected behavior would be break job by time out even if no one minion was finished\responded...
Is there an ability to do it with current version of plugin?
I can run job multiple times, for example, first two builds was success and third one just can't finish and jenkins fell down. I'll try to debug jenkins, maybe I'll update it into latest version
Friz-zy commentedon Oct 4, 2017
Update: I updated jenkins and all necessary plugins into latest state.
I saw that jenkins got http answer from api but then - nothing.
Nothing in jenkins logs or "com.waytta.saltstack" logger: there is
Sending JSONbut noReceived response.I tried strace with
-e poll,select,connect,recvfrom,sendto,open,accessbut didn't saw anything helpful unfortunately.Is there a way to increase logging of internal logic?
mchugh19 commentedon Oct 4, 2017
Sounds like you are able to get logs from the saltstack plugin. The only way I've been able to get the http logs from jenkins was to set a default FINEST Jenkins logger, and view "All Logs".
In the case of using a timeout to break the job where no minions return, that is not directly supported by the plugin. There is the build timeout plugin you can use to wrap a build to support a timeout, or the equivelent
timeout()command if you use pipelines.The reasoning for this was to make the general use case easy. A salt job might finish in 30 seconds or 3 hours. So rather than require you to know up front how long a build can be expected to take, the salt plugin will continue to wait for the first minion to respond. At that point, the timeout ticker starts in order to give other minions a chance to return as well. For cases like yours where there is a risk no minions will return, then explicitly specifying a timeout via the existing jenkins timeout commands given above should help.
Does using the build timeout plugin and the block build option generally work for you, or are there other issues here? If you can send over the config for the build which caused the jid error, I can take a look at that as well.
Friz-zy commentedon Oct 5, 2017
Problem that plugin continue to be in "still waiting for response from salt" state even after getting actual response. I saw that in tcpdump and strace logs, there was no http requests after that but plugin doesn't finish the job. So build step can take hour while salt job itself finished after 1 minute.
So I don't need http logs, I want to debut salt plugin itself. Is there a way to do it without 'stracing' jenkins with all subprocesses?
Jid error config:
Client Interface: local
Function: cmd.run
Arguments: 'rm -rf /tmp/nginx'
Target: G@role:PROXY and G@environment:STAGE
Target Type: glob
Wait for completion: true
Without
Wait for completionall works finemchugh19 commentedon Oct 11, 2017
All I am aware of for debugging is simply the logs. For this plugin it simply attempts to lookup the issued JID and return the results.
When the plugin has started a job that it is not getting the return from, could you post the output from
salt-run jobs.lookup_jid <job id number>on the salt-master? If it reports that all minions have returned, then there is some bug preventing the Jeknins plugin from noticing.Friz-zy commentedon Oct 13, 2017
Okay, there are some info:
I started job at 3:44 and it finished after 18 minutes
salt plugin logs:
at the same time salt jobs actually was finished in ~2 minutes after start.
I checked salt master little later:
most of all time I saw this output in job logs:
I updated jenkins to latest 2.84 version before this test
I'll try to update pipeline plugins too as this is job in long pipeline to see if this would help
mchugh19 commentedon Oct 14, 2017
Hmm. Perhaps it is something related to the http connection having to get a large json response. While the jenkins plugin can handle the json just fine, perhaps there is a timeout somewhere getting the large content. It seems especially interesting, since your log shows the salt command being sent at 3:44, but while you said the salt command finished 2 minutes later, the jenkins plugin couldn't get the response until 4:03.
mchugh19 commentedon Oct 14, 2017
Can you try testing this release
In order to test the previous theory, I've upped the http timeout from 5 seconds to 30.
mchugh19 commentedon Oct 16, 2017
Just published the release. It should hit the mirrors within the next 24 hours. Please let me know if you see any improvement or if you still have jobs not being detected as completed.
Friz-zy commentedon Oct 16, 2017
Thank you, I updated plugin and restarted Jenkins.
Let's see how it would going :)
Friz-zy commentedon Oct 19, 2017
No, the same issue with new version.
I'm trying get http logs also but logger is empty even with addition finest logger for /jenkins/log/levels
mchugh19 commentedon Nov 9, 2017
Can you try this release? https://github.com/jenkinsci/saltstack-plugin/releases/tag/3.1.4-beta1
I was able to replicate the StackOverflowError and this fixes the problem for me.
Friz-zy commentedon Nov 10, 2017
Okay, I installed hpi file manually, we'll see is it helped or not soon
Friz-zy commentedon Nov 10, 2017
No, still long execution
Strange, we have some number of pipelines with +- the same configs and deployment process and this problem affects only most oldest repo with 1.7k build cycles, other have < 1k builds and work as expected
I'll try manually clean history of builds just for test
Friz-zy commentedon Nov 15, 2017
I finally found solution:
I tried clear all old builds in jenkins but it didn't helped.
Then I replaced all file.directory module in all states into cmd script with chown and chmod - and deployment now takes 40 seconds instead of one hour lol
We have a directory with thousands of files ("this is nodejs, baby") and started from 2016 file.directory show changes for each file - tha's produce a huge output that looks like produce a problem.
Thank you for help with it debug :)