Where an error occurs in creating request.objects, if it was a client side validation error, rather than server side Kubernetes error, then the exception would not be caught and a message as to why failure occurred not recorded in the status of the WorkshopAllocation resource. The status would also not be updated to failed. Rather than catch only Kubernetes exceptions, all exceptions should be caught.
try:
object_name = object_body["metadata"]["name"]
object_namespace = object_body["metadata"]["namespace"]
object_type = object_body["kind"]
logger.debug(
"Creating workshop request object %s of type %s in namespace %s for session %s.",
object_name,
object_type,
object_namespace,
session_name,
)
create_from_dict(object_body)
except Exception as exc:
logger.exception(
"Unable to create workshop request objects for session, failed on creating workshop request object %s of type %s in namespace %s for session %s.",
object_name,
object_type,
object_namespace,
session_name,
)
patch["status"] = {
OPERATOR_STATUS_KEY: {
"phase": "Failed",
"message": f"Unable to create workshop request objects for session, failed on creating workshop request object {object_name} of type {object_type} in namespace {object_namespace} for session {session_name}.",
}
}
raise kopf.PermanentError(
f"Unable to create workshop request objects for session, failed on creating workshop request object {object_name} of type {object_type} in namespace {object_namespace} for session {session_name}."
) from exc
Describe the bug
Where an error occurs in creating request.objects, if it was a client side validation error, rather than server side Kubernetes error, then the exception would not be caught and a message as to why failure occurred not recorded in the status of the WorkshopAllocation resource. The status would also not be updated to failed. Rather than catch only Kubernetes exceptions, all exceptions should be caught.
Additional information
No response