outposts: handle k8s 422 response code by recreating objects
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
98a56c77e3
commit
92d38f62b5
|
@ -70,6 +70,17 @@ class KubernetesObjectReconciler(Generic[T]):
|
||||||
raise exc
|
raise exc
|
||||||
else:
|
else:
|
||||||
self.reconcile(current, reference)
|
self.reconcile(current, reference)
|
||||||
|
except NeedsUpdate:
|
||||||
|
try:
|
||||||
|
self.update(current, reference)
|
||||||
|
self.logger.debug("Updating")
|
||||||
|
except (OpenApiException, HTTPError) as exc:
|
||||||
|
# pylint: disable=no-member
|
||||||
|
if isinstance(exc, ApiException) and exc.status == 422:
|
||||||
|
self.logger.debug("Failed to update current, triggering re-create")
|
||||||
|
raise NeedsRecreate from exc
|
||||||
|
self.logger.debug("Other unhandled error", exc=exc)
|
||||||
|
raise exc
|
||||||
except NeedsRecreate:
|
except NeedsRecreate:
|
||||||
self.logger.debug("Recreate requested")
|
self.logger.debug("Recreate requested")
|
||||||
if current:
|
if current:
|
||||||
|
@ -79,9 +90,6 @@ class KubernetesObjectReconciler(Generic[T]):
|
||||||
self.logger.debug("No old found, creating")
|
self.logger.debug("No old found, creating")
|
||||||
self.logger.debug("Creating")
|
self.logger.debug("Creating")
|
||||||
self.create(reference)
|
self.create(reference)
|
||||||
except NeedsUpdate:
|
|
||||||
self.logger.debug("Updating")
|
|
||||||
self.update(current, reference)
|
|
||||||
else:
|
else:
|
||||||
self.logger.debug("Object is up-to-date.")
|
self.logger.debug("Object is up-to-date.")
|
||||||
|
|
||||||
|
|
Reference in New Issue