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

chore(release): merge release 22.04.1 into 22.04.x #349

Merged
merged 31 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
95e58a2
enh(broker/mysql_connection): unix socket is different on Debian or o…
bouda1 Jun 13, 2022
ea327d5
Mon 13562 sonar atoi 22.04.x.new (#290)
denliA Jun 21, 2022
a81829a
enh(ccc): new grpc client
bouda1 Jun 21, 2022
3af3790
fix(engine): when display_name is empty, it should be replaced by des…
bouda1 Jun 21, 2022
a23c890
enh(tests): database credentials configurable from resource.robot (#2…
denliA Jun 21, 2022
665dd9c
fix(engine): checkable::name() conflicted with host::name()
bouda1 Jun 21, 2022
1a4c987
Mon 13901 cbd multiargs 22.04.x (#293)
denliA Jun 23, 2022
5bc8326
Mon 13562 sonar unsigned bitwise operator (#294) (#295)
denliA Jun 24, 2022
9590659
enh(sonar): ignore postgresql in bam folder (#296) (#298)
denliA Jun 27, 2022
03643e6
enh(sonar): change reserved name to a non reserved one (#297) (#301)
denliA Jun 29, 2022
18e68a5
fix(broker/bam): downtimes on kpi can be more than one
bouda1 Jun 30, 2022
161271d
fix(broker): rebuild/remove graphs has come back
bouda1 Jul 5, 2022
f6b067e
enh(ccc): ccc is functional
bouda1 Jul 8, 2022
512bca7
MON-14166 fix bbdo compression nego (#316)
jean-christophe81 Jul 8, 2022
9dbe605
Mon 13562 sonar atoi external command (#302) (#318)
denliA Jul 12, 2022
027dbf6
fix(broker/engine): grpc api can be changed throught configuration. O…
bouda1 Jul 12, 2022
fc26741
fix(broker/bam): detection of downtime end was bad (#319)
bouda1 Jul 12, 2022
edf12a5
fix(engine): bad rebase fixed here
bouda1 Jul 12, 2022
d90a049
enh(sonar) : replace new by make_shared or make_unique (#322) (#326)
denliA Jul 18, 2022
8a0651e
fix(robot): fix robot BEATOI tests 22.04 (#325)
denliA Jul 18, 2022
e14ed0b
Mon 14198 sonar dynamic allocations (#327) (#328)
denliA Jul 25, 2022
65487df
fix(broker/rebuild): error in sql query
bouda1 Jul 28, 2022
1223736
fix(broker/rebuild): creation date of rrd file too late
bouda1 Jul 28, 2022
5316762
fix(ci): update dockerfile centos7 for python38 (#337)
rem31 Jul 29, 2022
dbf0b7d
fix(ci/debian): set shell to centreon-engine user (#334)
lgcosta Jul 29, 2022
0abe027
fix(ci): issue with conan fixed
bouda1 Jul 29, 2022
8269b22
fix(ci/scripts): conan bad path
bouda1 Aug 1, 2022
7e68f4e
enh(engine/anomalydetection): Enable recheck for anomaly-detection se…
jean-christophe81 Aug 3, 2022
cd461bc
fix(ci/tests): dateutil missing for robot
bouda1 Aug 3, 2022
7262cbc
fix(ci): correct syntax
chgautier Aug 30, 2022
ea82d0b
Merge branch '22.04.x' into release-22.04.1
chgautier Aug 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(broker/bam): downtimes on kpi can be more than one
* enh(tests/bam): test on bam and ignored downtimes on kpi implemented
* chore(doc): CHANGELOG updated
* doc(tests): README updated

REFS: MON-14091
  • Loading branch information
bouda1 authored Jun 30, 2022
commit 18e68a59f07360579f5d24f60165a346bdb19de3
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ A gRPC stream connector did not stop correctly on cbd stop.
On BAM misconfiguration, cbd could crash. This is fixed now. That was due to
an issue in mysql code with promises handling.

In a BA configured to ignore its kpi downtimes, if a kpi represented by a
service has two overlapping downtimes applied. When the first one is cancelled,
it is as if all the downtimes are removed. This is fixed with this new version.

*Debian*

Default configuration files were not installed on a Debian fresh install.
Expand Down
8 changes: 6 additions & 2 deletions broker/bam/src/kpi_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,25 @@ void kpi_service::service_update(std::shared_ptr<neb::downtime> const& dt,
io::stream* visitor) {
assert(dt && dt->host_id == _host_id && dt->service_id == _service_id);
// Update information.
_downtimed = dt->was_started && dt->actual_end_time.is_null();
bool downtimed = dt->was_started && dt->actual_end_time.is_null();
if (!_downtimed && downtimed)
_downtimed = true;

if (_downtime_ids.contains(dt->internal_id) && !dt->was_cancelled) {
log_v2::bam()->trace("Downtime {} already handled in this kpi service",
dt->internal_id);
return;
}

if (_downtimed) {
if (downtimed) {
log_v2::bam()->trace("adding in kpi service the impacting downtime {}",
dt->internal_id);
_downtime_ids.insert(dt->internal_id);
} else {
log_v2::bam()->trace("removing from kpi service the impacting downtime {}",
dt->internal_id);
_downtime_ids.erase(dt->internal_id);
_downtimed = !_downtime_ids.empty();
}

if (!_event || _event->in_downtime != _downtimed) {
Expand Down
253 changes: 127 additions & 126 deletions tests/README.md

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions tests/bam/inherited_downtime.robot
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,85 @@ BEBAMIDT2

Stop Engine
Stop Broker

BEBAMIGNDT1
[Documentation] A BA of type 'worst' with two services is configured. The downtime policy on this ba is "Ignore the indicator in the calculation". The BA is in critical state, because of the second critical service. Then we apply two downtimes on this last one. The BA state is ok because of the policy on indicators. A first downtime is cancelled, the BA is still OK, but when the second downtime is cancelled, the BA should be CRITICAL.
[Tags] broker downtime engine bam
Clear Commands Status
Config Broker module
Config Broker central
Broker Config Log central bam trace
Config Broker rrd
Config Engine ${1}

Clone Engine Config To DB
Add Bam Config To Engine

@{svc}= Set Variable ${{ [("host_16", "service_313"), ("host_16", "service_314")] }}
Create BA With Services test worst ${svc} ignore
Add Bam Config To Broker central
# Command of service_314 is set to critical
${cmd_1}= Get Command Id 313
Log To Console service_314 has command id ${cmd_1}
Set Command Status ${cmd_1} 0
${cmd_2}= Get Command Id 314
Log To Console service_314 has command id ${cmd_2}
Set Command Status ${cmd_2} 2
Start Broker
Start Engine
Sleep 5s

# KPI set to ok
Repeat Keyword 3 times Process Service Check Result host_16 service_313 0 output critical for 313
${result}= Check Service Status With Timeout host_16 service_313 0 60
Should Be True ${result} msg=The service (host_16,service_313) is not OK as expected

# KPI set to critical
Repeat Keyword 3 times Process Service Check Result host_16 service_314 2 output critical for 314
${result}= Check Service Status With Timeout host_16 service_314 2 60
Should Be True ${result} msg=The service (host_16,service_314) is not CRITICAL as expected

# The BA should become critical
${result}= Check Ba Status With Timeout test 2 60
Should Be True ${result} msg=The BA ba_1 is not CRITICAL as expected
Log To console The BA is critical.

# Two downtimes are applied on service_314
Schedule Service Downtime host_16 service_314 3600
${result}= Check Service Downtime With Timeout host_16 service_314 1 60
Should Be True ${result} msg=The service (host_16, service_314) is not in downtime as it should be
Log to console One downtime applied to service_314.

Schedule Service Downtime host_16 service_314 1800
${result}= Check Service Downtime With Timeout host_16 service_314 2 60
Should Be True ${result} msg=The service (host_16, service_314) is not in downtime as it should be
Log to console Two downtimes applied to service_314.

${result}= Check Service Downtime With Timeout _Module_BAM_1 ba_1 0 60
Should Be True ${result} msg=The BA ba_1 is in downtime but should not
Log to console The BA is configured to ignore kpis in downtime

${result}= Check Ba Status With Timeout test 0 60
Should Be True ${result} msg=The service in downtime should be ignored while computing the state of this BA.
Log to console The BA is OK, since the critical service is in downtime.

# The first downtime is deleted
Delete Service Downtime host_16 service_314

${result}= Check Service Downtime With Timeout host_16 service_314 1 60
Should Be True ${result} msg=The service (host_16, service_314) does not contain 1 downtime as it should
Log to console Still one downtime applied to service_314.

${result}= Check Ba Status With Timeout test 0 60
Should Be True ${result} msg=The BA is not OK whereas the service_314 is still in downtime.
Log to console The BA is still OK

# The second downtime is deleted
Delete Service Downtime host_16 service_314
${result}= Check Ba Status With Timeout test 2 60
Should Be True ${result} msg=The critical service is no more in downtime, the BA should be critical.
Log to console The BA is now critical (no more downtime)

Stop Engine
Kindly Stop Broker

6 changes: 3 additions & 3 deletions tests/resources/Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def check_service_status_with_timeout(hostname: str, service_desc: str, status:
cursor.execute("SELECT s.state FROM services s LEFT JOIN hosts h ON s.host_id=h.host_id WHERE s.description=\"{}\" AND h.name=\"{}\"".format(
service_desc, hostname))
result = cursor.fetchall()
if result[0]['state'] and int(result[0]['state']) == status:
if result[0]['state'] is not None and int(result[0]['state']) == int(status):
return True
time.sleep(5)
return False
Expand Down Expand Up @@ -446,7 +446,7 @@ def check_ba_status_with_timeout(ba_name: str, status: int, timeout: int):
cursor.execute(
"SELECT current_status FROM mod_bam WHERE name='{}'".format(ba_name))
result = cursor.fetchall()
if result[0]['current_status'] and int(result[0]['current_status']) == status:
if result[0]['current_status'] is not None and int(result[0]['current_status']) == status:
return True
time.sleep(5)
return False
Expand Down Expand Up @@ -484,7 +484,7 @@ def delete_service_downtime(hst: str, svc: str):

with connection:
with connection.cursor() as cursor:
cursor.execute("select d.internal_id from downtimes d inner join hosts h on d.host_id=h.host_id inner join services s on d.service_id=s.service_id where d.cancelled='0' and s.scheduled_downtime_depth='1' and s.description='{}' and h.name='{}'".format(svc, hst))
cursor.execute("select d.internal_id from downtimes d inner join hosts h on d.host_id=h.host_id inner join services s on d.service_id=s.service_id where d.cancelled='0' and s.scheduled_downtime_depth<>'0' and s.description='{}' and h.name='{}' LIMIT 1".format(svc, hst))
result = cursor.fetchall()
did = int(result[0]['internal_id'])

Expand Down
4 changes: 2 additions & 2 deletions tests/resources/Engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,9 @@ def add_bam_config_to_engine():
dbconf.init_bam()


def create_ba_with_services(name: str, typ: str, svc: list):
def create_ba_with_services(name: str, typ: str, svc: list, dt_policy="inherit"):
global dbconf
dbconf.create_ba_with_services(name, typ, svc)
dbconf.create_ba_with_services(name, typ, svc, dt_policy)


def get_command_id(service: int):
Expand Down
11 changes: 9 additions & 2 deletions tests/resources/db_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def create_conf_db(self):
hid += 1
connection.commit()

def create_ba_with_services(self, name:str, typ:str, svc:[(str,str)]):
def create_ba_with_services(self, name:str, typ:str, svc:[(str,str)], dt_policy):
connection = pymysql.connect(host=DB_HOST,
user=DB_USER,
password=DB_PASS,
Expand All @@ -184,7 +184,14 @@ def create_ba_with_services(self, name:str, typ:str, svc:[(str,str)]):
elif typ == 'worst':
t = 2
with connection.cursor() as cursor:
cursor.execute("INSERT INTO mod_bam (name, state_source, activate,id_reporting_period,level_w,level_c,id_notification_period,notifications_enabled,event_handler_enabled, inherit_kpi_downtimes) VALUES ('{}',{},'1',1, 80, 70, 1,'0', '0','1')".format(name, t))
if dt_policy == "inherit":
inherit_dt = 1
elif dt_policy == "ignore":
inherit_dt = 2
else:
inherit_dt = 0

cursor.execute("INSERT INTO mod_bam (name, state_source, activate,id_reporting_period,level_w,level_c,id_notification_period,notifications_enabled,event_handler_enabled, inherit_kpi_downtimes) VALUES ('{}',{},'1',1, 80, 70, 1,'0', '0','{}')".format(name, t, inherit_dt))
id_ba = cursor.lastrowid
sid = self.engine.create_bam_service("ba_{}".format(id_ba), name, "_Module_BAM_1", "centreon-bam-check!{}".format(id_ba))
cursor.execute("INSERT INTO service (service_id, service_description, display_name, service_active_checks_enabled, service_passive_checks_enabled,service_register) VALUES ({0}, \"ba_{1}\",\"{2}\",'2','2','2')".format(sid, id_ba, name))
Expand Down