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

Timeperiod using YYYY-MM-DD format spans the next day too #9388

Open
Yoda-BZH opened this issue Jun 7, 2022 · 4 comments · May be fixed by #9983
Open

Timeperiod using YYYY-MM-DD format spans the next day too #9388

Yoda-BZH opened this issue Jun 7, 2022 · 4 comments · May be fixed by #9983
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Yoda-BZH
Copy link

Yoda-BZH commented Jun 7, 2022

Describe the bug

When defining a TimePeriod for a specific day (like bank days) in the YYYY-MM-DD format (ex: 2022-06-06 for June 6th), and the current date is the next day (june 7th), icinga shows that the timeperiod is still active.

To Reproduce

  1. Create a timeperiod for a specific date. Example:
object TimePeriod "MY-TEST" {
    import "legacy-timeperiod"
    display_name = "8-5 - 8H-17H"
    ranges = {
        "2022-06-06"	= "00:00-24:00"
    }
}
  1. Apply the configuration
  2. While being June 7th, call /v1/objects/timeperiods?timeperiod=MY-TEST
{
  "results": [
    {
      "attrs": {
        "__name": "MY-TEST",
        "active": false,
        "display_name": "8-5 - 8H-17H",
        "excludes": [],
        "ha_mode": 0,
        "includes": [],
        "is_inside": true,        ## HERE
        "name": "MY-TEST",
        "original_attributes": null,
        "package": "director",
        "paused": true,
        "prefer_includes": true,
        "ranges": {
          "2022-06-06": "00:00-24:00"
        },
        "segments": [
          {
            "begin": 1654552800,
            "end": 1654639200
          }
        ],
        "source_location": {
          "first_column": 1,
          "first_line": 333,
          "last_column": 28,
          "last_line": 333,
          "path": "/var/lib/icinga2/api/packages/director/ce293876-0465-4613-87e8-e3c804bb6498/zones.d/director-global/timeperiods.conf"
        },
        "templates": [
          "MY-TEST",
          "legacy-timeperiod",
          "legacy-timeperiod"
        ],
        "type": "TimePeriod",
        "update": {
          "arguments": [
            "tp",
            "begin",
            "end"
          ],
          "deprecated": false,
          "name": "Internal#LegacyTimePeriod",
          "side_effect_free": false,
          "type": "Function"
        },
        "valid_begin": 1654466400,
        "valid_end": 1654725600,
        "vars": null,
        "version": 0,
        "zone": "director-global"
      },
      "joins": {},
      "meta": {},
      "name": "MY-TEST",
      "type": "TimePeriod"
    }
  ]
}

  1. Requesting /v1/objects/timeperiods?attrs=is_inside also show that the timeperiod is still "inside" the next day
{
  "results": [
    {
      "attrs": {
        "is_inside": true
      },
      "joins": {},
      "meta": {},
      "name": "MY-TEST",
      "type": "TimePeriod"
    },
    {
      "attrs": {
        "is_inside": true
      },
      "joins": {},
      "meta": {},
      "name": "bank-days-france",
      "type": "TimePeriod"
    }
  ]
}

Expected behavior

On june 7th, the timeperiod should be over, and is_inside should be false

Your Environment

Include as many relevant details about the environment you experienced the problem in

  • Version used (icinga2 --version): r2.13.3-1 from icinga debian repository

  • Operating System and version: Debian 11.3

  • Enabled features (icinga2 feature list):
    Disabled features: command compatlog debuglog elasticsearch gelf graphite icingadb influxdb influxdb2 livestatus opentsdb perfdata statusdata syslog
    Enabled features: api checker ido-mysql mainlog notification

  • Icinga Web 2 version and modules (System - About):
    Icinga Web 2 Version 2.10.1
    Git commit 974729a6421c17fdb8bb1931623107cf6a90fc7e
    PHP Version 7.4.28
    Git commit date 2022-04-06

Icinga Documentation
Loaded Libraries
icinga/icinga-php-library 0.8.1
icinga/icinga-php-thirdparty 0.10.0
Loaded Modules
director 1.9.1 Configure
fileshipper 1.2.0 Configure
graphite 1.2.0 Configure
idoreports 0.10.0 Configure
incubator 0.13.0 Configure
monitoring 2.10.1 Configure
pdfexport 0.10.1 Configure
reporting 0.10.0 Configure
setup 2.10.1 Configure

Additional context

one machine for:

  • the web interface (and icinga-director service)
  • one master
  • multiple satellites (debian 11, 10 and 9)

Add any other context about the problem here.

This behaviour may only apply to YYYY-MM-DD format. Using "monday 6 june 2022" works as expected.

It's not because the month number and day number are equal. I did other tests with other days and I have the same behaviour.

        "valid_begin": 1654466400,
        "valid_end": 1654725600,
$ date -d @1654466400
Mon Jun  6 00:00:00 CEST 2022
date -d @1654725600
Thu Jun  9 00:00:00 CEST 2022

Is that normal that valid_end is not 1654552800 (2022-06-07 00:00:00) ?

Tested with two platforms (prod and dev environment with the same behaviour)

@Yoda-BZH
Copy link
Author

Yoda-BZH commented Jun 7, 2022

@Al2Klimov Al2Klimov added the bug Something isn't working label Jun 7, 2022
@ohrly
Copy link

ohrly commented Jul 29, 2022

Describe the bug

We have the same problem with the timeperiod being active one more time.

To Reproduce

In our problem it affects the timeperiod for notifications (here the object from the timepriod.conf):

object TimePeriod "sms-johndoe" {
    import "legacy-timeperiod"
    ranges = {
        "2022-05-24 - 2022-05-29" = "00:00-24:00"
        "2022-05-30"  = "00:00-09:00"
    }
}

This will send sms to johndoe on 2022-05-30 all day long (00:00-24:00)!

Your Environment

icinga2 - The Icinga 2 network monitoring daemon (version: r2.13.4-1)

Copyright (c) 2012-2022 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl2.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

System information:
  Platform: Oracle Linux Server
  Platform version: 8.6
  Kernel: Linux
  Kernel version: 4.18.0-372.9.1.el8.x86_64
  Architecture: x86_64

Build information:
  Compiler: GNU 8.5.0
  OpenSSL version: OpenSSL 1.1.1k  FIPS 25 Mar 2021

Application information:

General paths:
  Config directory: /etc/icinga2
  Data directory: /var/lib/icinga2
  Log directory: /var/log/icinga2
  Cache directory: /var/cache/icinga2
  Spool directory: /var/spool/icinga2
  Run directory: /run/icinga2

Old paths (deprecated):
  Installation root: /usr
  Sysconf directory: /etc
  Run directory (base): /run
  Local state directory: /var

Internal paths:
  Package data directory: /usr/share/icinga2
  State path: /var/lib/icinga2/icinga2.state
  Modified attributes path: /var/lib/icinga2/modified-attributes.conf
  Objects path: /var/cache/icinga2/icinga2.debug
  Vars path: /var/cache/icinga2/icinga2.vars
  PID path: /run/icinga2/icinga2.pid

@X8invisible
Copy link

X8invisible commented Aug 30, 2022

I believe this has something to do with the "acorss midnight" feature https://icinga.com/docs/icinga-2/latest/doc/08-advanced-topics/#across-midnight

I have tested by setting an exclude to be like this, which does work:

ranges = {
    "2022-08-29" = "07:00-12:59,13:00-19:00"

 }

@Al2Klimov
Copy link
Member

Duplicate of #8741

@Al2Klimov Al2Klimov marked this as a duplicate of #8741 Nov 22, 2023
@yhabteab yhabteab linked a pull request Jan 29, 2024 that will close this issue
@yhabteab yhabteab added this to the 2.15.0 milestone Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants