# Deleting Scheduled Downtime on parent host not deleting downtime on dependent child host

**URL:** <https://community.icinga.com/t/deleting-scheduled-downtime-on-parent-host-not-deleting-downtime-on-dependent-child-host/11533>\
**Category:** Icinga 2\
**Tags:** downtime, dependencies\
**Created:** [March 3, 2023, 7:00am UTC](https://community.icinga.com/t/deleting-scheduled-downtime-on-parent-host-not-deleting-downtime-on-dependent-child-host/11533 "2023-03-03T07:00:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomassuffel](https://community.icinga.com/user_avatar/community.icinga.com/thomassuffel/32/6507_2.png) [@thomassuffel](https://community.icinga.com/u/thomassuffel)\
**Post date:** [March 3, 2023, 7:00am UTC](https://community.icinga.com/t/deleting-scheduled-downtime-on-parent-host-not-deleting-downtime-on-dependent-child-host/11533/1 "2023-03-03T07:00:31Z")

</div>

Hello and good morning everybody,

I had successfully setup a parent \<-\> child dependency using dependency apply rules.

 ![Screenshot 2023-03-03 at 07.57.36](https://community.icinga.com/uploads/default/original/2X/e/e44f1ef50668696f7398f06b7ec35a872effedcb.png)

When I schedule a downtime on parent host with option “Schedule non-triggered downtime for all child hosts” the downtime is successfully propagated to the child host as expected.  
When I delete the scheduled downtime on the parent host the downtime on the child host stays active and is not deleted.

I just want to ask if this is “normal” behaviour or if I am missing something?

Thanks in advance and kind regards,  
Thomas

---

<div class="post-metadata">

**Author:** ![Al2Klimov](https://community.icinga.com/user_avatar/community.icinga.com/al2klimov/32/959_2.png) [@Al2Klimov](https://community.icinga.com/u/Al2Klimov)\
**Post date:** [March 23, 2023, 5:19pm UTC](https://community.icinga.com/t/deleting-scheduled-downtime-on-parent-host-not-deleting-downtime-on-dependent-child-host/11533/2 "2023-03-23T17:19:42Z")

</div>

Hello Thomas!

No, this is not the normal behaviour since v2.13.0:

> <https://github.com/Icinga/icinga2/pull/8913>
>
> This PR adds the attribute \`parent\` to the \`Downtime\` object. This allows us to …delete downtimes that have been created as child downtimes on a hosts services (using API parameter \`all\_services\`) while deleting the hosts downtime.
> 
> Attribute PR in Icinga DB (used for testing): https://github.com/Icinga/icingadb/pull/323
> 
> \## Testing
> 
> \### Config
> \`\`\`
> var serviceCount = 3
> 
> object Host "DowntimeTestHost" {
> check\_command = "dummy"
> }
> 
> for (s in range(serviceCount)) {
> object Service "DowntimeTestService-" + s {
> check\_command = "dummy"
> host\_name = "DowntimeTestHost"
> }
> }
> \`\`\`
> 
> \### Steps
> 
> 1. Schedule downtimes with \`all\_services\` option:
> \`\`\`
> curl -k -s -u root:icinga -H 'Accept: application/json' \\
> -X POST 'https://localhost:5665/v1/actions/schedule-downtime' \\
> -d '{ "type": "Host", "filter": "host.name==\\"DowntimeTestHost\\"", "start\_time": 1446388806, "end\_time": 1746389806, "author": "icingaadmin", "comment": "test", "pretty": true, "all\_services": true }'
> \`\`\`
> 2. Select all downtimes from Icinga DB database:
> \`\`\`
> mysql icingadb -e "select id, parent\_id, object\_type from downtime order by object\_type;"
> \`\`\`
> 3. Delete parent downtime:
> \`\`\`
> curl -k -s -u root:icinga -H 'Accept: application/json' \\
> -X POST 'https://localhost:5665/v1/actions/remove-downtime' \\
> -d '{ "downtime": "\<DOWNTIME-NAME\>", "pretty": true }'
> \`\`\`
> 4. Again select all downtimes from Icinga DB database to validate the removal of all services downtimes:
> \`\`\`
> mysql icingadb -e "select id, parent\_id, object\_type from downtime order by object\_type;"
> \`\`\`
> 
> \### Results
> 
> \#### Before
> 
> 1. Create downtimes
> \`\`\`
> \[noah@NoH-MB ~ \]$ curl -k -s -u root:icinga -H 'Accept: application/json' \\
> -X POST 'https://localhost:5665/v1/actions/schedule-downtime' \\
> -d '{ "type": "Host", "filter": "host.name==\\"DowntimeTestHost\\"", "start\_time": 1446388806, "end\_time": 1746389806, "author": "icingaadmin", "comment": "test", "pretty": true, "all\_services": true }'
> {
> "results": \[
> {
> "code": 200,
> "legacy\_id": 1,
> "name": "DowntimeTestHost!b6ad0a3b-7c8f-4a2c-968e-dc0e8fbda103",
> "service\_downtimes": \[
> {
> "legacy\_id": 2,
> "name": "DowntimeTestHost!DowntimeTestService-0!58a333db-13cf-43e4-9f8b-22f60d8b3c91"
> },
> {
> "legacy\_id": 3,
> "name": "DowntimeTestHost!DowntimeTestService-1!4dd12ad7-3b0d-49b4-b575-f81a09f694b1"
> },
> {
> "legacy\_id": 4,
> "name": "DowntimeTestHost!DowntimeTestService-2!fb172915-0ab9-44bf-92c2-232d41b18b0e"
> }
> \],
> "status": "Successfully scheduled downtime 'DowntimeTestHost!b6ad0a3b-7c8f-4a2c-968e-dc0e8fbda103' for object 'DowntimeTestHost'."
> }
> \]
> }
> \`\`\`
> 
> 2. Select from Icinga DB database
> \`\`\`
> \[noah@NoH-MB ~ \]$ mysql icingadb -e "select id, object\_type from downtime order by object\_type;"
> +--------------------------------------------+-------------+
> | id | object\_type |
> +--------------------------------------------+-------------+
> | 0x1498918DDF6288BCCAA8885C48950272915149ED | host |
> | 0x31CA087DCFAE8A312FF773B13923A2E314EB3685 | service |
> | 0x9A0426DBC927DC8E4188FE0DEB7344349DF2BC3E | service |
> | 0xE8427CECB1E2652403E73E8A52A9D40A41ADB32A | service |
> +--------------------------------------------+-------------+
> \`\`\`
> 
> 3. Remove parent downtime
> \`\`\`
> \[noah@NoH-MB ~ \]$ curl -k -s -u root:icinga -H 'Accept: application/json' \\
> -X POST 'https://localhost:5665/v1/actions/remove-downtime' \\
> -d '{ "downtime": "DowntimeTestHost!b6ad0a3b-7c8f-4a2c-968e-dc0e8fbda103", "pretty": true }'
> {
> "results": \[
> {
> "code": 200,
> "status": "Successfully removed downtime 'DowntimeTestHost!b6ad0a3b-7c8f-4a2c-968e-dc0e8fbda103'."
> }
> \]
> }
> \`\`\`
> 
> 4. Again select all services from Icinga DB database:
> \`\`\`
> \[noah@NoH-MB ~ \]$ mysql icingadb -e "select id, object\_type from downtime order by object\_type;"
> +--------------------------------------------+-------------+
> | id | object\_type |
> +--------------------------------------------+-------------+
> | 0x31CA087DCFAE8A312FF773B13923A2E314EB3685 | service |
> | 0x9A0426DBC927DC8E4188FE0DEB7344349DF2BC3E | service |
> | 0xE8427CECB1E2652403E73E8A52A9D40A41ADB32A | service |
> +--------------------------------------------+-------------+
> // Service downtimes are still there
> \`\`\`
> 
> \#### After
> 1. Create downtimes
> \`\`\`
> \[noah@NoH-MB ~ \]$ curl -k -s -u root:icinga -H 'Accept: application/json' \\
> -X POST 'https://localhost:5665/v1/actions/schedule-downtime' \\
> -d '{ "type": "Host", "filter": "host.name==\\"DowntimeTestHost\\"", "start\_time": 1446388806, "end\_time": 1746389806, "author": "icingaadmin", "comment": "test", "pretty": true, "all\_services": true }'
> {
> "results": \[
> {
> "code": 200,
> "legacy\_id": 1,
> "name": "DowntimeTestHost!e26a4f56-63cd-4388-8975-2db0d8fc8107",
> "service\_downtimes": \[
> {
> "legacy\_id": 2,
> "name": "DowntimeTestHost!DowntimeTestService-0!57b60fd9-4cb7-493a-b33d-ef892aacf7b8"
> },
> {
> "legacy\_id": 3,
> "name": "DowntimeTestHost!DowntimeTestService-1!d2e7793d-db42-40fa-88c2-6ab78f5c823e"
> },
> {
> "legacy\_id": 4,
> "name": "DowntimeTestHost!DowntimeTestService-2!72393c64-201d-407c-8bdc-396f1601ed0e"
> }
> \],
> "status": "Successfully scheduled downtime 'DowntimeTestHost!e26a4f56-63cd-4388-8975-2db0d8fc8107' for object 'DowntimeTestHost'."
> }
> \]
> }
> \`\`\`
> 
> 2. Select from Icinga DB database (should see \`parent\_id\` set to the hosts downtime id)
> \`\`\`
> \[noah@NoH-MB ~ \]$ mysql icingadb -e "select id, parent\_id, object\_type from downtime order by object\_type;"
> +--------------------------------------------+--------------------------------------------+-------------+
> | id | parent\_id | object\_type |
> +--------------------------------------------+--------------------------------------------+-------------+
> | 0x1ECE86DE1B6BB9D98222123E7F61059A3EBD4DDF | NULL | host |
> | 0x348EDE862D53874FACAFFE3F71F26584ECF61C28 | 0x1ECE86DE1B6BB9D98222123E7F61059A3EBD4DDF | service |
> | 0x437A5875F7956B16D5AA4ED401540108FC7802EF | 0x1ECE86DE1B6BB9D98222123E7F61059A3EBD4DDF | service |
> | 0xDDBD7297C7B149C58D8D24112E56DD002EC39767 | 0x1ECE86DE1B6BB9D98222123E7F61059A3EBD4DDF | service |
> +--------------------------------------------+--------------------------------------------+-------------+
> \`\`\`
> 
> 3. Remove parent downtime
> \`\`\`
> \[noah@NoH-MB ~ \]$ curl -k -s -u root:icinga -H 'Accept: application/json' \\
> -X POST 'https://localhost:5665/v1/actions/remove-downtime' \\
> -d '{ "downtime": "DowntimeTestHost!e26a4f56-63cd-4388-8975-2db0d8fc8107", "pretty": true }'
> {
> "results": \[
> {
> "code": 200,
> "status": "Successfully removed downtime 'DowntimeTestHost!e26a4f56-63cd-4388-8975-2db0d8fc8107' and 3 child downtimes."
> }
> \]
> }
> \`\`\`
> 
> 4. Again select all services from Icinga DB database:
> \`\`\`
> \[noah@NoH-MB ~ \]$ mysql icingadb -e "select id, parent\_id, object\_type from downtime order by object\_type;"
> \[noah@NoH-MB ~ \]$
> // Emtpy result set -\> All child downtimes have been removed
> \`\`\`

Best,  
A/K

---

<div class="post-metadata">

**Author:** ![thomassuffel](https://community.icinga.com/user_avatar/community.icinga.com/thomassuffel/32/6507_2.png) [@thomassuffel](https://community.icinga.com/u/thomassuffel)\
**Post date:** [March 28, 2023, 8:21am UTC](https://community.icinga.com/t/deleting-scheduled-downtime-on-parent-host-not-deleting-downtime-on-dependent-child-host/11533/3 "2023-03-28T08:21:32Z")

</div>

Hey Al2Klimov,

thank you for your reply.

Is the PR which you linked not a different topic, it sounds like the scenario:

- schedule downtime on host with all services on host
- remove downtime on host removes also the downtimes on the host services

My scenario ist:

- parent host ↔ child host via dependency apply rule
- schedule downtime for parent host → downtime for child host is automatically set
- delete downtime of parent host → downtime of child host is not deleted automatically

We use Icinga2 version: r2.13.4-1

kind regards,  
Thomas

---

<div class="post-metadata">

**Author:** ![Al2Klimov](https://community.icinga.com/user_avatar/community.icinga.com/al2klimov/32/959_2.png) [@Al2Klimov](https://community.icinga.com/u/Al2Klimov)\
**Post date:** [March 29, 2023, 1:08pm UTC](https://community.icinga.com/t/deleting-scheduled-downtime-on-parent-host-not-deleting-downtime-on-dependent-child-host/11533/4 "2023-03-29T13:08:37Z")

</div>

You’re right, but this PR introduces the functionality of cascade deletion in general (and links service downtimes to their hosts’ ones). To link also the child hosts’ downtimes to the parent’s one is just one line of code to change, here:

> <https://github.com/Icinga/icinga2/blob/a84a0a3ceedfc5137bd6cb781a075837a9dcf768/lib/icinga/apiactions.cpp#L457-L458>

I consider that change a good idea.

CC @jbrost
