Skip to content
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

Copp Changes #1004

Merged
merged 11 commits into from
Nov 12, 2020
14 changes: 14 additions & 0 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ def migrate_intf_table(self):
self.appDB.set(self.appDB.APPL_DB, table, 'NULL', 'NULL')
if_db.append(if_name)

def migrate_copp_table(self):
'''
Delete the existing COPP table
'''
if self.appDB is None:
return

keys = self.appDB.keys(self.appDB.APPL_DB, "COPP_TABLE:*")
if keys is None:
return
for copp_key in keys:
self.appDB.delete(self.appDB.APPL_DB, copp_key)

def version_unknown(self):
"""
version_unknown tracks all SONiC versions that doesn't have a version
Expand Down Expand Up @@ -247,6 +260,7 @@ def common_migration_ops(self):
# Update all tables that do not exist in configDB but are present in INIT_CFG
for init_table_key, init_table_val in table_val.items():
self.configDB.set_entry(init_cfg_table, init_table_key, init_table_val)
self.migrate_copp_table()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an extra line

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


def migrate(self):
version = self.get_version()
Expand Down
8 changes: 8 additions & 0 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ function backup_database()
end
end
" 0 > /dev/null
# Delete COPP_TABLE keys in APPL_DB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we can remove this section

sonic-db-cli APPL_DB eval "
for _, k in ipairs(redis.call('keys', '*')) do
if string.match(k, 'COPP_TABLE:') then
redis.call('del', k)
end
end
" 0 > /dev/null
sonic-db-cli SAVE > /dev/null
#TODO : need a script to copy all rdb files if there is multiple db instances config
docker cp database:/var/lib/redis/$REDIS_FILE $WARM_DIR
Expand Down