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

Don't fail to remove obsolete downtimes #10062

Merged
merged 3 commits into from
May 29, 2024

Conversation

yhabteab
Copy link
Member

@yhabteab yhabteab commented May 15, 2024

Before

See #10042

After

  • Deleting downtimes automatically due to owner config hash change.
[2024-05-15 16:52:17 +0200] information/ConfigObjectUtility: Deleted object 'downtime-test!39752e43-ffb6-40ee-8d17-c129a1b2f7c6' of type 'Downtime'.
[2024-05-15 16:52:17 +0200] information/Downtime: Removed downtime 'downtime-test!39752e43-ffb6-40ee-8d17-c129a1b2f7c6' from checkable 'downtime-test' (Reason: cancelled by 'downtime-test!backup-downtime').
  • Deleting a downtime that belongs to a ScheduledDowntime object via the API
 curl -k -s -S -i -u root:icinga -H 'Accept: application/json' \
 -X POST 'https://localhost:5665/v1/actions/remove-downtime' \
 -d '{ "downtime": "downtime-test!baa2338e-34b0-44a1-94fa-c24f9b1f2b0a", "pretty": true }'

–––
HTTP/1.1 400 Bad Request
Server: Icinga/v2.14.0-175-g81aec894c
Content-Type: application/json
Content-Length: 246

{
    "results": [
        {
            "code": 400,
            "status": "Cannot remove downtime 'downtime-test!baa2338e-34b0-44a1-94fa-c24f9b1f2b0a'. It is owned by scheduled downtime object 'downtime-test!backup-downtime'"
        }
    ]
}

fixes #10042

@yhabteab yhabteab requested a review from Al2Klimov May 15, 2024 15:15
@cla-bot cla-bot bot added the cla/signed label May 15, 2024
@icinga-probot icinga-probot bot added area/runtime Downtimes, comments, dependencies, events bug Something isn't working ref/IP labels May 15, 2024
@yhabteab yhabteab added the consider backporting Should be considered for inclusion in a bugfix release label May 15, 2024
@yhabteab yhabteab added this to the 2.15.0 milestone May 15, 2024
lib/icinga/scheduleddowntime.cpp Outdated Show resolved Hide resolved
lib/icinga/downtime.cpp Outdated Show resolved Hide resolved
lib/icinga/downtime.cpp Outdated Show resolved Hide resolved
@yhabteab yhabteab force-pushed the do-not-fail-removing-obsolete-downtimes branch from 81aec89 to 438aa6d Compare May 16, 2024 10:20
@yhabteab
Copy link
Member Author

Before

[2024-05-16 12:17:00 +0200] debug/ApiListener: Sent update for object 'downtime-test!99532ab9-66fd-4625-881c-1e71acfc3dab': {"config":"object Downtime \"99532ab9-66fd-4625-881c-1e71acfc3dab\" ignore_on_error {\n\tauthor = \"icingaadmin\"\n\tauthoritative_zone = \"master\"\n\tcomment = \"Scheduled downtime by me\"\n\tconfig_owner = \"downtime-test!backup-downtime\"\n\tconfig_owner_hash = \"f15ba79d61f3f10cc45e03469760c8609a808e752b691dcfd798551ba8069091\"\n\tduration = 7200.000000\n\tend_time = 1716220800.000000\n\tentry_time = 1715854620.401736\n\tfixed = true\n\thost_name = \"downtime-test\"\n\tparent = \"\"\n\tscheduled_by = \"downtime-test!backup-downtime\"\n\tstart_time = 1716202800.000000\n\ttriggered_by = \"\"\n\tversion = 1715854620.401923\n\tzone = \"master\"\n}\n","modified_attributes":{},"name":"downtime-test!99532ab9-66fd-4625-881c-1e71acfc3dab","original_attributes":[],"type":"Downtime","version":1715854620.401923,"zone":"master"}
[2024-05-16 12:17:00 +0200] information/ConfigObjectUtility: Created and activated object 'downtime-test!99532ab9-66fd-4625-881c-1e71acfc3dab' of type 'Downtime'.
[2024-05-16 12:17:00 +0200] notice/ApiListener: Relaying 'config::UpdateObject' message
[2024-05-16 12:17:00 +0200] notice/WorkQueue: Stopped WorkQueue threads for 'ConfigObjectUtility::CreateObject'
[2024-05-16 12:17:00 +0200] information/Downtime: Added downtime 'downtime-test!99532ab9-66fd-4625-881c-1e71acfc3dab' between '2024-05-20 13:00:00' and '2024-05-20 18:00:00', author: 'icingaadmin', fixed
[2024-05-16 12:17:00 +0200] critical/ScheduledDowntime: Exception occurred during removal of obsolete downtime for scheduled downtime 'downtime-test!backup-downtime': Error: Cannot remove downtime 'downtime-test!baa2338e-34b0-44a1-94fa-c24f9b1f2b0a'. It is owned by scheduled downtime object 'downtime-test!backup-downtime'

After

[2024-05-16 12:19:53 +0200] debug/ApiListener: Sent delete for object 'downtime-test!99532ab9-66fd-4625-881c-1e71acfc3dab': {"name":"downtime-test!99532ab9-66fd-4625-881c-1e71acfc3dab","type":"Downtime","version":1715854620.401923}
[2024-05-16 12:19:53 +0200] information/ConfigObjectUtility: Deleted object 'downtime-test!99532ab9-66fd-4625-881c-1e71acfc3dab' of type 'Downtime'.
[2024-05-16 12:19:53 +0200] information/Downtime: Removed downtime 'downtime-test!99532ab9-66fd-4625-881c-1e71acfc3dab' from checkable 'downtime-test' (Reason: cancelled by 'downtime-test!backup-downtime' of type 'ScheduledDowntime').
[2024-05-16 12:19:53 +0200] debug/ApiListener: Sent delete for object 'downtime-test!baa2338e-34b0-44a1-94fa-c24f9b1f2b0a': {"name":"downtime-test!baa2338e-34b0-44a1-94fa-c24f9b1f2b0a","type":"Downtime","version":1715785930.19472}
[2024-05-16 12:19:53 +0200] information/ConfigObjectUtility: Deleted object 'downtime-test!baa2338e-34b0-44a1-94fa-c24f9b1f2b0a' of type 'Downtime'.
[2024-05-16 12:19:53 +0200] information/Downtime: Removed downtime 'downtime-test!baa2338e-34b0-44a1-94fa-c24f9b1f2b0a' from checkable 'downtime-test' (Reason: cancelled by 'downtime-test!backup-downtime' of type 'ScheduledDowntime').

@yhabteab yhabteab requested a review from Al2Klimov May 16, 2024 10:23
lib/icinga/downtime.hpp Outdated Show resolved Hide resolved
lib/icinga/downtime.cpp Outdated Show resolved Hide resolved
lib/icinga/checkable-downtime.cpp Outdated Show resolved Hide resolved
@yhabteab yhabteab force-pushed the do-not-fail-removing-obsolete-downtimes branch from 438aa6d to f9ae1d5 Compare May 21, 2024 15:37
@yhabteab yhabteab requested a review from Al2Klimov May 21, 2024 15:37
lib/icinga/downtime.cpp Outdated Show resolved Hide resolved
@yhabteab yhabteab force-pushed the do-not-fail-removing-obsolete-downtimes branch from f9ae1d5 to f4256eb Compare May 22, 2024 12:56
@yhabteab yhabteab requested a review from Al2Klimov May 22, 2024 12:56
Al2Klimov
Al2Klimov previously approved these changes May 22, 2024
@yhabteab
Copy link
Member Author

Sorry! I had to revert a change from feeeded because the origin for the removed child downtimes should be the current endpoint and not some other passed ones.

@Al2Klimov
Copy link
Member

And why exactly?

@yhabteab
Copy link
Member Author

yhabteab commented May 22, 2024

And why exactly?

Because the object deletion event for these child downtimes is will initially be triggered on the current endpoint, and their deletion event should also be synchronised to the sender of the deletion event of the parent downtime.

if (cancelled) {
downtime->SetRemovalInfo(removedBy, Utility::GetTime());
if (removalReason != DowntimeExpired) {
downtime->SetRemovalInfo(removedBy, Utility::GetTime(), origin);
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we omit ALL the origin passthrough additions for now and discuss them separately?

Copy link
Member Author

Choose a reason for hiding this comment

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

No problem! Downtime::RemoveDowntime() is never called from outside with the origin param set anyway, so I am wondering why it was introduced in the first place.

@yhabteab yhabteab force-pushed the do-not-fail-removing-obsolete-downtimes branch from c0e458b to 81a94a0 Compare May 23, 2024 08:09
@yhabteab yhabteab requested a review from Al2Klimov May 23, 2024 08:10
@Al2Klimov Al2Klimov merged commit 58e1718 into master May 29, 2024
26 checks passed
@Al2Klimov Al2Klimov deleted the do-not-fail-removing-obsolete-downtimes branch May 29, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/runtime Downtimes, comments, dependencies, events bug Something isn't working cla/signed consider backporting Should be considered for inclusion in a bugfix release ref/IP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scheduled Downtime won't be changed/deleted after reload
2 participants