diff --git a/counterpoll/main.py b/counterpoll/main.py index 530281188f..00af667c9e 100644 --- a/counterpoll/main.py +++ b/counterpoll/main.py @@ -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) diff --git a/scripts/db_migrator.py b/scripts/db_migrator.py index 9be3ce325b..90b80ee039 100755 --- a/scripts/db_migrator.py +++ b/scripts/db_migrator.py @@ -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): """ @@ -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' @@ -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() diff --git a/scripts/fast-reboot b/scripts/fast-reboot index aef71d6cd6..b43f604e0d 100755 --- a/scripts/fast-reboot +++ b/scripts/fast-reboot @@ -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 @@ -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 diff --git a/tests/db_migrator_input/config_db/cross_branch_upgrade_to_4_0_3_expected.json b/tests/db_migrator_input/config_db/cross_branch_upgrade_flex_counters_expected.json similarity index 59% rename from tests/db_migrator_input/config_db/cross_branch_upgrade_to_4_0_3_expected.json rename to tests/db_migrator_input/config_db/cross_branch_upgrade_flex_counters_expected.json index 1ebfbc6afe..68d08afce3 100644 --- a/tests/db_migrator_input/config_db/cross_branch_upgrade_to_4_0_3_expected.json +++ b/tests/db_migrator_input/config_db/cross_branch_upgrade_flex_counters_expected.json @@ -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" } } diff --git a/tests/db_migrator_input/config_db/cross_branch_upgrade_to_4_0_3_input.json b/tests/db_migrator_input/config_db/cross_branch_upgrade_flex_counters_input.json similarity index 100% rename from tests/db_migrator_input/config_db/cross_branch_upgrade_to_4_0_3_input.json rename to tests/db_migrator_input/config_db/cross_branch_upgrade_flex_counters_input.json diff --git a/tests/db_migrator_test.py b/tests/db_migrator_test.py index cdf4251bd7..5b45440b5b 100644 --- a/tests/db_migrator_test.py +++ b/tests/db_migrator_test.py @@ -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" @@ -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()) @@ -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" } }