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

Events handling for deleted branches can blow up

    XMLWordPrintable

Details

    • Bug
    • Status: In Review (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • Jenkins 2.74
      Branch API Plugin 2.0.11
      GitHub Branch Source Plugin 2.2.3

    Description

      Hi,

      In a multibranch pipeline job configured with GitHub repository, when a branch was deleted in GitHub and respective event is processed in Jenkins, that branch is not marked as dead in a 'Branches' view any longer.

      Related snippet from the Repository Events log is below.

      At a glance, when fetching branch data for all branches of interest, an exception is thrown for deleted branches which causes processing to stop.

      In turn, the branch info is fetched during lazy iteration here.

      Not sure if this issue should be filed against GItHub Branch Source Plugin or this one, because event though the exception is thrown from downstream, on the upstream level it sounds odd to fetch data for the branch just deleted. However I don't know the plugin innards well enough to speculate here.

      [Fri Aug 18 06:18:59 PDT 2017] Received Push event to branch non-buildable-branch in repository me/pipelineTrigger REMOVED event from 10.254.180.205 ⇒ http://my.host.com:9090/github-webhook/ with timestamp Fri Aug 18 06:18:54 PDT 2017
      06:18:59 Connecting to https://github.com/api/v3 using me/****** (GitHub OAuth token)
      Examining me/pipelineTrigger
      
        Checking branches...
      
        Getting remote branch non-buildable-branch...
      ERROR: {"message":"Branch not found","documentation_url":"https://developer.github.com/enterprise/2.9/v3/repos/#get-branch"}
      java.io.FileNotFoundException: https://github.com/api/v3/repos/me/pipelineTrigger/branches/non-buildable-branch
      	at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
      	at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
      	at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
      	at org.kohsuke.github.Requester.parse(Requester.java:602)
      	at org.kohsuke.github.Requester.parse(Requester.java:584)
      	at org.kohsuke.github.Requester._to(Requester.java:264)
      Caused: java.io.FileNotFoundException: {"message":"Branch not found","documentation_url":"https://developer.github.com/enterprise/2.9/v3/repos/#get-branch"}
      	at org.kohsuke.github.Requester.handleApiError(Requester.java:660)
      	at org.kohsuke.github.Requester._to(Requester.java:285)
      	at org.kohsuke.github.Requester.to(Requester.java:226)
      	at org.kohsuke.github.GHRepository.getBranch(GHRepository.java:1234)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$LazyBranches.create(GitHubSCMSource.java:1773)
      	at org.jenkinsci.plugins.github_branch_source.LazyIterable.iterator(LazyIterable.java:57)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:869)
      	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:355)
      	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:309)
      	at jenkins.branch.MultiBranchProject$SCMEventListenerImpl.processHeadUpdate(MultiBranchProject.java:1543)
      	at jenkins.branch.MultiBranchProject$SCMEventListenerImpl.onSCMHeadEvent(MultiBranchProject.java:1144)
      	at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:247)
      	at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:230)
      	at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:481)
      	at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      [Fri Aug 18 06:18:59 PDT 2017] Push event to branch non-buildable-branch in repository me/pipelineTrigger REMOVED event from 10.254.180.205 ⇒ http://my.host.com:9090/github-webhook/ with timestamp Fri Aug 18 06:18:54 PDT 2017 processed in 0.47 sec

      Attachments

        Issue Links

          Activity

            anenviousguest Vladislav Ponomarev created issue -
            anenviousguest Vladislav Ponomarev made changes -
            Field Original Value New Value
            Description Hi,

            In a multibranch pipeline job configured with GitHub repository, when a branch was deleted in GitHub and respective event is processed in Jenkins, that branch is not marked as dead in a 'Branches' view any longer.

            Related snippet from the Repository Events log is below.

            At a glance, when [fetching branch data for all branches of interest,|https://github.com/anenviousguest/branch-api-plugin/blob/master/src/main/java/jenkins/branch/MultiBranchProject.java#L1543] an exception is thrown for deleted branches which causes processing to stop.

            In turn, the branch info is fetched during lazy iteration [here.|https://github.com/jenkinsci/github-branch-source-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java#L869]

            Not sure if this issue should be filed against GItHub Branch Source Plugin or this one, because event though the exception is thrown from downstream, on the upstream level it sounds odd to fetch data for the branch just deleted. However I don't know the plugin innards well enough to speculate here.
            {noformat}
            [Fri Aug 18 06:18:59 PDT 2017] Received Push event to branch non-buildable-branch in repository me/pipelineTrigger REMOVED event from 10.254.180.205 ⇒ http://my.host.com:9090/github-webhook/ with timestamp Fri Aug 18 06:18:54 PDT 2017
            06:18:59 Connecting to https://github.com/api/v3 using me/****** (GitHub OAuth token)
            Examining me/pipelineTrigger

              Checking branches...

              Getting remote branch non-buildable-branch...
            ERROR: {"message":"Branch not found","documentation_url":"https://developer.github.com/enterprise/2.9/v3/repos/#get-branch"}
            java.io.FileNotFoundException: https://github.com/api/v3/repos/me/pipelineTrigger/branches/non-buildable-branch
            at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
            at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
            at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
            at org.kohsuke.github.Requester.parse(Requester.java:602)
            at org.kohsuke.github.Requester.parse(Requester.java:584)
            at org.kohsuke.github.Requester._to(Requester.java:264)
            Caused: java.io.FileNotFoundException: {"message":"Branch not found","documentation_url":"https://developer.github.com/enterprise/2.9/v3/repos/#get-branch"}
            at org.kohsuke.github.Requester.handleApiError(Requester.java:660)
            at org.kohsuke.github.Requester._to(Requester.java:285)
            at org.kohsuke.github.Requester.to(Requester.java:226)
            at org.kohsuke.github.GHRepository.getBranch(GHRepository.java:1234)
            at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$LazyBranches.create(GitHubSCMSource.java:1773)
            at org.jenkinsci.plugins.github_branch_source.LazyIterable.iterator(LazyIterable.java:57)
            at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:869)
            at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:355)
            at jenkins.scm.api.SCMSource.fetch(SCMSource.java:309)
            at jenkins.branch.MultiBranchProject$SCMEventListenerImpl.processHeadUpdate(MultiBranchProject.java:1543)
            at jenkins.branch.MultiBranchProject$SCMEventListenerImpl.onSCMHeadEvent(MultiBranchProject.java:1144)
            at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:247)
            at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:230)
            at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:481)
            at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            at java.lang.Thread.run(Thread.java:748)
            [Fri Aug 18 06:18:59 PDT 2017] Push event to branch non-buildable-branch in repository vponomarev/pipelineTrigger REMOVED event from 10.254.180.205 ⇒ http://my.host.com:9090/github-webhook/ with timestamp Fri Aug 18 06:18:54 PDT 2017 processed in 0.47 sec{noformat}
            Hi,

            In a multibranch pipeline job configured with GitHub repository, when a branch was deleted in GitHub and respective event is processed in Jenkins, that branch is not marked as dead in a 'Branches' view any longer.

            Related snippet from the Repository Events log is below.

            At a glance, when [fetching branch data for all branches of interest,|https://github.com/anenviousguest/branch-api-plugin/blob/master/src/main/java/jenkins/branch/MultiBranchProject.java#L1543] an exception is thrown for deleted branches which causes processing to stop.

            In turn, the branch info is fetched during lazy iteration [here.|https://github.com/jenkinsci/github-branch-source-plugin/blob/master/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java#L869]

            Not sure if this issue should be filed against GItHub Branch Source Plugin or this one, because event though the exception is thrown from downstream, on the upstream level it sounds odd to fetch data for the branch just deleted. However I don't know the plugin innards well enough to speculate here.
            {noformat}
            [Fri Aug 18 06:18:59 PDT 2017] Received Push event to branch non-buildable-branch in repository me/pipelineTrigger REMOVED event from 10.254.180.205 ⇒ http://my.host.com:9090/github-webhook/ with timestamp Fri Aug 18 06:18:54 PDT 2017
            06:18:59 Connecting to https://github.com/api/v3 using me/****** (GitHub OAuth token)
            Examining me/pipelineTrigger

              Checking branches...

              Getting remote branch non-buildable-branch...
            ERROR: {"message":"Branch not found","documentation_url":"https://developer.github.com/enterprise/2.9/v3/repos/#get-branch"}
            java.io.FileNotFoundException: https://github.com/api/v3/repos/me/pipelineTrigger/branches/non-buildable-branch
            at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
            at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
            at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
            at org.kohsuke.github.Requester.parse(Requester.java:602)
            at org.kohsuke.github.Requester.parse(Requester.java:584)
            at org.kohsuke.github.Requester._to(Requester.java:264)
            Caused: java.io.FileNotFoundException: {"message":"Branch not found","documentation_url":"https://developer.github.com/enterprise/2.9/v3/repos/#get-branch"}
            at org.kohsuke.github.Requester.handleApiError(Requester.java:660)
            at org.kohsuke.github.Requester._to(Requester.java:285)
            at org.kohsuke.github.Requester.to(Requester.java:226)
            at org.kohsuke.github.GHRepository.getBranch(GHRepository.java:1234)
            at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource$LazyBranches.create(GitHubSCMSource.java:1773)
            at org.jenkinsci.plugins.github_branch_source.LazyIterable.iterator(LazyIterable.java:57)
            at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:869)
            at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:355)
            at jenkins.scm.api.SCMSource.fetch(SCMSource.java:309)
            at jenkins.branch.MultiBranchProject$SCMEventListenerImpl.processHeadUpdate(MultiBranchProject.java:1543)
            at jenkins.branch.MultiBranchProject$SCMEventListenerImpl.onSCMHeadEvent(MultiBranchProject.java:1144)
            at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:247)
            at jenkins.scm.api.SCMHeadEvent$DispatcherImpl.fire(SCMHeadEvent.java:230)
            at jenkins.scm.api.SCMEvent$Dispatcher.run(SCMEvent.java:481)
            at jenkins.security.ImpersonatingScheduledExecutorService$1.run(ImpersonatingScheduledExecutorService.java:58)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
            at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            at java.lang.Thread.run(Thread.java:748)
            [Fri Aug 18 06:18:59 PDT 2017] Push event to branch non-buildable-branch in repository me/pipelineTrigger REMOVED event from 10.254.180.205 ⇒ http://my.host.com:9090/github-webhook/ with timestamp Fri Aug 18 06:18:54 PDT 2017 processed in 0.47 sec{noformat}
            stephenconnolly Stephen Connolly made changes -
            Summary Due to fetch errors, deleted branch is not marked as "dead" any longer Events handling for deleted branches can blow up

            This is really just a bug in the event handling code, renaming as such

            stephenconnolly Stephen Connolly added a comment - This is really just a bug in the event handling code, renaming as such
            stephenconnolly Stephen Connolly made changes -
            Remote Link This issue links to "PR#15 (Web Link)" [ 17601 ]
            stephenconnolly Stephen Connolly made changes -
            Remote Link This issue links to "PR#15 (Web Link)" [ 17601 ]
            stephenconnolly Stephen Connolly made changes -
            Remote Link This issue links to "PR#156 (Web Link)" [ 17603 ]
            stephenconnolly Stephen Connolly made changes -
            Component/s github-branch-source-plugin [ 20858 ]
            Component/s branch-api-plugin [ 18621 ]
            stephenconnolly Stephen Connolly made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            stephenconnolly Stephen Connolly made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]

            Code changed in jenkins
            User: Stephen Connolly
            Path:
            src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java
            http://jenkins-ci.org/commit/github-branch-source-plugin/49989435e00ac8e74621386daac291a912d17fbd
            Log:
            [FIXED JENKINS-46295] Handle the case where the query optimization is for a deleted branch

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Stephen Connolly Path: src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java http://jenkins-ci.org/commit/github-branch-source-plugin/49989435e00ac8e74621386daac291a912d17fbd Log: [FIXED JENKINS-46295] Handle the case where the query optimization is for a deleted branch
            acejam Joshua Noble added a comment -

            stephenconnolly This fix has been merged and looks good to me. Can we get a release cut of this plugin so the fix can be deployed?

            acejam Joshua Noble added a comment - stephenconnolly This fix has been merged and looks good to me. Can we get a release cut of this plugin so the fix can be deployed?
            stephenconnolly Stephen Connolly made changes -
            Remote Link This issue links to "Page (Jenkins Wiki)" [ 17913 ]

            Removing myself as assignee. My current work assignments do not provide sufficient bandwidth to review these issues and in the majority of cases I am only assigned by virtue of being the default assignee. For the credentials-api and scm-api related plugins I have permission to allocate time reviewing changes to these APIs themselves to ensure these APIs remain cohesive, but that can be handled through PR reviews rather than assigning issues in JIRA

            stephenconnolly Stephen Connolly added a comment - Removing myself as assignee. My current work assignments do not provide sufficient bandwidth to review these issues and in the majority of cases I am only assigned by virtue of being the default assignee. For the credentials-api and scm-api related plugins I have permission to allocate time reviewing changes to these APIs themselves to ensure these APIs remain cohesive, but that can be handled through PR reviews rather than assigning issues in JIRA
            stephenconnolly Stephen Connolly made changes -
            Assignee Stephen Connolly [ stephenconnolly ]

            People

              Unassigned Unassigned
              anenviousguest Vladislav Ponomarev
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: