From 87a4c45446ff0cd60b8af4da77e9badda378eba4 Mon Sep 17 00:00:00 2001 From: Zhou Hao Date: Tue, 19 Apr 2022 13:12:58 +0800 Subject: [PATCH] Increase the handling of 409 errors when node creation fails When creating a node with a 409 error, try again later. Signed-off-by: Zhou Hao --- pkg/provisioner/ironic/ironic.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/provisioner/ironic/ironic.go b/pkg/provisioner/ironic/ironic.go index 555057664c..2f2055d514 100644 --- a/pkg/provisioner/ironic/ironic.go +++ b/pkg/provisioner/ironic/ironic.go @@ -382,12 +382,17 @@ func (p *ironicProvisioner) ValidateManagementAccess(data provisioner.Management "capabilities": bootModeCapabilities[data.BootMode], }, }).Extract() - // FIXME(dhellmann): Handle 409 and 503? errors here. - if err != nil { + switch err.(type) { + case nil: + p.publisher("Registered", "Registered new host") + case gophercloud.ErrDefault409: + p.log.Info("could not register host in ironic, busy") + result, err = retryAfterDelay(provisionRequeueDelay) + return + default: result, err = transientError(errors.Wrap(err, "failed to register host in ironic")) return } - p.publisher("Registered", "Registered new host") // Store the ID so other methods can assume it is set and so // we can find the node again later.