Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASMCMS-8965: Update sessions controller to provide error responses consistently and correctly #430

Merged
merged 8 commits into from
Feb 7, 2025

Conversation

mharding-hpe
Copy link
Contributor

@mharding-hpe mharding-hpe commented Feb 5, 2025

CAST-35696 was opened because when creating a BOS session with the CLI, if a nonexistent template name is specified, the error is less than informative:

ncn-m001:~/mitch # cray bos v2 sessions create --template-name jason-sollom-forever --operation reboot
Usage: cray bos v2 sessions create [OPTIONS]
Try 'cray bos v2 sessions create -h' for help.

Error: Error received from server: 400 Bad Request

Now, this is not a case of the BOS server code not providing more details. You can see this if you run the same command with the verbose option (I've truncated the output to highlight the error details):

ncn-m001:~/mitch # cray bos v2 sessions create --template-name jason-sollom-forever --operation reboot -vvv
[...]
ERROR: "Session Template Name invalid: jason-sollom-forever"
[...]
Error: Error received from server: 400 Bad Request

The root cause here is another case of BOS not following its own API spec. Per the API spec, this endpoint should be returning a ProblemDetails object, which the CLI then knows how to parse and decode. However, in a couple of cases, this endpoint instead just returns a plain string (along with the 400 status). This is why the CLI is not properly presenting the response.

This PR modifies the sessions controller, creating a few helper functions to ensure that every endpoint returns the correct (per the API) responses, and does some minor tidying/clarifications in the API spec. This PR also removes the no-longer-used MultitenancyNotSupported problem details.

On mug, with the updated BOS applied, you can see that the CLI now provides the error message even in non-verbose mode:

ncn-m001:~/mitch # cray bos v2 sessions create --template-name jason-sollom-forever --operation reboot
Usage: cray bos v2 sessions create [OPTIONS]
Try 'cray bos v2 sessions create -h' for help.

Error: Bad Request: Session Template Name invalid: jason-sollom-forever
ncn-m001:~/mitch #

I deliberately made this PR against the development branch for CASMCMS-9265, because this uses some of the imports added with that PR, and this made it less messy.

@mharding-hpe mharding-hpe merged commit eba4e21 into casmcms-9265 Feb 7, 2025
3 checks passed
@mharding-hpe mharding-hpe deleted the casmcms-8965 branch February 7, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants