Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
CORTX-34147: Add time stamp for consul process state updated in bq
Browse files Browse the repository at this point in the history
Problem:
HARE bq messages in Support Bundle do not contain timestamps.
This is needed for effective offline debug using logs from Support bundle.

Solution:
Add timestamps to bq publisher; also add the consul kv dump so generated to
Support Bundle.

Signed-off-by: pavankrishnat <pavan.k.thunuguntla@seagate.com>
  • Loading branch information
pavankrishnat committed Sep 15, 2022
1 parent 7e9dea9 commit 7bc6654
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 6 additions & 2 deletions hax/hax/handler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020 Seagate Technology LLC and/or its Affiliates
# Copyright (c) 2020-2022 Seagate Technology LLC and/or its Affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,7 @@
# please email opensource@seagate.com or cortx-questions@seagate.com.
#

import datetime
import logging
from typing import List, Any
from hax.message import (BroadcastHAStates, Die, EntrypointRequest,
Expand Down Expand Up @@ -78,7 +79,10 @@ def broadcast_process_state(self, event: ConfHaProcess):
'state': ha_process_events[event.chp_event],
'type': event_type}
payload = dump_json(data)
res = self.bq_publisher.publish('PROCESS-STATE-UPDATE', payload)
now_time = str(datetime.datetime.now())
res = self.bq_publisher.publish(now_time,
'PROCESS-STATE-UPDATE',
payload)
LOG.debug('PROCESS-STATE-UPDATE event JSON: %s res: %d',
payload, res)

Expand Down
9 changes: 6 additions & 3 deletions hax/hax/queue/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
# XXX do we want to make payload definition more strict?
# E.g. there could be a type hierarchy for payload objects that depends
# on the type name.
Message = NamedTuple('Message', [('message_type', str),
Message = NamedTuple('Message', [('timestamp', str),
('message_type', str),
('payload', Dict[str, Any])])


Expand All @@ -22,10 +23,12 @@ def __init__(self,
self.epoch_key = epoch_key

@repeat_if_fails(wait_seconds=0.1)
def publish(self, message_type: str, payload: str) -> int:
def publish(self, timestamp: str, message_type: str, payload: str) -> int:
"""Publishes the given message to the queue."""
data = simplejson.loads(payload)
message = Message(message_type=message_type, payload=data)
message = Message(timestamp=timestamp,
message_type=message_type,
payload=data)
data = simplejson.dumps(message)

while True:
Expand Down
5 changes: 4 additions & 1 deletion utils/hare-reportbug
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright (c) 2020 Seagate Technology LLC and/or its Affiliates
# Copyright (c) 2020-2022 Seagate Technology LLC and/or its Affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -130,6 +130,9 @@ sudo systemctl --all --full --no-pager status {hare,m0,motr,s3}\* \

running_process_list

# consul kv output
consul kv get --recurse > consul_kv.log

# cluster status
sudo timeout --kill-after 30 15 hctl status \
> hctl-status.txt || true
Expand Down

0 comments on commit 7bc6654

Please sign in to comment.