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
Return correct status codes in process-check-result API #9354
Return correct status codes in process-check-result API #9354
Conversation
849ea23
to
de30ed5
Compare
70184b9
to
033bd4f
Compare
Hi @julianbrost ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't consider how long the names would get when moving the enum into the class. I suggest adding using Result = Checkable::ProcessingResult;
to ApiActions::ProcessCheckResult()
and Checkable::ProcessCheckResult()
and then using that alias to keep things a bit shorter.
033bd4f
to
f0e5d9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one tiny indentation mishap left to fix, then I'm happy with the PR.
f0e5d9c
to
9d9810b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit over-engineered, but better than the other way around.
@julianbrost Also see my OP edit.
…atus-in-process-check-result-api Return correct status codes in process-check-result API
Hi all!
This PR addresses the issue #9353.
fixes #9353
In the implementation we modified the
ProcessCheckResult
function in order to return an enum that describes the actual result of the function. In theApiActions::ProcessCheckResult
function we check the returned enum and create a result with an appropriate code and status message.Please let us know if you think other status codes can be more appropriate.
Below you find some curl request with which we can test the changes, in particular to check that the API returns an appropriate reply when we send a process-check-result with an older timestamp with respect to the last check result of the host.
Tests
Initial process-check-result:
curl -v -k -u root:<pwd> 'https://localhost:5665/v1/actions/process-check-result' -H 'accept: application/json' -XPOST -d '{"type": "Host", "host": "my-host", "exit_status": 1, "plugin_output": "initial pcr", "execution_start": "1650553018.000000", "execution_end": "1650553018.000000"}'
should return
{"results":[{"code":200.0,"status":"Successfully processed check result for object 'my-host'."}]}
Process-check-result with older
execution_start:
curl -v -k -u root:<pwd> 'https://localhost:5665/v1/actions/process-check-result' -H 'accept: application/json' -XPOST -d '{"type": "Host", "host": "my-host", "exit_status": 1, "plugin_output": "pcr with older timestamp", "execution_start": "1650553017.000000", "execution_end": "1650553017.000000"}'
should return:
{"results":[{"code":409.0,"status":"Newer check result already present. Check result for 'my-host' was discarded."}]}
Process-check-result with newer
execution_start
:curl -v -k -u root:<pwd> 'https://localhost:5665/v1/actions/process-check-result' -H 'accept: application/json' -XPOST -d '{"type": "Host", "host": "my-host", "exit_status": 1, "plugin_output": "pcr with newer timestamp", "execution_start": "1650553019.000000", "execution_end": "1650553019.000000"}'
should return:
{"results":[{"code":200.0,"status":"Successfully processed check result for object 'my-host'."}]}