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

Branches and merge requests disappear when calls to GitLab fail

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      How was this detected?

      Branches in multibranch pipelines for projects hosted in GitLab.com started randomly appearing and disappearing (i.e. random results after every scan).

      What's causing it?

      We have discovered this issue by accident due to a bug in GitLab (https://gitlab.com/gitlab-org/gitlab/issues/37059) which causes the calls to /api/v*/projects/*/branches to return status code 500.

      The gitlab-branch-source-plugin unfortunately handles the exceptions which are thrown during the scan incorrectly. The exceptions are ignored and only the stacktrace is printed into the output.

      Line in code: https://github.com/jenkinsci/gitlab-branch-source-plugin/blob/master/src/main/java/io/jenkins/plugins/gitlabbranchsource/GitLabSCMSource.java#L537

      Because of this, Jenkins is not aware that the scan has failed and treats the empty list of branches and merge requests as successful result and thinks all the branches and MRs have been deleted from the repository.

      How to fix this?

      • Throw the exception out of the method as one of the exception types which are declared by the inherited method contract (e.g. IOException)
      • Given how reliable GitLab APIs are (based on our experience over the last ~6 months as a paying customer...), retry logic should mitigate most of these issues.

       

        Attachments

          Activity

          Hide
          lholota Lukas Holota added a comment -
          Show
          lholota Lukas Holota added a comment - Merge request fixing this bug:  https://github.com/jenkinsci/gitlab-branch-source-plugin/pull/63
          Hide
          redeamer Michael Musenbrock added a comment - - edited

          We now git the issue a few times already, and all our build history is lost again, including the build numbers. Manual restoration is time consuming and bothersome.

          A simply updated of our gitlab instance (with a maintenance reboot) triggers the issue. Jenkins would need to be stopped before gitlab is updated.

          I added a new PR, which solely addresses this issue (without retry as #63 does): #88

          Show
          redeamer Michael Musenbrock added a comment - - edited We now git the issue a few times already, and all our build history is lost again, including the build numbers. Manual restoration is time consuming and bothersome. A simply updated of our gitlab instance (with a maintenance reboot) triggers the issue. Jenkins would need to be stopped before gitlab is updated. I added a new PR, which solely addresses this issue (without retry as #63 does): #88

            People

            Assignee:
            baymac Parichay Barpanda
            Reporter:
            lholota Lukas Holota
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: