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

apiserver: include error messages in error responses #897

Merged
merged 1 commit into from
Apr 8, 2020

Conversation

tjkirch
Copy link
Contributor

@tjkirch tjkirch commented Apr 8, 2020

Description of changes:

While checking #895 we had a hard time figuring out why early-boot-config was failing in the dev variant, and the error message showed the HTTP code but no error message from the server.

This change makes the apiserver include the error description in the message. (We don't include secrets in these messages, and you have to go through an authorized channel to make API calls at all.)

Testing done:

Before, no details after URI:

$ cargo run -- --socket-path /tmp/thar-api.sock -u '/settings?tx=foo' -X PATCH -d '{"xx": true}' -v -v -v
Status 400 when PATCHing unix://snip:0/settings?tx=foo: 
$ cargo run -- --socket-path /tmp/thar-api.sock -u '/tx/commit?tx=lkasjdkfl' -X POST  -v -v -v
Status 422 when POSTing unix://snip:0/tx/commit?tx=lkasjdkfl: 

After, error message after URI:

$ cargo run -- --socket-path /tmp/thar-api.sock -u '/settings?tx=foo' -X PATCH -d '{"xx": true}' -v -v -v
Status 400 when PATCHing unix://snip:0/settings?tx=foo: Json deserialize error: unknown field `xx`, expected one of `motd`, `kubernetes`, `updates`, `host-containers`, `ntp`, `aws` at line 1 column 5
$ cargo run -- --socket-path /tmp/thar-api.sock -u '/tx/commit?tx=lkasjdkfl' -X POST  -v -v -v
Status 422 when POSTing unix://snip:0/tx/commit?tx=lkasjdkfl: Tried to commit with no pending changes

Made an AMI, it connected to my cluster and ran a pod OK, connected and saw systemctl running and API OK.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@tjkirch tjkirch requested a review from etungsten April 8, 2020 21:09
Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍔

@tjkirch tjkirch merged commit a50b273 into bottlerocket-os:develop Apr 8, 2020
@tjkirch tjkirch deleted the api-error-rsp branch April 8, 2020 22:14
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.

3 participants