Details
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
- is related to
-
NEXUS-28452 Staging move may fail against a repo created by Repository API
-
- Closed
-