XVNC plugin is not freeing allocated Displays after failed builds

Article ID:115002507248
1 minute readKnowledge base

Issue

After a failed build the XVNC plugin does not free up the allocated Display numbers and now I am out of allocated numbers

Environment

  • CloudBees Jenkins Enterprise

  • XVNC plugin

Resolution

The issue is that if a build fails, the XVNC does not clean up allocated display port numbers and the agent still thinks that port is being used. The issue is documented in JENKINS-40496 and will have a workaround in JENKINS-40430. The best solution we have right now is to use one of these scripts to free up allocated display port numbers:

  1. Port range:

     agentName = "XXX"
     displayNumbers=(25..28)
     DESCRIPTOR = Jenkins.getActiveInstance().getDescriptorByType(hudson.plugins.xvnc.Xvnc$DescriptorImpl.class)
     allocator = DESCRIPTOR.allocators.get(agentName);
     displayNumbers.forEach{displayNumber->
       println "Before: ${allocator.allocatedNumbers}"
       allocator.free(displayNumber)
       println "After: ${allocator.allocatedNumbers}"
     }
  2. Comma seperated list:

     agentName = "XXX"
     displayNumbers=[25,26,27,28]
     DESCRIPTOR = Jenkins.getActiveInstance().getDescriptorByType(hudson.plugins.xvnc.Xvnc$DescriptorImpl.class)
     allocator = DESCRIPTOR.allocators.get(agentName);
     displayNumbers.forEach{displayNumber->
       println "Before: ${allocator.allocatedNumbers}"
       allocator.free(displayNumber)
       println "After: ${allocator.allocatedNumbers}"
     }

Put either one of those into your script console to have it free up the display numbers inside of the Brackets [].