From 652b30b77333b0f5d46f8b3ef43f0a6512adb200 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 21 Jun 2022 12:16:30 +0100 Subject: [PATCH 1/2] Bug 2097728: Don't fail on server delete returning HTTP 404 If a server create request to nova fails particularly early in the process, it might never actually result in a server resource being created. This means attempts to delete the server will result in a HTTP 404. This is fine. The server is already gone so there's no reason we can't simply ignore the error. Signed-off-by: Stephen Finucane --- pkg/cloud/openstack/clients/machineservice.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/cloud/openstack/clients/machineservice.go b/pkg/cloud/openstack/clients/machineservice.go index 9c919ac0ac..541d26639b 100644 --- a/pkg/cloud/openstack/clients/machineservice.go +++ b/pkg/cloud/openstack/clients/machineservice.go @@ -1065,7 +1065,18 @@ func (is *InstanceService) InstanceDelete(id string) error { } // delete instance - return servers.Delete(is.computeClient, id).ExtractErr() + err = servers.Delete(is.computeClient, id).ExtractErr() + + // we don't report HTTP 404 since that's okay - the server is gone already + if err != nil { + if httpStatus, ok := err.(gophercloud.ErrDefault404); ok { + if httpStatus.Actual == 404 { + klog.Warningf("Couldn't find instance %v to delete: %v", id, err) + return nil + } + } + } + return err } func GetTrunkSupport(is *InstanceService) (bool, error) { From eb249b03019c05a6b43b4658f72b0af7a088323b Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 21 Jun 2022 15:15:06 +0100 Subject: [PATCH 2/2] Lower logging level No need for this to be a warning as we've already determined it's okay to ignore. Signed-off-by: Stephen Finucane --- pkg/cloud/openstack/clients/machineservice.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cloud/openstack/clients/machineservice.go b/pkg/cloud/openstack/clients/machineservice.go index 541d26639b..8b7d721f26 100644 --- a/pkg/cloud/openstack/clients/machineservice.go +++ b/pkg/cloud/openstack/clients/machineservice.go @@ -1071,7 +1071,7 @@ func (is *InstanceService) InstanceDelete(id string) error { if err != nil { if httpStatus, ok := err.(gophercloud.ErrDefault404); ok { if httpStatus.Actual == 404 { - klog.Warningf("Couldn't find instance %v to delete: %v", id, err) + klog.Infof("Couldn't find instance %v to delete: %v", id, err) return nil } }