Closed oxzi closed 2 months ago
- Version used (
icinga2 --version
): Icinga DB: Support Redis username authentication #10102 which is a bit ahead ofmaster
GitHub says otherwise :-)!
Damn. I tried searching for other issues, but failed to find any. Next time, I rebase first, but honestly, I haven't expected a fix in the meantime.
Edit: Verified that the bug was resolved after rebasing.
Describe the bug
After a failed attempt to create some Object via the Icinga 2 API due to a validation exception, the chosen Object name is blocked and Icinga 2 aborts further attempts as they are re-creations. Please take a look at the To Reproduce section below, which should make it more obvious.
I stumbled about this issue while debugging changes for #10102, where I wanted to verify my Validate methods via the Icinga 2 API.
To Reproduce
To make sure that this has nothing to do with my code, my example uses
TimePeriod
and its validation method.https://github.com/Icinga/icinga2/blob/e678f0977d54bd57cec5ab6d79d100410256c188/lib/icinga/timeperiod.cpp#L373
TimePeriod
Object named "oops" with invalidranges
values, resulting inTimePeriod::ValidateRanges
to throw an exception. ``` $ curl -k -s -S -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/timeperiods/oops' -d '{"attrs": {"ranges": {"F": "F"}}, "pretty": true}' { "results": [ { "code": 500, "errors": [ "Error: Validation failed for object 'oops' of type 'TimePeriod'; Attribute 'ranges': Invalid time specification 'F': Invalid time specification: F\nLocation: in /var/lib/icinga2/api/packages/_api/8e2362bd-b6a8-415d-85fe-33074907fcd8/conf.d/timeperiods/oops.conf: 2:2-4:2" ], "status": "Object could not be created." } ] } ```TimePeriod
Object named "oops":TimePeriod
: ``` $ curl -k -s -S -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/timeperiods/oops' -d '{"attrs": {"ranges": {"F": "F"}}, "pretty": true}' { "results": [ { "code": 500, "errors": [ "Error: Object 'oops' of type 'TimePeriod' re-defined: in /var/lib/icinga2/api/packages/_api/8e2362bd-b6a8-415d-85fe-33074907fcd8/conf.d/timeperiods/oops.conf: 1:0-1:23; previous definition: in /var/lib/icinga2/api/packages/_api/8e2362bd-b6a8-415d-85fe-33074907fcd8/conf.d/timeperiods/oops.conf: 1:0-1:23\nLocation: in /var/lib/icinga2/api/packages/_api/8e2362bd-b6a8-415d-85fe-33074907fcd8/conf.d/timeperiods/oops.conf: 1:0-1:23" ], "status": "Object could not be created." } ] } ```TimePeriod
: ``` $ curl -k -s -S -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/timeperiods/oops' -d '{"attrs": {"ranges": {"2025-05-25": "00:00-24:00"}}, "pretty": true}' { "results": [ { "code": 500, "errors": [ "Error: Object 'oops' of type 'TimePeriod' re-defined: in /var/lib/icinga2/api/packages/_api/8e2362bd-b6a8-415d-85fe-33074907fcd8/conf.d/timeperiods/oops.conf: 1:0-1:23; previous definition: in /var/lib/icinga2/api/packages/_api/8e2362bd-b6a8-415d-85fe-33074907fcd8/conf.d/timeperiods/oops.conf: 1:0-1:23\nLocation: in /var/lib/icinga2/api/packages/_api/8e2362bd-b6a8-415d-85fe-33074907fcd8/conf.d/timeperiods/oops.conf: 1:0-1:23" ], "status": "Object could not be created." } ] } ```On further inspection, the referenced file in the re-definition error does not exist. There is even no mention of such an object.
Btw, I am also unable to delete it via the API:
A specter is haunting Icinga 2 - the specter of
TimePeriod
.Expected behavior
If Icinga 2 states that an "Object could not be created", one should be able to retry with the same name.
Screenshots
N/A
Your Environment
Include as many relevant details about the environment you experienced the problem in
icinga2 --version
): #10102 which is a bit ahead ofmaster
icinga2 feature list
): api checker icingadb ido-mysql ido-pgsql notificationicinga2 daemon -C
): :ballot_box_with_check:zones.conf
file (oricinga2 object list --type Endpoint
andicinga2 object list --type Zone
) from all affected nodes.Additional context
N/A