mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
Merge pull request #5984 from baude/v2intrestart
enable integration tests for restart
This commit is contained in:
@ -217,12 +217,23 @@ func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []strin
|
|||||||
}
|
}
|
||||||
func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []string, options entities.RestartOptions) ([]*entities.RestartReport, error) {
|
func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []string, options entities.RestartOptions) ([]*entities.RestartReport, error) {
|
||||||
var (
|
var (
|
||||||
|
ctrs []*libpod.Container
|
||||||
|
err error
|
||||||
reports []*entities.RestartReport
|
reports []*entities.RestartReport
|
||||||
)
|
)
|
||||||
ctrs, err := getContainersByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
|
||||||
if err != nil {
|
if options.Running {
|
||||||
return nil, err
|
ctrs, err = ic.Libpod.GetRunningContainers()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ctrs, err = getContainersByContext(options.All, options.Latest, namesOrIds, ic.Libpod)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, con := range ctrs {
|
for _, con := range ctrs {
|
||||||
timeout := con.StopTimeout()
|
timeout := con.StopTimeout()
|
||||||
if options.Timeout != nil {
|
if options.Timeout != nil {
|
||||||
|
@ -115,11 +115,15 @@ func (ic *ContainerEngine) ContainerRestart(ctx context.Context, namesOrIds []st
|
|||||||
t := int(*options.Timeout)
|
t := int(*options.Timeout)
|
||||||
timeout = &t
|
timeout = &t
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
|
ctrs, err := getContainersByContext(ic.ClientCxt, options.All, namesOrIds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
|
if options.Running && c.State != define.ContainerStateRunning.String() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
reports = append(reports, &entities.RestartReport{
|
reports = append(reports, &entities.RestartReport{
|
||||||
Id: c.ID,
|
Id: c.ID,
|
||||||
Err: containers.Restart(ic.ClientCxt, c.ID, timeout),
|
Err: containers.Restart(ic.ClientCxt, c.ID, timeout),
|
||||||
|
@ -17,7 +17,6 @@ var _ = Describe("Podman restart", func() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
Skip(v2fail)
|
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Reference in New Issue
Block a user