diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-05-18 09:39:30 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-18 09:39:30 -0400 |
commit | 12964c7b93457a05441db081270a51083a1398f4 (patch) | |
tree | 3d8065963efc0f004547ff4a4dc4cee96b4fb2f9 /libpod/runtime_ctr.go | |
parent | 9915b8f599da2f179c8dd1bff7951141a7bdaa1b (diff) | |
parent | 8684d41e387ae40cc64cd513bbc3f7ac319360f4 (diff) | |
download | podman-12964c7b93457a05441db081270a51083a1398f4.tar.gz podman-12964c7b93457a05441db081270a51083a1398f4.tar.bz2 podman-12964c7b93457a05441db081270a51083a1398f4.zip |
Merge pull request #14256 from vrothberg/run-1287
k8systemd: run k8s workloads in systemd
Diffstat (limited to 'libpod/runtime_ctr.go')
-rw-r--r-- | libpod/runtime_ctr.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 7e8a21a8c..2eaa77572 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -644,6 +644,16 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo return err } + if c.IsService() { + canStop, err := c.canStopServiceContainer() + if err != nil { + return err + } + if !canStop { + return fmt.Errorf("container %s is the service container of pod(s) %s and cannot be removed without removing the pod(s)", c.ID(), strings.Join(c.state.Service.Pods, ",")) + } + } + // If we're not force-removing, we need to check if we're in a good // state to remove. if !force { @@ -907,6 +917,16 @@ func (r *Runtime) evictContainer(ctx context.Context, idOrName string, removeVol } } + if c.IsService() { + canStop, err := c.canStopServiceContainer() + if err != nil { + return id, err + } + if !canStop { + return id, fmt.Errorf("container %s is the service container of pod(s) %s and cannot be removed without removing the pod(s)", c.ID(), strings.Join(c.state.Service.Pods, ",")) + } + } + var cleanupErr error // Remove the container from the state if c.config.Pod != "" { |