mirror of
https://github.com/containers/podman.git
synced 2025-06-17 23:20:59 +08:00
rootless: implement pod restart
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -67,25 +67,26 @@ var cmdsNotRequiringRootless = map[*cobra.Command]bool{
|
|||||||
_exportCommand: true,
|
_exportCommand: true,
|
||||||
//// `info` must be executed in an user namespace.
|
//// `info` must be executed in an user namespace.
|
||||||
//// If this change, please also update libpod.refreshRootless()
|
//// If this change, please also update libpod.refreshRootless()
|
||||||
_loginCommand: true,
|
_loginCommand: true,
|
||||||
_logoutCommand: true,
|
_logoutCommand: true,
|
||||||
_mountCommand: true,
|
_mountCommand: true,
|
||||||
_killCommand: true,
|
_killCommand: true,
|
||||||
_pauseCommand: true,
|
_pauseCommand: true,
|
||||||
_podRmCommand: true,
|
_podRmCommand: true,
|
||||||
_podKillCommand: true,
|
_podKillCommand: true,
|
||||||
_podStatsCommand: true,
|
_podRestartCommand: true,
|
||||||
_podStopCommand: true,
|
_podStatsCommand: true,
|
||||||
_podTopCommand: true,
|
_podStopCommand: true,
|
||||||
_restartCommand: true,
|
_podTopCommand: true,
|
||||||
&_psCommand: true,
|
_restartCommand: true,
|
||||||
_rmCommand: true,
|
&_psCommand: true,
|
||||||
_runCommand: true,
|
_rmCommand: true,
|
||||||
_unpauseCommand: true,
|
_runCommand: true,
|
||||||
_searchCommand: true,
|
_unpauseCommand: true,
|
||||||
_statsCommand: true,
|
_searchCommand: true,
|
||||||
_stopCommand: true,
|
_statsCommand: true,
|
||||||
_topCommand: true,
|
_stopCommand: true,
|
||||||
|
_topCommand: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
|
@ -2,9 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||||
"github.com/containers/libpod/pkg/adapter"
|
"github.com/containers/libpod/pkg/adapter"
|
||||||
|
"github.com/containers/libpod/pkg/rootless"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -46,12 +48,24 @@ func init() {
|
|||||||
|
|
||||||
func podRestartCmd(c *cliconfig.PodRestartValues) error {
|
func podRestartCmd(c *cliconfig.PodRestartValues) error {
|
||||||
var lastError error
|
var lastError error
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
rootless.SetSkipStorageSetup(true)
|
||||||
|
}
|
||||||
runtime, err := adapter.GetRuntime(&c.PodmanCommand)
|
runtime, err := adapter.GetRuntime(&c.PodmanCommand)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not get runtime")
|
return errors.Wrapf(err, "could not get runtime")
|
||||||
}
|
}
|
||||||
defer runtime.Shutdown(false)
|
defer runtime.Shutdown(false)
|
||||||
|
|
||||||
|
if rootless.IsRootless() {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
c.InputArgs, c.All, c.Latest, err = joinPodNS(runtime, c.All, c.Latest, c.InputArgs)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
restartIDs, conErrors, restartErrors := runtime.RestartPods(getContext(), c)
|
restartIDs, conErrors, restartErrors := runtime.RestartPods(getContext(), c)
|
||||||
|
|
||||||
for _, p := range restartIDs {
|
for _, p := range restartIDs {
|
||||||
|
Reference in New Issue
Block a user