From 4d6a0534f99b08d1d6cb302efbc8f24b08722ce2 Mon Sep 17 00:00:00 2001 From: Bin Qian Date: Mon, 15 Nov 2021 10:53:23 -0500 Subject: [PATCH] Add fd-limit-reached degraded condition for open-ldap service Added a new degrade action result code (161) to degrade the open-ldap service if FD limit is reached. Result code 160 indicates open FD is approaching to the limit, it will reset the degraded state as well as normal result code 0. SM was not designed to raise service level warnings/alarms. A major alarms will be raised by collectd when open-ldap open file descriptors is approaching to the limit (above 95%), and a critical alarm will be raised when the limit is reached (100%). Ref collectd changes: https://review.opendev.org/c/starlingx/monitoring/+/819137 Partial-bug: 1952126 Change-Id: I893c137ab81fcf01e949c9ca13cedcbe8fe5d86d Signed-off-by: Bin Qian --- service-mgmt/sm-common/src/sm_types.c | 2 ++ service-mgmt/sm-common/src/sm_types.h | 3 +++ service-mgmt/sm-db/database/create_sm_db.sql | 3 +++ service-mgmt/sm/src/sm_service_group_audit.c | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/service-mgmt/sm-common/src/sm_types.c b/service-mgmt/sm-common/src/sm_types.c index d881be02..09e5e116 100644 --- a/service-mgmt/sm-common/src/sm_types.c +++ b/service-mgmt/sm-common/src/sm_types.c @@ -309,6 +309,7 @@ _sm_service_group_condition_mappings[SM_SERVICE_GROUP_CONDITION_MAX] = { SM_SERVICE_GROUP_CONDITION_RECOVERY_FAILURE, "recovery-failure" }, { SM_SERVICE_GROUP_CONDITION_ACTION_FAILURE, "action-failure" }, { SM_SERVICE_GROUP_CONDITION_FATAL_FAILURE, "fatal-failure" }, + { SM_SERVICE_GROUP_CONDITION_FD_LIMIT_REACHED, "FD-limit-reached" }, }; static SmValueStrMappingT @@ -414,6 +415,7 @@ _sm_service_condition_mappings[SM_SERVICE_CONDITION_MAX] = { SM_SERVICE_CONDITION_RECOVERY_FAILURE, "recovery-failure" }, { SM_SERVICE_CONDITION_ACTION_FAILURE, "action-failure" }, { SM_SERVICE_CONDITION_FATAL_FAILURE, "fatal-failure" }, + { SM_SERVICE_CONDITION_FD_LIMIT_REACHED, "FD-limit-reached" }, }; static SmValueStrMappingT diff --git a/service-mgmt/sm-common/src/sm_types.h b/service-mgmt/sm-common/src/sm_types.h index 0362447a..bc7ba28a 100644 --- a/service-mgmt/sm-common/src/sm_types.h +++ b/service-mgmt/sm-common/src/sm_types.h @@ -458,6 +458,7 @@ typedef enum SM_SERVICE_GROUP_CONDITION_RECOVERY_FAILURE, SM_SERVICE_GROUP_CONDITION_ACTION_FAILURE, SM_SERVICE_GROUP_CONDITION_FATAL_FAILURE, + SM_SERVICE_GROUP_CONDITION_FD_LIMIT_REACHED, SM_SERVICE_GROUP_CONDITION_MAX } SmServiceGroupConditionT; @@ -565,6 +566,7 @@ typedef enum // recovery-failure: recovery of the service has failed. // action-failure: a service action has failed. // fatal-failure: a fatal failure has occured. +// FD-limit-reached: limit of open FD has reached. typedef enum { SM_SERVICE_CONDITION_NIL, @@ -578,6 +580,7 @@ typedef enum SM_SERVICE_CONDITION_RECOVERY_FAILURE, SM_SERVICE_CONDITION_ACTION_FAILURE, SM_SERVICE_CONDITION_FATAL_FAILURE, + SM_SERVICE_CONDITION_FD_LIMIT_REACHED, SM_SERVICE_CONDITION_MAX } SmServiceConditionT; diff --git a/service-mgmt/sm-db/database/create_sm_db.sql b/service-mgmt/sm-db/database/create_sm_db.sql index 7d369e0c..6a7fb625 100644 --- a/service-mgmt/sm-db/database/create_sm_db.sql +++ b/service-mgmt/sm-db/database/create_sm_db.sql @@ -628,6 +628,9 @@ INSERT INTO "SERVICE_ACTION_RESULTS" VALUES('ocf-script','default','stop','5','s INSERT INTO "SERVICE_ACTION_RESULTS" VALUES('ocf-script','default','demote','5','success','disabled','unknown','unknown'); INSERT INTO "SERVICE_ACTION_RESULTS" VALUES('ocf-script','Filesystem','stop','1','success','disabled','unknown','unknown'); INSERT INTO "SERVICE_ACTION_RESULTS" VALUES('ocf-script','Filesystem','stop','plugin-timeout','success','disabled','unknown','unknown'); +INSERT INTO "SERVICE_ACTION_RESULTS" VALUES('lsb-script','openldap','status','0','success','enabled-active','',''); +INSERT INTO "SERVICE_ACTION_RESULTS" VALUES('lsb-script','openldap','status','160','success','enabled-active','',''); +INSERT INTO "SERVICE_ACTION_RESULTS" VALUES('lsb-script','openldap','status','161','success','enabled-active','degraded','FD-limit-reached'); CREATE TABLE SCHEMA_VERSION (ID INTEGER PRIMARY KEY AUTOINCREMENT, MAJOR INTEGER, MINOR INTEGER); INSERT INTO "SCHEMA_VERSION" VALUES(2,0,0); CREATE TABLE CONFIGURATION ( ID INTEGER PRIMARY KEY AUTOINCREMENT, "KEY" CHAR(32), "VALUE" CHAR(32) ); diff --git a/service-mgmt/sm/src/sm_service_group_audit.c b/service-mgmt/sm/src/sm_service_group_audit.c index 226ab327..952d021e 100644 --- a/service-mgmt/sm/src/sm_service_group_audit.c +++ b/service-mgmt/sm/src/sm_service_group_audit.c @@ -124,6 +124,10 @@ static void sm_service_group_audit_map_service_condition( *condition = SM_SERVICE_GROUP_CONDITION_FATAL_FAILURE; break; + case SM_SERVICE_CONDITION_FD_LIMIT_REACHED: + *condition = SM_SERVICE_GROUP_CONDITION_FD_LIMIT_REACHED; + break; + default: *condition = SM_SERVICE_GROUP_CONDITION_UNKNOWN; DPRINTFE( "Unknown service condition (%i) given.",