Skip to content

Commit

Permalink
Merge pull request #209 from aau-claaudia/BetterCreateFailedMessages
Browse files Browse the repository at this point in the history
Change error message when openstack failed to get volume
  • Loading branch information
frixdk authored May 30, 2024
2 parents 46a3417 + 48eb48a commit fcda01c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ to test the provider API.

For the manual insertion endpoint there is an example [here](src/test/resources/requests/temp-job-request-example.json).

## Athentication and Authorization
## Authentication and Authorization

UCloud and the provider
This is handled by UClouds provider integration module: [Jvm-Provider-Support](https://github.com/SDU-eScience/UCloud/tree/master/backend/jvm-provider-support)
Expand Down
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,10 +507,22 @@ 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 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,
MessageFormat.format(messages.jobs.createFailed, message)
MessageFormat.format(messages.jobs.createFailed, jobMessage)
)
}

Expand Down

0 comments on commit fcda01c

Please sign in to comment.