-
Notifications
You must be signed in to change notification settings - Fork 580
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
CreateObjectHandler: Fix ignore_on_error api flag doesn't work properly #8819
CreateObjectHandler: Fix ignore_on_error api flag doesn't work properly #8819
Conversation
Before: curl -k -s -u root:icinga -H 'Accept: application/json' \
-X PUT 'https://localhost:5665/v1/objects/hosts/example' \
-d '{ "attrs": { "address": "192.168.1.1", "vars.os" : "Linux" }, "ignore_on_error": true, "pretty": true }' {
"results": [
{
"code": 500,
"errors": [
"Error: Validation failed for object 'example' of type 'Host'; Attribute 'check_command': Attribute must not be empty.\nLocation: in /Users/yhabteab/Workspace/icinga2/prefix/var/lib/icinga2/api/packages/_api/ca7c22f6-3eed-426c-bd2e-04b9cf04c267/conf.d/hosts/example.conf: 1:0-1:32"
],
"status": "Object could not be created."
}
]
} After: {
"results": [
{
"code": 200,
"status": "Object was not created but 'ignore_on_error' was set to true."
}
]
} |
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.
Seems quite logical to me and the code below confirms this.
Apropos: couldn’t you just fix the condition instead of duplicating the mentioned code?
3e93a6d
to
8a5ebbb
Compare
The API ``ignore_on_error`` flag doesn't quite work yet, as it should. For example, if you don't set the ``command`` attribute when creating a host object via API, the action will fail during config validation and it won't even go out from the ``ConfigObjectUtility::CreateObject()`` method. After that internal server error is sent, even though you have set the flag.
8a5ebbb
to
b0cd962
Compare
Have you re-tested it (all cases)? |
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.
Given the description of #8820, it sound like this PR would introduce a crash. This has to be investigated/fixed before we can merge this. (Posting this "request changes" review so that it's not forgotten.)
Exactly, so Blocked by |
Can't reproduce this with the current master (dd7009d): $ curl -i -k -s -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/hosts/example' -d '{ "attrs": { "address": "192.168.1.1", "vars.os" : "Linux" }, "ignore_on_error": true, "pretty": true }'
HTTP/1.1 200 OK
Server: Icinga/v2.13.0-458-gdd7009dc6
Content-Type: application/json
Content-Length: 157
{
"results": [
{
"code": 200,
"status": "Object was not created but 'ignore_on_error' was set to true"
}
]
} Also, with your PR rebased onto the current master, the following happens:
I find the documentation for the To be honest, I don't see many use cases for this flag where you actually want that behavior rather than just ignore error responses. So another option would be to make the documentation more clear on what this parameter actually does. |
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.
Works for me as well, why exactly do we still need this?
Fixed by #9406 implicitly. |
The API
ignore_on_error
flag doesn't quite work yet, as it should. For example, if you don't set thecheck_command
attribute when creating a host object via API, the action will fail during config validation and it won't even go out from theConfigObjectUtility::CreateObject()
method. After that internal server error is sent, even though you have set the flag.