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

Recuring Downtime wrong dates specific month #7061

Closed
cfcnigel opened this issue Mar 29, 2019 · 8 comments · Fixed by #10107
Closed

Recuring Downtime wrong dates specific month #7061

cfcnigel opened this issue Mar 29, 2019 · 8 comments · Fixed by #10107
Assignees
Labels
area/runtime Downtimes, comments, dependencies, events bug Something isn't working
Milestone

Comments

@cfcnigel
Copy link

Describe the bug

i have a problem with recurring downtimes in my Icinga. i have a host that is always shut down on the last Monday of the month for maintenance.

apply ScheduledDowntime "reboot-system-vsmo" to Host {
        author ="icingaadmin"
        comment = "Monatliche Wartung VSM-CP2"
        ranges = {
                 "monday -1" = "05:45-07:15"
                 }
        assign where host.name == "vsm_sapcp2"
}

For a while this worked quite well. but since last month, this does not work properly.
In IcingaWeb2 the downtime is planed for 01.04.2019 but the last monday in april is the 29th.

from debug log:

Evaluating segment: monday -1 april: 05:45-07:15
Considering segment: Mon Apr 29 05:45:00 2019 -> Mon Apr 29 07:15:00 2019
(best match yet)
Evaluating segment: monday -1 august: 05:45-07:15
Considering segment: Mon Aug 26 05:45:00 2019 -> Mon Aug 26 07:15:00 2019
Evaluating segment: monday -1 december: 05:45-07:15
Considering segment: Mon Dec 30 05:45:00 2019 -> Mon Dec 30 07:15:00 2019
Evaluating segment: monday -1 february: 05:45-07:15
Evaluating segment: monday -1 january: 05:45-07:15
Evaluating segment: monday -1 july: 05:45-07:15
Considering segment: Mon Jul 29 05:45:00 2019 -> Mon Jul 29 07:15:00 2019
Evaluating segment: monday -1 june: 05:45-07:15
Considering segment: Mon Jul  1 05:45:00 2019 -> Mon Jul  1 07:15:00 2019
Evaluating segment: monday -1 march: 05:45-07:15
Considering segment: Mon Apr  1 05:45:00 2019 -> Mon Apr  1 07:15:00 2019
(best match yet)
Evaluating segment: monday -1 may: 05:45-07:15
Considering segment: Mon May 27 05:45:00 2019 -> Mon May 27 07:15:00 2019
Evaluating segment: monday -1 november: 05:45-07:15
Considering segment: Mon Nov 25 05:45:00 2019 -> Mon Nov 25 07:15:00 2019
Evaluating segment: monday -1 october: 05:45-07:15
Considering segment: Mon Oct 28 05:45:00 2019 -> Mon Oct 28 07:15:00 2019
Evaluating segment: monday -1 september: 05:45-07:15
Considering segment: Mon Sep 30 05:45:00 2019 -> Mon Sep 30 07:15:00 2019

If I look at it that way, the result for January, February, march and june is not correct. However, all other months fit again.

Screenshots

https://community.icinga.com/uploads/default/original/1X/0ee1bcf4b80f39490b5caef7eca6a089fe678dcb.png

Your Environment

My System:
Ubuntu 16.04.6 LTS
Icinga2 r2.10.4-1
Icingaweb2: 2.6.2

watch Icinga forum for more infos:
https://community.icinga.com/t/recuring-downtime-wrong/740

regards,
Basti

@dnsmichi dnsmichi added the bug Something isn't working label Mar 29, 2019
@dnsmichi
Copy link
Contributor

dnsmichi commented Apr 8, 2019

Sounds like an off-by-one error in the timeperiod calculation code. Anyone up for a patch is more than welcome.

@dnsmichi dnsmichi added the good first issue Good for newcomers label Apr 8, 2019
@htriem htriem self-assigned this Jan 23, 2020
@htriem htriem added the area/runtime Downtimes, comments, dependencies, events label Jan 23, 2020
@lakshmanaram
Copy link

@htriem I see that you've assigned this issue to yourself. Are you working on this or would it be okay if I take this up as my first issue?

@Al2Klimov
Copy link
Member

PING @htriem

@julianbrost
Copy link
Contributor

Oh, sounds like something I've written down as "looks like this might be broken, should maybe look if this is indeed a problem" to my todo list while working on #8921.

Looks like the search for the last n-th weekday includes the first day of the following month there:

if (n > 0) {
dir = 1;
} else {
n *= -1;
dir = -1;
/* Negative days are relative to the next month. */
t.tm_mon++;
}
ASSERT(n > 0);
t.tm_mday = 1;

@Al2Klimov
Copy link
Member

While working on #8921? An already merged PR?

@julianbrost
Copy link
Contributor

Yes? I didn't say that the PR is supposed to fix the issue. Just read "while working on #8921" as "the last time I looked at legacytimeperiod.cpp".

@htriem htriem removed their assignment Nov 16, 2022
@Al2Klimov
Copy link
Member

would it be okay if I take this up as my first issue?

@lakshmanaram Yes, go for it.

@yhabteab
Copy link
Member

yhabteab commented Aug 2, 2024

I've successfully reproduced this!

[2024-06-21 00:01:00 +0000] debug/ScheduledDowntime: Creating new Downtime for ScheduledDowntime "docker-master!something-happened"
[2024-06-21 00:01:00 +0000] debug/ScheduledDowntime: Finding running scheduled downtime segment for time 1718928060 (minEnd -)
[2024-06-21 00:01:00 +0000] debug/ScheduledDowntime: Evaluating (running?) segment: monday -1: 05:45-07:15
[2024-06-21 00:01:00 +0000] debug/ScheduledDowntime: Finding next scheduled downtime segment for time 1718928060
[2024-06-21 00:01:00 +0000] debug/ScheduledDowntime: Evaluating segment: monday -1: 05:45-07:15
[2024-06-21 00:01:00 +0000] debug/ScheduledDowntime: Considering segment: Mon Jul  1 05:45:00 2024 -> Mon Jul  1 07:15:00 2024
[2024-06-21 00:01:00 +0000] debug/ScheduledDowntime: (best match yet)

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants