nerdctl icon indicating copy to clipboard operation
nerdctl copied to clipboard

feat: add `--remove-orphans` flag to `compose down`

Open stillfox-lee opened this issue 3 years ago • 2 comments

Signed-off-by: Siyi Liao [email protected]

close: https://github.com/containerd/nerdctl/issues/1344

stillfox-lee avatar Sep 08 '22 07:09 stillfox-lee

test-integration-docker-compatibility seems failing

=== RUN   TestComposeDownRemoveOrphans
    compose_down_linux_test.go:54: projectName="nerdctl-compose-test-1662693203"
    compose_down_linux_test.go:61: assertion failed: res.ExitCode is not exitCode: Stopping nerdctl-compose-test-1662693203_test_1 ... 
        Stopping nerdctl-compose-test-1662693203_test_1 ... done
        Found orphan containers (nerdctl-compose-test-1662693203_orphan_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
        Removing nerdctl-compose-test-1662693203_test_1 ... 
        Removing nerdctl-compose-test-1662693203_test_1 ... done
        Removing network nerdctl-compose-test-1662693203_default
        error while removing network: network nerdctl-compose-test-1662693203_default id b2cad4ddcb3f07d66fe38fab5a38577b69c241cd90f41153e24be5c7097ab71c has active endpoints
        
--- FAIL: TestComposeDownRemoveOrphans (23.30s)

AkihiroSuda avatar Oct 09 '22 14:10 AkihiroSuda

test-integration-docker-compatibility seems failing

=== RUN   TestComposeDownRemoveOrphans
    compose_down_linux_test.go:54: projectName="nerdctl-compose-test-1662693203"
    compose_down_linux_test.go:61: assertion failed: res.ExitCode is not exitCode: Stopping nerdctl-compose-test-1662693203_test_1 ... 
        Stopping nerdctl-compose-test-1662693203_test_1 ... done
        Found orphan containers (nerdctl-compose-test-1662693203_orphan_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
        Removing nerdctl-compose-test-1662693203_test_1 ... 
        Removing nerdctl-compose-test-1662693203_test_1 ... done
        Removing network nerdctl-compose-test-1662693203_default
        error while removing network: network nerdctl-compose-test-1662693203_default id b2cad4ddcb3f07d66fe38fab5a38577b69c241cd90f41153e24be5c7097ab71c has active endpoints
        
--- FAIL: TestComposeDownRemoveOrphans (23.30s)

@AkihiroSuda Thanks for your help. I think the main reason is the different behavior of docker and nerdctl. Could your please take a look at this scenario?

stillfox-lee avatar Oct 10 '22 15:10 stillfox-lee

Is this still draft?

Looks good but needs squashing commits

AkihiroSuda avatar Dec 21 '22 00:12 AkihiroSuda

maybe also rebase to get the fix for flaky tests

djdongjin avatar Dec 21 '22 02:12 djdongjin

@AkihiroSuda @djdongjin Hi, sorry for the delay. PTAL.

stillfox-lee avatar Dec 26 '22 14:12 stillfox-lee

Please squash commits

AkihiroSuda avatar Dec 27 '22 04:12 AkihiroSuda

@AkihiroSuda I used git rebase -i to squash into one commit, but didn't expect to get this result. What should I do now? Execute git rest by reflog to reverse?

stillfox-lee avatar Dec 27 '22 14:12 stillfox-lee

@stillfox-lee can you try this and see if it works?

First update your local main branch (git checkout main; git pull upstream main)

Then rebase this branch and resolve conflict (git checkout compose/down-remove-orphans; git rebase main)

Otherwise, maybe you can also try create a new local branch and cherrypick your own commit to the new branch and force push from the new local branch to the old remote branch.

djdongjin avatar Dec 28 '22 16:12 djdongjin

Otherwise, maybe you can also try create a new local branch and cherrypick your own commit to the new branch and force push from the new local branch to the old remote branch.

@djdongjin It works! Thanks a lot.

stillfox-lee avatar Dec 29 '22 15:12 stillfox-lee

By the way, how should I squash commits in this case (merged main branch already)?

stillfox-lee avatar Dec 29 '22 15:12 stillfox-lee

By the way, how should I squash commits in this case (merged main branch already)?

Personally I don't use merge much and use more rebase, so in my case (assume I create 5 commits):

# update local main
git checkout main
git pull upstream main
# rebase dev branch, so my 5 commits are on the top
git checkout dev
git rebase main
# squash / interactively rebase the latest 5 commits
git rebase -i HEAD~5

djdongjin avatar Dec 29 '22 15:12 djdongjin

By the way, how should I squash commits in this case (merged main branch already)?

Personally I don't use merge much and use more rebase, so in my case (assume I create 5 commits):

# update local main
git checkout main
git pull upstream main
# rebase dev branch, so my 5 commits are on the top
git checkout dev
git rebase main
# squash / interactively rebase the latest 5 commits
git rebase -i HEAD~5

Got it. Thanks.

stillfox-lee avatar Dec 29 '22 16:12 stillfox-lee