forked from Tendrl/commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import flow failure related log messages should be more specific abou…
…t what went wrong tendrl-bug-id: Tendrl#1080 bugzilla: 1688630 Signed-off-by: GowthamShanmugasundaram <gshanmug@redhat.com>
- Loading branch information
1 parent
7fcbe3b
commit 6706c12
Showing
9 changed files
with
265 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
tendrl/commons/objects/node/atoms/check_service_status/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
import etcd | ||
|
||
from tendrl.commons import objects | ||
from tendrl.commons.objects import AtomExecutionFailedError | ||
from tendrl.commons.utils import etcd_utils | ||
from tendrl.commons.utils import log_utils as logger | ||
|
||
|
||
TENDRL_SERVICES = { | ||
"server": [ | ||
"tendrl-node-agent", | ||
"tendrl-monitoring-integration", | ||
"tendrl-api", | ||
], | ||
"storage_node": [ | ||
"tendrl-node-agent", | ||
"glusterd", | ||
] | ||
} | ||
|
||
|
||
class CheckServiceStatus(objects.BaseAtom): | ||
def __init__(self, *args, **kwargs): | ||
super(CheckServiceStatus, self).__init__(*args, **kwargs) | ||
|
||
def run(self): | ||
node_context = NS.tendrl.objects.NodeContext().load() | ||
tags = list(node_context.tags) | ||
service_status = True | ||
if "tendrl/monitor" in tags or \ | ||
"tendrl/integration/monitoring" in tags: | ||
# check neccessary service status in server | ||
for service_name in TENDRL_SERVICES["server"]: | ||
service = get_service_status( | ||
service_name | ||
) | ||
if not service.running: | ||
if len(service.error) > 0: | ||
msg = ("Unable to find status of the service %s " | ||
"on server-node. Error: %s" % ( | ||
service_name, | ||
service.error | ||
)) | ||
else: | ||
msg = ("Service %s is not running on a server-node, " | ||
"Please start it manually or check the log " | ||
"file to figure out the exact problem" % service_name) | ||
logger.log( | ||
"error", | ||
NS.get("publisher_id", None), | ||
{ | ||
"message": msg | ||
}, | ||
job_id=self.parameters['job_id'], | ||
flow_id=self.parameters['flow_id'] | ||
) | ||
service_status = False | ||
else: | ||
# check neccessary service status in storage nodes | ||
for service_name in TENDRL_SERVICES["storage_node"]: | ||
service = get_service_status(service_name) | ||
if not service.running: | ||
if len(service.error) > 0: | ||
msg = ("Unable to find status of the service %s " | ||
"on %s. Error: %s" % ( | ||
service_name, | ||
NS.node_context.fqdn, | ||
service.error | ||
)) | ||
else: | ||
msg = ("Service %s is not running on %s, Please " | ||
"start it manually or check the log file to " | ||
"figure out the exact problem" % ( | ||
service_name, | ||
NS.node_context.fqdn | ||
)) | ||
logger.log( | ||
"error", | ||
NS.get("publisher_id", None), | ||
{ | ||
"message": msg | ||
}, | ||
job_id=self.parameters['job_id'], | ||
flow_id=self.parameters['flow_id'] | ||
) | ||
service_status = False | ||
node_list = self.parameters['Node[]'] | ||
if service_status and len(node_list) > 1: | ||
# check monitoring integration is running on server | ||
try: | ||
node_arr = etcd_utils.read( | ||
"/indexes/tags/tendrl/integration/monitoring" | ||
).value | ||
node_id = eval(node_arr)[0] | ||
service = NS.tendrl.objects.Service( | ||
service="tendrl-monitoring-integration", | ||
node_id=node_id | ||
).load() | ||
service.error = list(service.error) | ||
if not service.running: | ||
if len(service.error) > 0: | ||
msg = ("Unable to find status of the service " | ||
"tendrl-monitoring-integration on " | ||
"server-node. Error: %s" % service.error) | ||
else: | ||
msg = ("Service tendrl-monitoring-integration is " | ||
"not running on a server-node, Please start" | ||
" it manually or check the log file to " | ||
"figure out the exact problem") | ||
logger.log( | ||
"error", | ||
NS.get("publisher_id", None), | ||
{ | ||
"message": msg | ||
}, | ||
job_id=self.parameters['job_id'], | ||
flow_id=self.parameters['flow_id'] | ||
) | ||
service_status = False | ||
except (etcd.EtcdKeyNotFound, IndexError): | ||
msg = ("Service tendrl-monitoring-integration is " | ||
"not running in a server, Please start it " | ||
"manually or check the log message to " | ||
"figure out the exact problem") | ||
logger.log( | ||
"error", | ||
NS.get("publisher_id", None), | ||
{ | ||
"message": msg | ||
}, | ||
job_id=self.parameters['job_id'], | ||
flow_id=self.parameters['flow_id'] | ||
) | ||
service_status = False | ||
return service_status | ||
|
||
|
||
def get_service_status(service_name): | ||
service = NS.tendrl.objects.Service( | ||
service=service_name | ||
) | ||
return service |
Oops, something went wrong.