-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[TSA] Reliable TSA: Addressing pizza box issues #19217
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,18 @@ if [ "$EUID" -ne 0 ] ; then | |
fi | ||
|
||
if [ -f /etc/sonic/chassisdb.conf ]; then | ||
rexec all -c "sudo TSA chassis" | ||
CHASSIS_TSA_STATE_UPDATE="CHASSIS_APP_DB HMSET "BGP_DEVICE_GLOBAL\|STATE" tsa_enabled "true"" | ||
CONFIG_DB_TSA_STATE_UPDATE='{"BGP_DEVICE_GLOBAL":{"STATE":{"tsa_enabled": "true"}}}' | ||
current_tsa_state="$(sonic-cfggen -d -v BGP_DEVICE_GLOBAL.STATE.tsa_enabled)" | ||
if [[ $current_tsa_state == true ]]; then | ||
echo "Chassis is already in Maintenance" | ||
logger -t TSA -p user.info "Chassis is already in Maintenance" | ||
else | ||
sonic-db-cli $CHASSIS_TSA_STATE_UPDATE | ||
sonic-cfggen -a "$CONFIG_DB_TSA_STATE_UPDATE" -w | ||
echo "Chassis Mode: Normal -> Maintenance" | ||
logger -t TSA -p user.info "Chassis Mode: Normal -> Maintenance" | ||
fi | ||
echo "Please execute \"rexec all -c 'sudo config save -y'\" to preserve System mode in Maintenance after reboot\ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be changed to just 'sudo config save' instead of rexec all now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fountzou : Please address this comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for comment @tjchadaga @abdosi . Fixed -- kindly see #19527 |
||
or config reload on all linecards" | ||
exit 0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,21 @@ if [ "$EUID" -ne 0 ] ; then | |
exit 1 | ||
fi | ||
|
||
# If run on supervisor of chassis, trigger remote execution of TSB on all linecards | ||
if [ -f /etc/sonic/chassisdb.conf ]; then | ||
rexec all -c "sudo TSB chassis" | ||
CHASSIS_TSA_STATE_UPDATE="CHASSIS_APP_DB HMSET "BGP_DEVICE_GLOBAL\|STATE" tsa_enabled "false"" | ||
CONFIG_DB_TSA_STATE_UPDATE='{"BGP_DEVICE_GLOBAL":{"STATE":{"tsa_enabled": "false"}}}' | ||
current_tsa_state="$(sonic-cfggen -d -v BGP_DEVICE_GLOBAL.STATE.tsa_enabled)" | ||
if [[ $current_tsa_state == false ]]; then | ||
echo "Chassis is already in Normal mode" | ||
logger -t TSB -p user.info "Chassis is already in Normal mode" | ||
else | ||
sonic-db-cli $CHASSIS_TSA_STATE_UPDATE | ||
sonic-cfggen -a "$CONFIG_DB_TSA_STATE_UPDATE" -w | ||
echo "Chassis Mode: Maintenance -> Normal" | ||
logger -t TSB -p user.info "Chassis Mode: Maintenance -> Normal" | ||
fi | ||
echo "Please execute \"rexec all -c 'sudo config save -y'\" to preserve System mode in Normal state after reboot\ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fountzou : Please address this comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for comment @tjchadaga @abdosi . Fixed -- kindly see #19527 |
||
or config reload on all linecards" | ||
or config reload on all linecards" | ||
exit 0 | ||
fi | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -269,6 +269,18 @@ function postStartAction() | |
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1" | ||
fi | ||
|
||
# In SUP, enforce CHASSIS_APP_DB.tsa_enabled to be in sync with BGP_DEVICE_GLOBAL.STATE.tsa_enabled | ||
if [[ -z "$DEV" ]] && [[ -f /etc/sonic/chassisdb.conf ]]; then | ||
tsa_cfg="$($SONIC_DB_CLI CONFIG_DB HGET "BGP_DEVICE_GLOBAL|STATE" "tsa_enabled")" | ||
if [[ -n "$tsa_cfg" ]]; then | ||
docker exec -i ${DOCKERNAME} $SONIC_DB_CLI CHASSIS_APP_DB HMSET "BGP_DEVICE_GLOBAL|STATE" tsa_enabled ${tsa_cfg} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please capture return code of operation and log message in case of failure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed your suggestion. Thanks! |
||
OP_CODE=$? | ||
if [ $OP_CODE -ne 0 ]; then | ||
echo "Err: Cmd failed (exit code $OP_CODE). CHASSIS_APP_DB and CONFIG_DB may be incosistent wrt tsa_enabled" | ||
fi | ||
fi | ||
fi | ||
|
||
# Add redis UDS to the redis group and give read/write access to the group | ||
REDIS_SOCK="/var/run/redis${DEV}/redis.sock" | ||
else | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -330,6 +330,19 @@ do_db_migration() | |
/usr/local/bin/db_migrator.py -o migrate | ||
fi | ||
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1" | ||
|
||
#Enforce CHASSIS_APP_DB.tsa_enabled to be in sync with BGP_DEVICE_GLOBAL.STATE.tsa_enabled | ||
if [[ -f /etc/sonic/chassisdb.conf ]]; then | ||
tsa_cfg="$(sonic-db-cli CONFIG_DB HGET "BGP_DEVICE_GLOBAL|STATE" "tsa_enabled")" | ||
sonic-db-cli CHASSIS_APP_DB HMSET "BGP_DEVICE_GLOBAL|STATE" tsa_enabled ${tsa_cfg} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please capture return code of operation and log message in case of failure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. Thanks for your comment |
||
OP_CODE=$? | ||
|
||
if [ $OP_CODE -ne 0 ]; then | ||
err_msg="Cmd failed (exit code $OP_CODE). CHASSIS_APP_DB and CONFIG_DB may be incosistent wrt tsa_enabled." | ||
echo "$err_msg" | ||
logger -t CHASSIS_APP_DB -p user.info "$err_msg" | ||
fi | ||
fi | ||
} | ||
|
||
# Perform configuration migration from backup copy. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from .manager import Manager | ||
from .managers_device_global import DeviceGlobalCfgMgr | ||
from .log import log_err, log_debug, log_notice | ||
import re | ||
from swsscommon import swsscommon | ||
|
||
class ChassisAppDbMgr(Manager): | ||
"""This class responds to change in tsa_enabled state of the supervisor""" | ||
|
||
def __init__(self, common_objs, db, table): | ||
""" | ||
Initialize the object | ||
:param common_objs: common object dictionary | ||
:param db: name of the db | ||
:param table: name of the table in the db | ||
""" | ||
self.lc_tsa = "" | ||
self.directory = common_objs['directory'] | ||
self.dev_cfg_mgr = DeviceGlobalCfgMgr(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_DEVICE_GLOBAL_TABLE_NAME) | ||
self.directory.subscribe([("CONFIG_DB", swsscommon.CFG_BGP_DEVICE_GLOBAL_TABLE_NAME, "tsa_enabled"),], self.on_lc_tsa_status_change) | ||
super(ChassisAppDbMgr, self).__init__( | ||
common_objs, | ||
[], | ||
db, | ||
table, | ||
) | ||
|
||
def on_lc_tsa_status_change(self): | ||
if self.directory.path_exist("CONFIG_DB", swsscommon.CFG_BGP_DEVICE_GLOBAL_TABLE_NAME, "tsa_enabled"): | ||
self.lc_tsa = self.directory.get_slot("CONFIG_DB", swsscommon.CFG_BGP_DEVICE_GLOBAL_TABLE_NAME)["tsa_enabled"] | ||
log_debug("ChassisAppDbMgr:: LC TSA update handler status %s" % self.lc_tsa) | ||
|
||
def set_handler(self, key, data): | ||
log_debug("ChassisAppDbMgr:: set handler") | ||
|
||
if not data: | ||
log_err("ChassisAppDbMgr:: data is None") | ||
return False | ||
|
||
if "tsa_enabled" in data: | ||
if self.lc_tsa == "false": | ||
self.dev_cfg_mgr.cfg_mgr.commit() | ||
self.dev_cfg_mgr.cfg_mgr.update() | ||
self.dev_cfg_mgr.isolate_unisolate_device(data["tsa_enabled"]) | ||
return True | ||
return False | ||
|
||
def del_handler(self, key): | ||
log_debug("ChassisAppDbMgr:: del handler") | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please change this to include chassis-packet or change the check to look for type == "SpineRouter"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fountzou : Please address this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for comment @tjchadaga @abdosi . Fixed -- kindly see #19527