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

'Destination already contains component' error when using staging API

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.23.0, 3.28.0
    • Fix Version/s: 3.29.1
    • Component/s: Staging
    • Labels:
    • Notability:
      2

      Description

      When using Staging to move a component from a source repo to a target repo which has "allow redeploy" enabled, the move will fail with a "Destination already contains component" error" if the component already exists in the target repo.

      It is expected that the move will succeed as the target repo has allow redeploy enabled.

      This issue is not format specific and the following reproducer is based on Docker:

      Step-1). Create docker image and then push it to the "docker-hosted" repo.

      cat > Dockerfile << EOF 
      FROM alpine
      RUN echo "v1.0.0" > /tmp/version.txt
      EOF
      
      docker build -t buildtoolstest:v1.0.0 .
      
      docker tag buildtoolstest:v1.0.0 node1.example.com:5000/buildtoolstest:v1.0.0
      docker tag buildtoolstest:v1.0.0 node1.example.com:5000/buildtoolstest:v1.0
      docker tag buildtoolstest:v1.0.0 node1.example.com:5000/buildtoolstest:v1
      
      docker push node1.example.com:5000/buildtoolstest:v1.0.0
      docker push node1.example.com:5000/buildtoolstest:v1.0
      docker push node1.example.com:5000/buildtoolstest:v1
      

      Step-2). Using Staging API move these docker images from "docker-hosted" to "docker-hosted-test" docker repo.

      curl -u admin:admin123 -X POST "http://node1.example.com:8081/service/rest/v1/staging/move/docker-hosted-test?docker.imageName=buildtoolstest&repository=docker-hosted"
      
      {
        "status" : 200,
        "message" : "Move Successful",
        "data" : {
          "destination" : "docker-hosted-test",
          "components moved" : [ {
            "name" : "buildtoolstest",
            "version" : "v1.0.0"
          }, {
            "name" : "buildtoolstest",
            "version" : "v1.0"
          }, {
            "name" : "buildtoolstest",
            "version" : "v1"
          } ]
        }
      }
      

      Step-3). Now Create another docker image and push it again to "docker-hosted".

      cat > Dockerfile << EOF 
      FROM alpine
      RUN echo "v1.0.1" > /tmp/version.txt
      EOF
      
      docker build -t buildtoolstest:v1.0.1 .
      
      docker tag buildtoolstest:v1.0.1 node1.example.com:5000/buildtoolstest:v1.0.1
      docker tag buildtoolstest:v1.0.1 node1.example.com:5000/buildtoolstest:v1.0
      docker tag buildtoolstest:v1.0.1 node1.example.com:5000/buildtoolstest:v1
      
      docker push node1.example.com:5000/buildtoolstest:v1.0.1
      docker push node1.example.com:5000/buildtoolstest:v1.0
      docker push node1.example.com:5000/buildtoolstest:v1
      

      Step-4). Using Staging API now move

      curl -u admin:admin123 -X POST "http://node1.example.com:8081/service/rest/v1/staging/move/docker-hosted-test?docker.imageName=buildtoolstest&docker.imageTag=v1.0.1&repository=docker-hosted"
      
      {
        "status" : 200,
        "message" : "Move Successful",
        "data" : {
          "destination" : "docker-hosted-test",
          "components moved" : [ {
            "name" : "buildtoolstest",
            "version" : "v1.0.1"
          } ]
        }
      } 
      

      However, other move fails which already has the same :

      curl -u admin:admin123 -X POST "http://node1.example.com:8081/service/rest/v1/staging/move/docker-hosted-test?docker.imageName=buildtoolstest&docker.imageTag=v1.0&repository=docker-hosted"
      
      {
        "status" : 400,
        "message" : "Destination already contains component: group=null, name=buildtoolstest, version=v1.0, format=docker",
        "data" : {
          "source" : {
            "repository" : "docker-hosted",
            "format" : "docker"
          },
          "destination" : {
            "repository" : "docker-hosted-test",
            "format" : "docker"
          }
        }
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sonofreichuk Sergii Onofreichuk
              Reporter:
              jsensharma Jay Kumar SenSharma
              CC:
              Richard Bywater
              Last Updated By:
              Hajime Osako Hajime Osako
              Team:
              NXRM - Trinity
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response:

                  tigCommentSecurity.panel-title