• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • audit-trail-plugin
    • None
    • Jenkins 2.401.1
      Audit Trail : 333.vb_e1b_b_0f1238c
      Azure VM Agents : 859.v7213476e4fea_

      When logging build start/end on azure vm agents, the node name is not displayed, we have #unknown# instead.

      Jul 13, 2023 11:23:28,889 AM - myjob #1 Push event to branch main, Parameters:[] on node #unknown# started at 2023-07-13T09:12:02Z completed in 685713ms completed: SUCCESS

          [JENKINS-71637] node names are not logged

          Cyril Pottiers created issue -

          Pierre Beitz added a comment -

          cpottiers I suppose the Azure VM Agent plugin doesn't use an `AbstractBuild` (https://github.com/jenkinsci/audit-trail-plugin/blob/b45ca03c816c870b085ff735312425ff1fff2c72/src/main/java/hudson/plugins/audit_trail/AuditTrailRunListener.java#L92-L100). It should be a matter of looking into the Azure-vm-agents plugin to understand what object they use, and enrich the method I linked (maybe an optional dependency over the Azure VM agent plugin will be needed).

          I don't have a setup to reproduce though and I'm not a big fan of blind fixing, are you willing to provide a fix?

          Pierre Beitz added a comment - cpottiers I suppose the Azure VM Agent plugin doesn't use an `AbstractBuild` ( https://github.com/jenkinsci/audit-trail-plugin/blob/b45ca03c816c870b085ff735312425ff1fff2c72/src/main/java/hudson/plugins/audit_trail/AuditTrailRunListener.java#L92-L100). It should be a matter of looking into the Azure-vm-agents plugin to understand what object they use, and enrich the method I linked (maybe an optional dependency over the Azure VM agent plugin will be needed). I don't have a setup to reproduce though and I'm not a big fan of blind fixing, are you willing to provide a fix?

          I can see the same #unknown# in the audit logs for our pipelines when they run on regular on-prem SSH nodes, which doesn't really surprise me much, since we have pipelines that specify agent none as well as those that are created dynamically on the fly, and also considering that pipelines are not shown in e.g. the Status and Build History views for nodes.

           

          For "old school" Freestyle jobs, the node name appears in the "build start" Audit log lines.

          Jesper Andersson added a comment - I can see the same #unknown# in the audit logs for our pipelines when they run on regular on-prem SSH nodes, which doesn't really surprise me much, since we have pipelines that specify agent none as well as those that are created dynamically on the fly, and also considering that pipelines are not shown in e.g. the Status and Build History views for nodes.   For "old school" Freestyle jobs, the node name appears in the "build start" Audit log lines.

          Cyril Pottiers added a comment - - edited

          pierrebtz how can I help you to fix this ?
          With your link, I don't think the matter is that I use Azure VM Agents but more the usage of organization Folder which produce WorkflowRun pipelines instead of AbstractRun

          Cyril Pottiers added a comment - - edited pierrebtz how can I help you to fix this ? With your link, I don't think the matter is that I use Azure VM Agents but more the usage of organization Folder which produce WorkflowRun pipelines instead of AbstractRun

          Pierre Beitz added a comment -

          cpottiers njesper indeed there is also another possible case where the node doesn't exist anymore in Jenkins at the time the plugin code is called.

          I created a PR that does two things:

          • In case the Run is not an AbtractBuild, log the information about the classname. This will help me figuring out a good solution in this case.
          • In case the agent doesn't exist anymore, I used a second method available in AbstractRun that should allow to retrieve the agent name.

          https://github.com/jenkinsci/audit-trail-plugin/pull/127

          Pierre Beitz added a comment - cpottiers njesper indeed there is also another possible case where the node doesn't exist anymore in Jenkins at the time the plugin code is called. I created a PR that does two things: In case the Run is not an AbtractBuild, log the information about the classname. This will help me figuring out a good solution in this case. In case the agent doesn't exist anymore, I used a second method available in AbstractRun that should allow to retrieve the agent name. https://github.com/jenkinsci/audit-trail-plugin/pull/127

          pierrebtz 
          It confirm my doubt :
          Nov 08, 2023 4:12:12 PM INFO hudson.plugins.audit_trail.AuditTrailRunListener buildNodeName
          Run is not an AbstractBuild but a org.jenkinsci.plugins.workflow.job.WorkflowRun, will log the build node as #unknown#.

          Cyril Pottiers added a comment - pierrebtz   It confirm my doubt : Nov 08, 2023 4:12:12 PM INFO hudson.plugins.audit_trail.AuditTrailRunListener buildNodeName Run is not an AbstractBuild but a org.jenkinsci.plugins.workflow.job.WorkflowRun, will log the build node as #unknown#.

          Pierre Beitz added a comment -

          cpottiers I see. I started a draft PR that tries to extract all the agents used in a workflow run. I ran some tests with no agents (agent none), an agent and several agents in parallel and got the expected results. Would you mind trying on your setup?

          This is WIP, I need to polish it a bit and add some tests but I'd like to check if it answers your needs.

          https://github.com/jenkinsci/audit-trail-plugin/pull/128

          Pierre Beitz added a comment - cpottiers I see. I started a draft PR that tries to extract all the agents used in a workflow run. I ran some tests with no agents (agent none), an agent and several agents in parallel and got the expected results. Would you mind trying on your setup? This is WIP, I need to polish it a bit and add some tests but I'd like to check if it answers your needs. https://github.com/jenkinsci/audit-trail-plugin/pull/128

          Cyril Pottiers added a comment - - edited

          pierrebtz 

          ...
          Nov 10, 2023 11:02:54,119 AM - job/myorg/job/test/job/master/ #3 Started by user POTTIERS Cyril, Parameters:[]
          Nov 10, 2023 11:05:06,363 AM - myorg » test » master #3 Started by user POTTIERS Cyril, Parameters:[] on node no agent started at 2023-11-10T10:02:53Z completed in 131903ms completed: SUCCESS
          ...
          ...
          [Pipeline] Start of Pipeline
          [Pipeline] node
          Still waiting to schedule task
          Waiting for next available executor
          Running on vm-forge-agentc2f100 in /home/jenkins/workspace/myorg_test_master
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Declarative: Checkout SCM)
          ...

           

          Cyril Pottiers added a comment - - edited pierrebtz   ... Nov 10, 2023 11:02:54,119 AM - job/myorg/job/test/job/master/ #3 Started by user POTTIERS Cyril, Parameters:[] Nov 10, 2023 11:05:06,363 AM - myorg » test » master #3 Started by user POTTIERS Cyril, Parameters:[] on node no agent started at 2023-11-10T10:02:53Z completed in 131903ms completed: SUCCESS ... ... [Pipeline] Start of Pipeline [Pipeline] node Still waiting to schedule task Waiting for next available executor Running on vm-forge-agentc2f100 in /home/jenkins/workspace/myorg_test_master [Pipeline] { [Pipeline] stage [Pipeline] { (Declarative: Checkout SCM) ...  

          Pierre Beitz added a comment -

          cpottiers could you please share the relevant part of the pipeline definition (I don't care for the steps you execute, but I'd like to see how you declare your agents/nodes). Are you using declarative or scripted pipelines?

          Pierre Beitz added a comment - cpottiers could you please share the relevant part of the pipeline definition (I don't care for the steps you execute, but I'd like to see how you declare your agents/nodes). Are you using declarative or scripted pipelines?

          Cyril Pottiers added a comment - - edited

          Sure :

          pipeline {
            agent {
              label 'azure-agent'
            }
            stages {
              ...
            }
          }
          

           

          Cyril Pottiers added a comment - - edited Sure : pipeline { agent { label 'azure-agent' } stages { ... } }  

            pierrebtz Pierre Beitz
            cpottiers Cyril Pottiers
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: