Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compose pause and unpause commands #1621

Merged
merged 1 commit into from
Dec 8, 2022

Conversation

djdongjin
Copy link
Member

I put the two commands in the same file and all logic on the cmd/nerdctl side (no logic in pkg/composer) because:

  1. They rely on pauseContainer and unpauseContainer which are in cmd and we don't want pkg to rely on cmd. (Or maybe we can move all to their related pkgs).
  2. The two commands have straightforward and almost same logic (only difference on (un)pause) and they're usually used together.
  3. We test them together (pause and then unpause)

The current implementation follows docker compose behavior, which parallelizes (un)pause services and stops whenever there is an error, causing the result in an intermediate state (some services are paused and some are not, depending on the parallelization). As an example:

$ nerdctl compose pause svc0 # pause 1 svc
compose-test_svc0_1
$ nerdctl compose ps
NAME                     COMMAND             SERVICE    STATUS     PORTS
...
compose-test_svcc6_1     "sleep infinity"    svcc6      running
compose-test_svc0_1      "sleep infinity"    svc0       Paused
compose-test_svccc4_1    "sleep infinity"    svccc4     running
...
$ nerdctl compose pause # pause all svc
FATA[0000] container add38a31feb35a125d4433ec69be845aff356080a137c5768fb851a54ab7d61a is already paused
$ nerdctl compose ps # some are paused and some are not
NAME                     COMMAND             SERVICE    STATUS     PORTS
compose-test_svcc2_1     "sleep infinity"    svcc2      Paused
compose-test_svcc3_1     "sleep infinity"    svcc3      running
compose-test_svccc0_1    "sleep infinity"    svccc0     Paused
compose-test_svc3_1      "sleep infinity"    svc3       Paused
compose-test_svccc2_1    "sleep infinity"    svccc2     Paused
compose-test_svcc4_1     "sleep infinity"    svcc4      Paused
compose-test_svccc1_1    "sleep infinity"    svccc1     running
compose-test_svc7_1      "sleep infinity"    svc7       Paused
compose-test_svc5_1      "sleep infinity"    svc5       running
compose-test_svc6_1      "sleep infinity"    svc6       Paused
compose-test_svcc0_1     "sleep infinity"    svcc0      Paused
compose-test_svcc6_1     "sleep infinity"    svcc6      running
compose-test_svc0_1      "sleep infinity"    svc0       Paused
compose-test_svccc4_1    "sleep infinity"    svccc4     Paused
compose-test_svcc7_1     "sleep infinity"    svcc7      running
compose-test_svc2_1      "sleep infinity"    svc2       Paused
compose-test_svc1_1      "sleep infinity"    svc1       Paused
compose-test_svccc6_1    "sleep infinity"    svccc6     running
compose-test_svccc3_1    "sleep infinity"    svccc3     running
compose-test_svcc1_1     "sleep infinity"    svcc1      running
compose-test_svc4_1      "sleep infinity"    svc4       running
compose-test_svccc7_1    "sleep infinity"    svccc7     running
compose-test_svcc5_1     "sleep infinity"    svcc5      Paused
compose-test_svccc5_1    "sleep infinity"    svccc5     Paused

Signed-off-by: Jin Dong jindon@amazon.com

"github.com/containerd/nerdctl/pkg/testutil"
)

func TestComposePauseAndUnpause(t *testing.T) {
Copy link
Member

@AkihiroSuda AkihiroSuda Dec 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip if base.Info().CgroupDriver == "none"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. thanks for the reminder.

Signed-off-by: Jin Dong <jindon@amazon.com>

Add compose pause and unpause test

Signed-off-by: Jin Dong <jindon@amazon.com>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 102bd6c into containerd:main Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants