Skip to content

Commit

Permalink
Multiple messages. Log openstack reason
Browse files Browse the repository at this point in the history
  • Loading branch information
frixdk committed May 23, 2024
1 parent 15fb6d7 commit 48eb48a
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ class OpenStackService(
return
}
if (stack != null && stack.status == StackStatus.CREATE_FAILED.name) {
logger.error("Stack create failed status: ${stack.status} stackId: ${stack.id} stackName: ${stack.name}")
logger.error("Stack create failed status: ${stack.status} stackId: ${stack.id} stackName: ${stack.name} Reason: ${stack.stackStatusReason}")
sendJobFailedMessage(job.id, "Job failed. Reason: ${stack.stackStatusReason}")
return
}
Expand All @@ -507,13 +507,18 @@ class OpenStackService(
* A shortcut function for sending job failed update message
*/
fun sendJobFailedMessage(jobId: String, message: String) {
// Try to identify lack of resources and change message
val jobMessage: String = if ("failed to get volume" in message.lowercase()) {
// Try to identify lack of resources and change to user-friendly message
val resourceErrorMsgs = listOf(
"failed to get volume",
"no valid host was found"
)
val jobMessage: String = if (resourceErrorMsgs.any { it in message.lowercase() }) {
"Unfortunately all available resources have been allocated for the product type you have selected. " +
"The options available are to use an alternative machine size or product, or to try again later."
} else {
message
}

sendJobStatusMessage(
jobId,
JobState.FAILURE,
Expand Down

0 comments on commit 48eb48a

Please sign in to comment.