Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 1 addition & 47 deletions counterpoll/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,54 +483,8 @@ def show():
data.append(["FLOW_CNT_ROUTE_STAT", route_info.get("POLL_INTERVAL", DEFLT_10_SEC),
route_info.get("FLEX_COUNTER_STATUS", DISABLE)])

if is_dpu(config_db) and eni_info:
if is_dpu(configdb) and eni_info:
data.append(["ENI_STAT", eni_info.get("POLL_INTERVAL", DEFLT_10_SEC),
eni_info.get("FLEX_COUNTER_STATUS", DISABLE)])

click.echo(tabulate(data, headers=header, tablefmt="simple", missingval=""))

def _update_config_db_flex_counter_table(status, filename):
""" Update counter configuration in config_db file """
with open(filename) as config_db_file:
config_db = json.load(config_db_file)

write_config_db = False
if "FLEX_COUNTER_TABLE" in config_db:
if status != "delay":
for counter, counter_config in config_db["FLEX_COUNTER_TABLE"].items():
if "FLEX_COUNTER_STATUS" in counter_config and \
counter_config["FLEX_COUNTER_STATUS"] is not status:
counter_config["FLEX_COUNTER_STATUS"] = status
write_config_db = True

elif status == "delay":
write_config_db = True
for key in config_db["FLEX_COUNTER_TABLE"].keys():
config_db["FLEX_COUNTER_TABLE"][key].update({"FLEX_COUNTER_DELAY_STATUS":"true"})

if write_config_db:
with open(filename, 'w') as config_db_file:
json.dump(config_db, config_db_file, indent=4)

# Working on Config DB
@cli.group()
def config_db():
""" Config DB counter commands """

@config_db.command()
@click.argument("filename", default="/etc/sonic/config_db.json", type=click.Path(exists=True))
def enable(filename):
""" Enable counter configuration in config_db file """
_update_config_db_flex_counter_table("enable", filename)

@config_db.command()
@click.argument("filename", default="/etc/sonic/config_db.json", type=click.Path(exists=True))
def disable(filename):
""" Disable counter configuration in config_db file """
_update_config_db_flex_counter_table("disable", filename)

@config_db.command()
@click.argument("filename", default="/etc/sonic/config_db.json", type=click.Path(exists=True))
def delay(filename):
""" Delay counters in config_db file """
_update_config_db_flex_counter_table("delay", filename)
15 changes: 6 additions & 9 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,19 +764,17 @@ def update_edgezone_aggregator_config(self):
# Set new cable length values
self.configDB.set(self.configDB.CONFIG_DB, "CABLE_LENGTH|AZURE", intf, EDGEZONE_AGG_CABLE_LENGTH)

def migrate_config_db_flex_counter_delay_status(self):
def migrate_flex_counter_delay_status_removal(self):
"""
Migrate "FLEX_COUNTER_TABLE|*": { "value": { "FLEX_COUNTER_DELAY_STATUS": "false" } }
Set FLEX_COUNTER_DELAY_STATUS true in case of fast-reboot
Remove FLEX_COUNTER_DELAY_STATUS field.
"""

flex_counter_objects = self.configDB.get_keys('FLEX_COUNTER_TABLE')
for obj in flex_counter_objects:
flex_counter = self.configDB.get_entry('FLEX_COUNTER_TABLE', obj)
delay_status = flex_counter.get('FLEX_COUNTER_DELAY_STATUS')
if delay_status is None or delay_status == 'false':
flex_counter['FLEX_COUNTER_DELAY_STATUS'] = 'true'
self.configDB.mod_entry('FLEX_COUNTER_TABLE', obj, flex_counter)
flex_counter.pop('FLEX_COUNTER_DELAY_STATUS', None)
self.configDB.set_entry('FLEX_COUNTER_TABLE', obj, flex_counter)


def migrate_sflow_table(self):
"""
Expand Down Expand Up @@ -1169,8 +1167,6 @@ def version_4_0_2(self):
Version 4_0_2.
"""
log.log_info('Handling version_4_0_2')
if self.stateDB.keys(self.stateDB.STATE_DB, "FAST_REBOOT|system"):
self.migrate_config_db_flex_counter_delay_status()

self.set_version('version_4_0_3')
return 'version_4_0_3'
Expand Down Expand Up @@ -1293,6 +1289,7 @@ def common_migration_ops(self):

self.migrate_tacplus()
self.migrate_aaa()
self.migrate_flex_counter_delay_status_removal();

def migrate(self):
version = self.get_version()
Expand Down
12 changes: 0 additions & 12 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ EXIT_FILE_SYSTEM_FULL=3
EXIT_NEXT_IMAGE_NOT_EXISTS=4
EXIT_ORCHAGENT_SHUTDOWN=10
EXIT_SYNCD_SHUTDOWN=11
EXIT_COUNTERPOLL_DELAY_FAILURE=14
EXIT_DB_INTEGRITY_FAILURE=15
EXIT_NO_CONTROL_PLANE_ASSISTANT=20
EXIT_SONIC_INSTALLER_VERIFY_REBOOT=21
Expand Down Expand Up @@ -726,17 +725,6 @@ if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$
fi
fi

if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
COUNTERPOLL_DELAY_RC=0
# Delay counters in config_db.json
/usr/local/bin/counterpoll config-db delay $CONFIG_DB_FILE || COUNTERPOLL_DELAY_RC=$?
if [[ COUNTERPOLL_DELAY_RC -ne 0 ]]; then
error "Failed to delay counterpoll. Exit code: $COUNTERPOLL_DELAY_RC"
unload_kernel
exit "${EXIT_COUNTERPOLL_DELAY_FAILURE}"
fi
fi

if [[ ( "${REBOOT_TYPE}" = "warm-reboot" || "${REBOOT_TYPE}" = "fastfast-reboot" ) && "${TEAMD_INCREASE_RETRY_COUNT}" -eq 1 ]]; then
/usr/local/bin/teamd_increase_retry_count.py
fi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
{
"VERSIONS|DATABASE": {
"VERSION": "version_4_0_3"
"VERSION": "version_202411_01"
},
"FLEX_COUNTER_TABLE|ACL": {
"FLEX_COUNTER_STATUS": "true",
"FLEX_COUNTER_DELAY_STATUS": "true",
"POLL_INTERVAL": "10000"
},
"FLEX_COUNTER_TABLE|QUEUE": {
"FLEX_COUNTER_STATUS": "true",
"FLEX_COUNTER_DELAY_STATUS": "true",
"POLL_INTERVAL": "10000"
},
"FLEX_COUNTER_TABLE|PG_WATERMARK": {
"FLEX_COUNTER_STATUS": "false",
"FLEX_COUNTER_DELAY_STATUS": "true"
"FLEX_COUNTER_STATUS": "false"
}
}
20 changes: 10 additions & 10 deletions tests/db_migrator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def test_warm_upgrade_t0_edgezone_aggregator_same_cable_length(self):
assert not diff


class TestFastUpgrade_to_4_0_3(object):
class TestFastUpgrade(object):
@classmethod
def setup_class(cls):
os.environ['UTILITIES_UNIT_TESTING'] = "2"
Expand All @@ -761,16 +761,16 @@ def check_config_db(self, result, expected):
for table in self.config_db_tables_to_verify:
assert result.get_table(table) == expected.get_table(table)

def test_fast_reboot_upgrade_to_4_0_3(self):
db_before_migrate = 'cross_branch_upgrade_to_4_0_3_input'
db_after_migrate = 'cross_branch_upgrade_to_4_0_3_expected'
def test_fast_reboot_upgrade_fc(self):
db_before_migrate = 'cross_branch_upgrade_flex_counters_input'
db_after_migrate = 'cross_branch_upgrade_flex_counters_expected'
device_info.get_sonic_version_info = get_sonic_version_info_mlnx
db = self.mock_dedicated_config_db(db_before_migrate)
import db_migrator
dbmgtr = db_migrator.DBMigrator(None)
dbmgtr.migrate()
expected_db = self.mock_dedicated_config_db(db_after_migrate)
advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_4_0_3')
advance_version_for_expected_database(dbmgtr.configDB, expected_db.cfgdb, 'version_202411_01')
assert not self.check_config_db(dbmgtr.configDB, expected_db.cfgdb)
assert dbmgtr.CURRENT_VERSION == expected_db.cfgdb.get_entry('VERSIONS', 'DATABASE')['VERSION'], '{} {}'.format(dbmgtr.CURRENT_VERSION, dbmgtr.get_version())

Expand Down Expand Up @@ -929,13 +929,13 @@ def test_dns_nameserver_migrator_minigraph(self):
dbmgtr.config_src_data = {
'GNMI': {
'gnmi': {
"client_auth": "true",
"log_level": "2",
"client_auth": "true",
"log_level": "2",
"port": "50052"
},
},
'certs': {
"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key",
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
"server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key",
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
"server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer"
}
}
Expand Down