Uploaded image for project: 'Dev - Nexus Repo'
  1. Dev - Nexus Repo
  2. NEXUS-28357

A Repository in any other state than STARTED cannot be removed

    Details

    • Type: Bug
    • Status: New
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.30.1
    • Fix Version/s: None
    • Component/s: Repository
    • Labels:
    • Environment:
      CentOS 7.x

      Description

      I have the similar issue as https://issues.sonatype.org/browse/NEXUS-19437  but my problem is not about blobstore, but about Repository. 

       

      My scenario is:

      1. I created the NPM hosted repository through REST API Call
      POST /service/rest/v1/repositories/npm/hosted HTTP/2
      Host: repo.example.com
      accept: application/json
      content-type: application/json
      authorization: Basic ..............
      content-length: 251
      {
         "name": "test-repo",
         "online": true,
         "storage": {
           "blobStoreName": "npm-blob-store",
           "strictContentTypeValidation": true,
           "writePolicy": "allow_once"
         },
         "cleanup": {
           "policyNames": [
             "NPM_CLEANUP_020_DAYS"
           ]
         }
      }
      
      1. but the blobStoreName was invalid (not exists)
      2. The Nexus didn´t validate the blobstore reference and created the repository.  But the repository was not working
      3. I tried to DELETE the repository from GUI, but this failes
      4. Then I tried to DELETE repository from Groovy Task script like 
        import org.sonatype.nexus.repository.Repository
        
        Repository repo = repository.getRepositoryManager().get("test-repo")
        repo.delete();
      1. but all attempts failes on state, because the repozitory was in FAILED state and I didnt found any function, which could be used to DROP the repository
      2. also use o Repository manager was imposible, same errors
        repository.getRepositoryManager().delete("test-repo")
        
      1. as last chance I tried the code inspired by https://issues.sonatype.org/browse/NEXUS-19437 
        Repository repo = repository.getRepositoryManager().get("test-repo")
        repo.stateGuard.transition('STARTED').run({})
        repo.delete();
        repo.destroy();
      1. but this code cases that the Repository instance cached in memory by RepositoryManager  lost the reference to Configuration and the List of Repositories in UI was broken by nullpointerException - we lost capability to manage the Nexus repositories.  It was already reported as https://issues.sonatype.org/browse/NEXUS-21048
      2. So we decided to restart Nexus to cleanup memory caches.   But this was the last time when we saw the nexus responding.  Some inconsistenci in database related to previous actions on repository, stops the nexus boot.
      3. So the result was - restore all data from backup 

       

      I see two bugs in this story:

      1. the repository Create command should validate all atributes corectly - IF the blobstore name is mandatory, the blobstore should exists or the Error should be thrown
      2. there is no capability to force DELETE (DROP) of Repository, which is in some inconsistent state, or in FAILED state.  The API should be tolerant and make as much as possible to cleanup all objects related to repository and when something already was destroyed, skip it and continue to remove rest of the object.  The Delete operation should be reentrant.

       

      Thank you for improve of the functionality

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              kek Petr Novak
              Last Updated By:
              Joe Tom Joe Tom
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Date of First Response:

                  tigCommentSecurity.panel-title