Logging Agent Information to consoleLog of Build

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Logging Agent Information to consoleLog of Build

Andreas Sieferlinger
Hey,

i'm currently working on extending the Amazon ECS plugin a little bit to add some information about the agent the job is run on the the builds log in the UI.
For example the assumption was that the following line would create such a log entry:

As i learned on gitter (thanks btw to the people helping there) that this is happening in a different context, and therefore is most likeley ending up in the agents log.

Do you see another way of providing information about the Agent within the build log (eg somehow listening for builds and then trying to resolve that information)?

Thx for your help :)

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/fbc6cdf5-6e3d-41c5-baa2-bf00548298b0%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Logging Agent Information to consoleLog of Build

Ulli Hafner
Am 13.01.2020 um 14:18 schrieb Andreas Sieferlinger <[hidden email]>:

Hey,

i'm currently working on extending the Amazon ECS plugin a little bit to add some information about the agent the job is run on the the builds log in the UI.
For example the assumption was that the following line would create such a log entry:


I never used the launcher extension point but from the code link it looks that the method launch is invoked on the master so the lister messages should end up in the log of the corresponding node. (<a href="http://localhost:8080/computer/[your-agent]/log" class="">http://localhost:8080/computer/[your-agent]/log)
Typically, a TaskListener reports the progress on the master... 
 
As i learned on gitter (thanks btw to the people helping there) that this is happening in a different context, and therefore is most likeley ending up in the agents log.

Do you see another way of providing information about the Agent within the build log (eg somehow listening for builds and then trying to resolve that information)?

Thx for your help :)

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/fbc6cdf5-6e3d-41c5-baa2-bf00548298b0%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/E43976B8-6093-4461-953A-51ECBEFCBE3A%40gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Logging Agent Information to consoleLog of Build

Andreas Sieferlinger
Yep, afaik they do. The problem in this context is that due to the agents being ephemeral they are deleted immediately after they stop, and with that also this log is gone.
So the idea was to add some basic output (eg the TaskID) in the actual build log for easier debugging for users.

So far I haven't found a way how I would put that information into the consoleLog per build for every node being spawned

Am Mo., 13. Jan. 2020 um 16:59 Uhr schrieb Ullrich Hafner <[hidden email]>:
Am 13.01.2020 um 14:18 schrieb Andreas Sieferlinger <[hidden email]>:

Hey,

i'm currently working on extending the Amazon ECS plugin a little bit to add some information about the agent the job is run on the the builds log in the UI.
For example the assumption was that the following line would create such a log entry:


I never used the launcher extension point but from the code link it looks that the method launch is invoked on the master so the lister messages should end up in the log of the corresponding node. (http://localhost:8080/computer/[your-agent]/log)
Typically, a TaskListener reports the progress on the master... 
 
As i learned on gitter (thanks btw to the people helping there) that this is happening in a different context, and therefore is most likeley ending up in the agents log.

Do you see another way of providing information about the Agent within the build log (eg somehow listening for builds and then trying to resolve that information)?

Thx for your help :)

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/fbc6cdf5-6e3d-41c5-baa2-bf00548298b0%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/peQPWLwdsT0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/E43976B8-6093-4461-953A-51ECBEFCBE3A%40gmail.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAFXs%2BxyWifkFA-MrHtqb6Vr-WsFv_d_raFUUn4gr-c18raA1Og%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Logging Agent Information to consoleLog of Build

Jesse Glick-4
On Tue, Jan 14, 2020 at 10:26 AM Andreas Sieferlinger
<[hidden email]> wrote:
> The problem in this context is that due to the agents being ephemeral they are deleted immediately after they stop, and with that also this log is gone.
> So the idea was to add some basic output (eg the TaskID) in the actual build log for easier debugging for users.

Reminds me of: https://github.com/jenkinsci/kubernetes-plugin/pull/497

In general, diagnostics for ephemeral agents are not great. If you use
for example the `dockerNode` step, then the Jenkins queue is bypassed
and the agent log is just streamed into the owning build log. I do not
think there is a simple way for `Computer` (etc.) implementation to
inject this into the log for a user of the general `node` step or
freestyle builds, though. The best I can come up with (Pipeline only)
is to implement

https://javadoc.jenkins.io/plugin/workflow-api/org/jenkinsci/plugins/workflow/flow/StepListener.html

then check whether it is `node` (`ExecutorStep`) being run, and if the
context says that the `Computer` is yours, ask the context for the
`TaskListener` and copy the `Computer.getLogText` so far. Ideally
there would be a real API for a computer to print some information
when a build starts using an executor on it; or some flag indicating
that it is ephemeral and single-use so that the code using the
executor (e.g., `ExecutorStepExecution`) could decide to stream the
agent log.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3z_5MXOdFzv9%2B9Vc2nRPw08LvqMRAwvnffJGSsn-HgUg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Logging Agent Information to consoleLog of Build

Andreas Sieferlinger
I hoped there would be an easier way, but i'll try if i can figure it out for the ECS plugin

Am Dienstag, 14. Januar 2020 18:11:27 UTC+1 schrieb Jesse Glick:
On Tue, Jan 14, 2020 at 10:26 AM Andreas Sieferlinger
<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="pX5jnqvACwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">psdsief...@...> wrote:
> The problem in this context is that due to the agents being ephemeral they are deleted immediately after they stop, and with that also this log is gone.
> So the idea was to add some basic output (eg the TaskID) in the actual build log for easier debugging for users.

Reminds me of: <a href="https://github.com/jenkinsci/kubernetes-plugin/pull/497" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin%2Fpull%2F497\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFo9UEBfHgoabRKlv2Rlb3Ob1f23Q&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Fkubernetes-plugin%2Fpull%2F497\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFo9UEBfHgoabRKlv2Rlb3Ob1f23Q&#39;;return true;">https://github.com/jenkinsci/kubernetes-plugin/pull/497

In general, diagnostics for ephemeral agents are not great. If you use
for example the `dockerNode` step, then the Jenkins queue is bypassed
and the agent log is just streamed into the owning build log. I do not
think there is a simple way for `Computer` (etc.) implementation to
inject this into the log for a user of the general `node` step or
freestyle builds, though. The best I can come up with (Pipeline only)
is to implement

<a href="https://javadoc.jenkins.io/plugin/workflow-api/org/jenkinsci/plugins/workflow/flow/StepListener.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjavadoc.jenkins.io%2Fplugin%2Fworkflow-api%2Forg%2Fjenkinsci%2Fplugins%2Fworkflow%2Fflow%2FStepListener.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFW0ZM2ZPPsk5HlU0vPM2PotiTTOQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fjavadoc.jenkins.io%2Fplugin%2Fworkflow-api%2Forg%2Fjenkinsci%2Fplugins%2Fworkflow%2Fflow%2FStepListener.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFW0ZM2ZPPsk5HlU0vPM2PotiTTOQ&#39;;return true;">https://javadoc.jenkins.io/plugin/workflow-api/org/jenkinsci/plugins/workflow/flow/StepListener.html

then check whether it is `node` (`ExecutorStep`) being run, and if the
context says that the `Computer` is yours, ask the context for the
`TaskListener` and copy the `Computer.getLogText` so far. Ideally
there would be a real API for a computer to print some information
when a build starts using an executor on it; or some flag indicating
that it is ephemeral and single-use so that the code using the
executor (e.g., `ExecutorStepExecution`) could decide to stream the
agent log.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/412c9d32-9b94-4ba7-8d12-14618655e201%40googlegroups.com.