Merge pull request #17077 from mheon/set_stopping_early
Set StoppedByUser earlier in the process of stopping
This commit is contained in:
		
						commit
						3e229b0bd5
					
				|  | @ -1296,6 +1296,7 @@ func (c *Container) stop(timeout uint) error { | |||
| 	// demonstrates nicely that a high stop timeout will block even simple
 | ||||
| 	// commands such as `podman ps` from progressing if the container lock
 | ||||
| 	// is held when busy-waiting for the container to be stopped.
 | ||||
| 	c.state.StoppedByUser = true | ||||
| 	c.state.State = define.ContainerStateStopping | ||||
| 	if err := c.save(); err != nil { | ||||
| 		return fmt.Errorf("saving container %s state before stopping: %w", c.ID(), err) | ||||
|  | @ -1343,7 +1344,6 @@ func (c *Container) stop(timeout uint) error { | |||
| 	} | ||||
| 
 | ||||
| 	c.newContainerEvent(events.Stop) | ||||
| 	c.state.StoppedByUser = true | ||||
| 	return c.waitForConmonToExitAndSave() | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1407,6 +1407,22 @@ USER mail`, BB) | |||
| 		Expect(found).To(BeTrue()) | ||||
| 	}) | ||||
| 
 | ||||
| 	It("podman run with restart policy does not restart on manual stop", func() { | ||||
| 		ctrName := "testCtr" | ||||
| 		ctr := podmanTest.Podman([]string{"run", "-dt", "--restart=always", "--name", ctrName, ALPINE, "top"}) | ||||
| 		ctr.WaitWithDefaultTimeout() | ||||
| 		Expect(ctr).Should(Exit(0)) | ||||
| 
 | ||||
| 		stop := podmanTest.Podman([]string{"stop", ctrName}) | ||||
| 		stop.WaitWithDefaultTimeout() | ||||
| 		Expect(stop).Should(Exit(0)) | ||||
| 
 | ||||
| 		// This is ugly, but I don't see a better way
 | ||||
| 		time.Sleep(10 * time.Second) | ||||
| 
 | ||||
| 		Expect(podmanTest.NumberOfContainersRunning()).To(Equal(0)) | ||||
| 	}) | ||||
| 
 | ||||
| 	It("podman run with cgroups=split", func() { | ||||
| 		SkipIfNotSystemd(podmanTest.CgroupManager, "do not test --cgroups=split if not running on systemd") | ||||
| 		SkipIfRootlessCgroupsV1("Disable cgroups not supported on cgroupv1 for rootless users") | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue