Unpause unpauses a container by its id.
(ctx context.Context, client *containerd.Client, id string, cfg *config.Config, nerdctlCmd string, nerdctlArgs []string)
| 527 | |
| 528 | // Unpause unpauses a container by its id. |
| 529 | func Unpause(ctx context.Context, client *containerd.Client, id string, cfg *config.Config, nerdctlCmd string, nerdctlArgs []string) error { |
| 530 | container, err := client.LoadContainer(ctx, id) |
| 531 | if err != nil { |
| 532 | return err |
| 533 | } |
| 534 | |
| 535 | task, err := container.Task(ctx, cio.Load) |
| 536 | if err != nil { |
| 537 | return err |
| 538 | } |
| 539 | |
| 540 | status, err := task.Status(ctx) |
| 541 | if err != nil { |
| 542 | return err |
| 543 | } |
| 544 | |
| 545 | // Recreate healthcheck related systemd timer/service files. |
| 546 | if err := healthcheck.CreateTimer(ctx, container, cfg, nerdctlCmd, nerdctlArgs); err != nil { |
| 547 | return fmt.Errorf("failed to create healthcheck timer: %w", err) |
| 548 | } |
| 549 | if err := healthcheck.StartTimer(ctx, container, cfg); err != nil { |
| 550 | return fmt.Errorf("failed to start healthcheck timer: %w", err) |
| 551 | } |
| 552 | |
| 553 | switch status.Status { |
| 554 | case containerd.Paused: |
| 555 | return task.Resume(ctx) |
| 556 | default: |
| 557 | return fmt.Errorf("container %s is not paused", id) |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | // ContainerStateDirPath returns the path to the Nerdctl-managed state directory for the container with the given ID. |
| 562 | func ContainerStateDirPath(ns, dataStore, id string) (string, error) { |
no test coverage detected
searching dependent graphs…