Uploaded image for project: 'Jira Software Data Center'
  1. Jira Software Data Center
  2. JSWSERVER-16340

DVCS: sync is broken for Github Enterprise when an organization is deleted

    XMLWordPrintable

Details

    Description

      Summary

      DVCS: sync is broken for Github Enterprise when an organization is deleted

      Steps to Reproduce

      1. goto Github Enterprise, create OAuth credentials for the user;
      2. create 2 organizations with a repo in each;
      3. add the organizations, one by one, to DVCS;
      4. goto Github Enterprise, delete an organization;
      5. wait until the next hourly sync

      Expected Results

      The sync should complete successfully

      Actual Results

      The sync fails and any subsequent sync jobs fail as well. The following error is thrown in atlassian-jira.log

      2017-11-24 22:03:33,188 Caesium-1-3 ERROR ServiceRunner     [c.a.scheduler.core.JobLauncher] Scheduled job with ID 'com.atlassian.jira.plugins.dvcs.scheduler.DvcsScheduler:job' failed
      com.atlassian.jira.plugins.dvcs.exception.SourceControlException: Error retrieving list of repositories
      	at com.atlassian.jira.plugins.dvcs.spi.github.GithubCommunicator.getRepositories(GithubCommunicator.java:214)
      	at com.atlassian.jira.plugins.dvcs.service.remote.CachingCommunicator.getRepositories(CachingCommunicator.java:126)
      	at com.atlassian.jira.plugins.dvcs.service.RepositoryServiceImpl.syncRepositoryList(RepositoryServiceImpl.java:205)
      	at com.atlassian.jira.plugins.dvcs.service.RepositoryServiceImpl.syncRepositoryList(RepositoryServiceImpl.java:262)
      	at com.atlassian.jira.plugins.dvcs.scheduler.DvcsSchedulerJobRunner.syncOrganizations(DvcsSchedulerJobRunner.java:60)
      	at com.atlassian.jira.plugins.dvcs.scheduler.DvcsSchedulerJobRunner.runJob(DvcsSchedulerJobRunner.java:51)
      	at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:153)
      	at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:118)
      	at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:97)
      	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.launchJob(CaesiumSchedulerService.java:443)
      	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeClusteredJob(CaesiumSchedulerService.java:438)
      	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeClusteredJobWithRecoveryGuard(CaesiumSchedulerService.java:462)
      	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeQueuedJob(CaesiumSchedulerService.java:390)
      	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService$1.consume(CaesiumSchedulerService.java:285)
      	at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService$1.consume(CaesiumSchedulerService.java:282)
      	at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeJob(SchedulerQueueWorker.java:65)
      	at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeNextJob(SchedulerQueueWorker.java:59)
      	at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.run(SchedulerQueueWorker.java:34)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: org.eclipse.egit.github.core.client.RequestException: Not Found (404)
      	at org.eclipse.egit.github.core.client.GitHubClient.createException(GitHubClient.java:552)
      	at org.eclipse.egit.github.core.client.GitHubClient.get(GitHubClient.java:740)
      	at org.eclipse.egit.github.core.client.PageIterator.next(PageIterator.java:173)
      	at org.eclipse.egit.github.core.service.GitHubService.getAll(GitHubService.java:151)
      	at org.eclipse.egit.github.core.service.RepositoryService.getRepositories(RepositoryService.java:242)
      	... 18 more
      

      This bug is related to JSWSERVER-14268 but deals with deleted organizations rather than forked repositories.

      Workaround:

      1. Run following SQL command and copy the values of NAME and HOST_URL fields in next steps -
        If connected to Github Enterprise use this query:
        SELECT "NAME", "HOST_URL"
        FROM "AO_E8B6CC_ORGANIZATION_MAPPING"
        WHERE "DVCS_TYPE" = 'githube';
        

        If connected to Github Cloud use this query:

        SELECT "NAME", "HOST_URL"
        FROM "AO_E8B6CC_ORGANIZATION_MAPPING"
        WHERE "DVCS_TYPE" = 'github';
        
      2. For each record returned by above SQL command, run following curl commands using valid user credentials that have access to corresponding org/user account -
        curl -u <GITHUB_USER> -H 'Accept:application/json' '<HOST_URL>/api/v3/orgs/<NAME>/repos?per_page=100&page=1'
        

        Replace <HOST_URL> and <NAME> with values of "HOST_URL" and "NAME" fields respectively in SQL command output.

      3. Take any of the organizations that return the following response: 
         {'message': 'Not Found'}
      4. Validate that they do not exist on the Github Enterprise server
      5. Navigate to Settings >> Applications >> DVCS Accounts >> <Organization Name from step 4> ... (3-dots menu) >>> Delete

      Attachments

        Issue Links

          Activity

            People

              cvanes Chris van Es (Inactive)
              ddiblasio David Di Blasio
              Votes:
              8 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: