ExportXMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor
    • Component/s: gitea-plugin
    • None

      Summary

      GiteaNotifier.retryOnServerError() retries only on HTTP 500. When Gitea sits
      behind a reverse proxy and is briefly unreachable or restarting, the proxy
      answers 502/503/504, the retry condition does not match, and the commit status
      notification is abandoned on the first attempt.

      What happens

      The build itself succeeds, but the status never reaches Gitea:

      [Gitea] Notifying branch build status: SUCCESS This commit looks good
      ERROR: Could not send notifications
      org.jenkinsci.plugin.gitea.client.api.GiteaHttpStatusException: HTTP 502/Bad Gateway
          at ...DefaultGiteaConnection.post(DefaultGiteaConnection.java:1015)
          at ...DefaultGiteaConnection.createCommitStatus(DefaultGiteaConnection.java:619)
          at ...GiteaNotifier.lambda$sendNotifications$0(GiteaNotifier.java:160)
          at ...GiteaNotifier.retryOnServerError(GiteaNotifier.java:175)
          at ...GiteaNotifier.sendNotifications(GiteaNotifier.java:160)
          at ...GiteaNotifier$JobCompletedListener.onCompleted(GiteaNotifier.java:345)
      

      The commit is left with no status, which for a PR means required-status checks
      never resolve, and the only trace is a stack trace in the build log of an
      otherwise green build.

      Cause

      GiteaNotifier.java (current master):

      private static <T> T retryOnServerError(GiteaOperation<T> operation) throws IOException, InterruptedException {
          int tries = 3;
          while (true) {
              tries--;
              try {
                  return operation.execute();
              } catch (GiteaHttpStatusException e) {
                  if (e.getStatusCode() == 500 && tries > 0) {
                      // server may be overloaded
                      continue;
                  }
                  throw e;
              }
          }
      }
      

      Two separate problems:

      1. The condition is == 500. A reverse proxy reporting the backend as
        unreachable or restarting returns 502, 503 or 504, none of which are
        retried. Zero retries occur.
      2. Even when the condition does match, continue retries immediately with no
        delay. Three attempts complete in microseconds, which cannot outlast any real
        server-side blip. The comment says "server may be overloaded", but hammering
        an overloaded server three times without pausing is the opposite of a backoff.

      Steps to reproduce

      1. Run Gitea behind a reverse proxy (nginx or similar).
      2. Configure a Jenkins multibranch pipeline using the Gitea plugin.
      3. Stop or restart Gitea so the proxy returns 502, then let a build finish while
        it is still coming back up.
      4. The build completes with its real result, and the log shows
        "ERROR: Could not send notifications" with GiteaHttpStatusException HTTP 502.
        The commit has no status in Gitea.

      Expected

      A transient 5xx from the proxy or from Gitea should be retried, with a short
      delay between attempts, before the notification is abandoned.

      Suggested fix

      Retry on any 5xx rather than 500 only, and add a short backoff between
      attempts. The method already declares throws InterruptedException, so a
      sleep needs no signature change.

      Note this is deliberately a bounded improvement: a few seconds of backoff will
      cover a proxy blip or a rolling restart, not a full cold start of a large Gitea
      instance. Blocking a build's post-action for that long would be a worse
      trade-off than losing the status.

            Assignee:
            Unassigned
            Reporter:
            Mykola Shestopal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: