Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-67237

Downstream jobs are not guaranteed to build when the job configs have been updated recently

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • core
    • None
    • Jenkins: 2.322
    • 2.346

    Description

      We have a freestyle job (named config_job) that configures other freestyle jobs on the same jenkins via REST. In some of these freestyle jobs the config_job is added as a reverse build trigger and thus some jobs become downstream jobs of the config_job. We noticed that sometimes these newly added downstream jobs are not built.

      After looking at the jenkins source code, we noticed the following TODO in BuildTrigger.executes:

      // TODO this may not yet be up to date if rebuildDependencyGraphAsync has been used; need a method to wait for the last call made before now to finish
      final DependencyGraph graph = Jenkins.get().getDependencyGraph();
      

      Since the dependency graph is still rebuilding when our config_job finishes, an old version of the dependency graph is used which does not include the reverse triggers we just added and thus some downstream jobs are not built.

      Attachments

        Issue Links

          Activity

            simon_sohrt Simon Sohrt added a comment -

            Yeah, I will start looking into it tomorrow. 

            simon_sohrt Simon Sohrt added a comment - Yeah, I will start looking into it tomorrow. 
            basil Basil Crow added a comment -

            simon_sohrt Can you please investigate the alleged regression?

            basil Basil Crow added a comment - simon_sohrt Can you please investigate the alleged regression?
            spammy Anyi Zhu added a comment -

            My earlier comment were accidentally deleted - This issue needs to be reopened because the fix for this introduced another bug - if the downstream child job is build on a slave node and the parent job is set to build on a master node, the child job would not run at all and the master node has no record of the job even being triggered.

            spammy Anyi Zhu added a comment - My earlier comment were accidentally deleted - This issue needs to be reopened because the fix for this introduced another bug - if the downstream child job is build on a slave node and the parent job is set to build on a master node, the child job would not run at all and the master node has no record of the job even being triggered.
            simon_sohrt Simon Sohrt added a comment -

            We propose the following fix:

            BuildTrigger.executes waits until the dependency graph has settled. To detect if the dependency graph has settled, we add a getter for dependencyGraphDirty in Jenkins.java.

            We then modify rebuildDependencyGraphAsync() in Jenkins.java in such a way that only one job can be scheduled for rebuilding the dependency graph. If this method is called while the dependency graph is still rebuilding, the current run is canceled and a new run is started.

            simon_sohrt Simon Sohrt added a comment - We propose the following fix: BuildTrigger.executes waits until the dependency graph has settled. To detect if the dependency graph has settled, we add a getter for dependencyGraphDirty in Jenkins.java. We then modify rebuildDependencyGraphAsync() in Jenkins.java in such a way that only one job can be scheduled for rebuilding the dependency graph. If this method is called while the dependency graph is still rebuilding, the current run is canceled and a new run is started.

            People

              Unassigned Unassigned
              simon_sohrt Simon Sohrt
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: