mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #14945 from sstosh/pod-pause-cgroupv1
"podman pod pause" return error if cgroups v1 rootless container
This commit is contained in:
@ -5,12 +5,10 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/cgroups"
|
|
||||||
"github.com/containers/podman/v4/cmd/podman/common"
|
"github.com/containers/podman/v4/cmd/podman/common"
|
||||||
"github.com/containers/podman/v4/cmd/podman/registry"
|
"github.com/containers/podman/v4/cmd/podman/registry"
|
||||||
"github.com/containers/podman/v4/cmd/podman/utils"
|
"github.com/containers/podman/v4/cmd/podman/utils"
|
||||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v4/pkg/rootless"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
@ -65,12 +63,6 @@ func pause(cmd *cobra.Command, args []string) error {
|
|||||||
var (
|
var (
|
||||||
errs utils.OutputErrors
|
errs utils.OutputErrors
|
||||||
)
|
)
|
||||||
if rootless.IsRootless() && !registry.IsRemote() {
|
|
||||||
cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
|
|
||||||
if !cgroupv2 {
|
|
||||||
return errors.New("pause is not supported for cgroupv1 rootless containers")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(args) < 1 && !pauseOpts.All {
|
if len(args) < 1 && !pauseOpts.All {
|
||||||
return errors.New("you must provide at least one container name or id")
|
return errors.New("you must provide at least one container name or id")
|
||||||
|
@ -138,6 +138,7 @@ func (ic *ContainerEngine) PodPause(ctx context.Context, namesOrIds []string, op
|
|||||||
errs, err := p.Pause(ctx)
|
errs, err := p.Pause(ctx)
|
||||||
if err != nil && !errors.Is(err, define.ErrPodPartialFail) {
|
if err != nil && !errors.Is(err, define.ErrPodPartialFail) {
|
||||||
report.Errs = []error{err}
|
report.Errs = []error{err}
|
||||||
|
reports = append(reports, &report)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
@ -171,6 +172,7 @@ func (ic *ContainerEngine) PodUnpause(ctx context.Context, namesOrIds []string,
|
|||||||
errs, err := p.Unpause(ctx)
|
errs, err := p.Unpause(ctx)
|
||||||
if err != nil && !errors.Is(err, define.ErrPodPartialFail) {
|
if err != nil && !errors.Is(err, define.ErrPodPartialFail) {
|
||||||
report.Errs = []error{err}
|
report.Errs = []error{err}
|
||||||
|
reports = append(reports, &report)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
@ -196,6 +198,7 @@ func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, opt
|
|||||||
errs, err := p.StopWithTimeout(ctx, false, options.Timeout)
|
errs, err := p.StopWithTimeout(ctx, false, options.Timeout)
|
||||||
if err != nil && !errors.Is(err, define.ErrPodPartialFail) {
|
if err != nil && !errors.Is(err, define.ErrPodPartialFail) {
|
||||||
report.Errs = []error{err}
|
report.Errs = []error{err}
|
||||||
|
reports = append(reports, &report)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
|
Reference in New Issue
Block a user