Skip to content

Commit 3abd19e

Browse files
[FC] remove FC delay field (sonic-net#3577)
* [FC] remove FC delay field Signed-off-by: Stepan Blyschak <[email protected]>
1 parent 11c2716 commit 3abd19e

File tree

5 files changed

+14
-75
lines changed

5 files changed

+14
-75
lines changed

counterpoll/main.py

-47
Original file line numberDiff line numberDiff line change
@@ -566,53 +566,6 @@ def show():
566566

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

569-
def _update_config_db_flex_counter_table(status, filename):
570-
""" Update counter configuration in config_db file """
571-
with open(filename) as config_db_file:
572-
config_db = json.load(config_db_file)
573-
574-
write_config_db = False
575-
if "FLEX_COUNTER_TABLE" in config_db:
576-
if status != "delay":
577-
for counter, counter_config in config_db["FLEX_COUNTER_TABLE"].items():
578-
if "FLEX_COUNTER_STATUS" in counter_config and \
579-
counter_config["FLEX_COUNTER_STATUS"] is not status:
580-
counter_config["FLEX_COUNTER_STATUS"] = status
581-
write_config_db = True
582-
583-
elif status == "delay":
584-
write_config_db = True
585-
for key in config_db["FLEX_COUNTER_TABLE"].keys():
586-
config_db["FLEX_COUNTER_TABLE"][key].update({"FLEX_COUNTER_DELAY_STATUS":"true"})
587-
588-
if write_config_db:
589-
with open(filename, 'w') as config_db_file:
590-
json.dump(config_db, config_db_file, indent=4)
591-
592-
# Working on Config DB
593-
@cli.group()
594-
def config_db():
595-
""" Config DB counter commands """
596-
597-
@config_db.command()
598-
@click.argument("filename", default="/etc/sonic/config_db.json", type=click.Path(exists=True))
599-
def enable(filename):
600-
""" Enable counter configuration in config_db file """
601-
_update_config_db_flex_counter_table("enable", filename)
602-
603-
@config_db.command()
604-
@click.argument("filename", default="/etc/sonic/config_db.json", type=click.Path(exists=True))
605-
def disable(filename):
606-
""" Disable counter configuration in config_db file """
607-
_update_config_db_flex_counter_table("disable", filename)
608-
609-
@config_db.command()
610-
@click.argument("filename", default="/etc/sonic/config_db.json", type=click.Path(exists=True))
611-
def delay(filename):
612-
""" Delay counters in config_db file """
613-
_update_config_db_flex_counter_table("delay", filename)
614-
615-
616569
"""
617570
The list of dynamic commands that are added on a specific condition.
618571
Format:

scripts/db_migrator.py

+13
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,18 @@ def migrate_config_db_flex_counter_delay_status(self):
799799
flex_counter['FLEX_COUNTER_DELAY_STATUS'] = 'true'
800800
self.configDB.mod_entry('FLEX_COUNTER_TABLE', obj, flex_counter)
801801

802+
def migrate_flex_counter_delay_status_removal(self):
803+
"""
804+
Remove FLEX_COUNTER_DELAY_STATUS field.
805+
"""
806+
807+
flex_counter_objects = self.configDB.get_keys('FLEX_COUNTER_TABLE')
808+
for obj in flex_counter_objects:
809+
flex_counter = self.configDB.get_entry('FLEX_COUNTER_TABLE', obj)
810+
flex_counter.pop('FLEX_COUNTER_DELAY_STATUS', None)
811+
self.configDB.set_entry('FLEX_COUNTER_TABLE', obj, flex_counter)
812+
813+
802814
def migrate_sflow_table(self):
803815
"""
804816
Migrate "SFLOW_TABLE" and "SFLOW_SESSION_TABLE" to update default sample_direction
@@ -1278,6 +1290,7 @@ def version_202505_01(self):
12781290
master branch until 202505 branch is created.
12791291
"""
12801292
log.log_info('Handling version_202505_01')
1293+
self.migrate_flex_counter_delay_status_removal()
12811294
return None
12821295

12831296
def get_version(self):

scripts/fast-reboot

-12
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ EXIT_FILE_SYSTEM_FULL=3
4444
EXIT_NEXT_IMAGE_NOT_EXISTS=4
4545
EXIT_ORCHAGENT_SHUTDOWN=10
4646
EXIT_SYNCD_SHUTDOWN=11
47-
EXIT_COUNTERPOLL_DELAY_FAILURE=14
4847
EXIT_DB_INTEGRITY_FAILURE=15
4948
EXIT_NO_CONTROL_PLANE_ASSISTANT=20
5049
EXIT_SONIC_INSTALLER_VERIFY_REBOOT=21
@@ -786,17 +785,6 @@ if [[ "$REBOOT_TYPE" = "warm-reboot" || "$REBOOT_TYPE" = "fastfast-reboot" || "$
786785
fi
787786
fi
788787
789-
if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
790-
COUNTERPOLL_DELAY_RC=0
791-
# Delay counters in config_db.json
792-
/usr/local/bin/counterpoll config-db delay $CONFIG_DB_FILE || COUNTERPOLL_DELAY_RC=$?
793-
if [[ COUNTERPOLL_DELAY_RC -ne 0 ]]; then
794-
error "Failed to delay counterpoll. Exit code: $COUNTERPOLL_DELAY_RC"
795-
unload_kernel
796-
exit "${EXIT_COUNTERPOLL_DELAY_FAILURE}"
797-
fi
798-
fi
799-
800788
if [[ ( "${REBOOT_TYPE}" = "warm-reboot" || "${REBOOT_TYPE}" = "fastfast-reboot" || "${REBOOT_TYPE}" = "express-reboot" ) && "${TEAMD_INCREASE_RETRY_COUNT}" -eq 1 ]]; then
801789
/usr/local/bin/teamd_increase_retry_count.py
802790
fi

tests/counterpoll_test.py

-12
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,6 @@ def _get_config_db_file(self):
113113

114114
os.remove(config_db_file)
115115

116-
@pytest.mark.parametrize("status", ["disable", "enable"])
117-
def test_update_counter_config_db_status(self, status, _get_config_db_file):
118-
runner = CliRunner()
119-
result = runner.invoke(counterpoll.cli.commands["config-db"].commands[status], [_get_config_db_file])
120-
121-
with open(_get_config_db_file) as json_file:
122-
config_db = json.load(json_file)
123-
124-
if "FLEX_COUNTER_TABLE" in config_db:
125-
for counter, counter_config in config_db["FLEX_COUNTER_TABLE"].items():
126-
assert counter_config["FLEX_COUNTER_STATUS"] == status
127-
128116
@pytest.mark.parametrize("status", ["disable", "enable"])
129117
def test_update_pg_drop_status(self, status):
130118
runner = CliRunner()

tests/db_migrator_input/config_db/cross_branch_upgrade_to_4_0_3_expected.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
},
55
"FLEX_COUNTER_TABLE|ACL": {
66
"FLEX_COUNTER_STATUS": "enable",
7-
"FLEX_COUNTER_DELAY_STATUS": "true",
87
"POLL_INTERVAL": "10000"
98
},
109
"FLEX_COUNTER_TABLE|QUEUE": {
1110
"FLEX_COUNTER_STATUS": "enable",
12-
"FLEX_COUNTER_DELAY_STATUS": "true",
1311
"POLL_INTERVAL": "10000"
1412
},
1513
"FLEX_COUNTER_TABLE|PG_WATERMARK": {
16-
"FLEX_COUNTER_STATUS": "disable",
17-
"FLEX_COUNTER_DELAY_STATUS": "true"
14+
"FLEX_COUNTER_STATUS": "disable"
1815
}
1916
}

0 commit comments

Comments
 (0)