From d178a0d96ba767b9fe7ebe498a78871ba74bbee3 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 9 May 2020 17:16:41 -0700 Subject: [PATCH] Don't fail deletion if container doesn't exist; closes pterodactyl/panel#2001 --- server/environment_docker.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/server/environment_docker.go b/server/environment_docker.go index e6fee97..b4b6485 100644 --- a/server/environment_docker.go +++ b/server/environment_docker.go @@ -343,11 +343,21 @@ func (d *DockerEnvironment) Destroy() error { // Avoid crash detection firing off. d.Server.SetState(ProcessStoppingState) - return d.Client.ContainerRemove(ctx, d.Server.Uuid, types.ContainerRemoveOptions{ + err := d.Client.ContainerRemove(ctx, d.Server.Uuid, types.ContainerRemoveOptions{ RemoveVolumes: true, RemoveLinks: false, Force: true, }) + + // Don't trigger a destroy failure if we try to delete a container that does not + // exist on the system. We're just a step ahead of ourselves in that case. + // + // @see https://github.com/pterodactyl/panel/issues/2001 + if err != nil && client.IsErrNotFound(err) { + return nil + } + + return err } // Determine the container exit state and return the exit code and wether or not