Follow up: Add Datastore Version Registry Extension

When upgrading Trove, the trove-manage script fails
to upgrade the database when the DBDatastoreVersion
table is not empty.

This patch will help us fix above error

Change-Id: Ib615032747f89daf7f8500c7e2df4064fab05314
This commit is contained in:
Bo Tran 2024-10-31 17:38:40 +07:00 committed by wu.chunyang
parent 3ff639047e
commit 596134e3ad
4 changed files with 34 additions and 16 deletions

View File

@ -1,18 +1,26 @@
{ {
"version": { "version": {
"datastore": "cc9ee471-e781-43bf-a796-423c5d549997", "id": "800774c4-0505-4ae7-8cf9-aae131e065ae",
"id": "4eb0179d-fe11-4556-9422-5267d2fc7625", "name": "5.7",
"version": "5.7",
"links": [ "links": [
{ {
"href": "https://127.0.0.1:8779/v1.0/9f8dd5eacb074c9f87d2d822c9092aa5/datastores/versions/4eb0179d-fe11-4556-9422-5267d2fc7625", "href": "https://127.0.0.1:8779/v1.0/0600c20b16444bfa979b879b099805a1/datastores/versions/800774c4-0505-4ae7-8cf9-aae131e065ae",
"rel": "self" "rel": "self"
}, },
{ {
"href": "https://127.0.0.1:8779/datastores/versions/4eb0179d-fe11-4556-9422-5267d2fc7625", "href": "https://127.0.0.1:8779/datastores/versions/800774c4-0505-4ae7-8cf9-aae131e065ae",
"rel": "bookmark" "rel": "bookmark"
} }
], ],
"name": "12", "datastore": "3423e828-3355-48ef-9c16-5c41e7c196fb",
"version": "5.7.29" "active": true,
"packages": "",
"image": null,
"registry_ext": "trove.guestagent.datastore.mysql.manager.Manager",
"repl_strategy": "trove.guestagent.strategies.replication.mysql_gtid.MysqlGTIDReplication",
"image_tags": [
"trove"
]
} }
} }

View File

@ -0,0 +1,5 @@
---
fixes:
- |
fix a bug where the trove-manage script fails to upgrade
the database when the DBDatastoreVersion table is not empty.

View File

@ -65,7 +65,8 @@ class DBCapabilityOverrides(dbmodels.DatabaseModelBase):
class DBDatastoreVersion(dbmodels.DatabaseModelBase): class DBDatastoreVersion(dbmodels.DatabaseModelBase):
_data_fields = ['datastore_id', 'name', 'image_id', 'image_tags', _data_fields = ['datastore_id', 'name', 'image_id', 'image_tags',
'packages', 'active', 'manager', 'version'] 'packages', 'active', 'manager', 'version',
'registry_ext', 'repl_strategy']
_table_name = 'datastore_versions' _table_name = 'datastore_versions'

View File

@ -75,7 +75,11 @@ def upgrade() -> None:
'repl_namespace': repl_namespaces.get(dsv_manager, ''), 'repl_namespace': repl_namespaces.get(dsv_manager, ''),
'repl_strategy': repl_strategies.get(dsv_manager, '') 'repl_strategy': repl_strategies.get(dsv_manager, '')
} }
ds_versions_table = table("datastore_versions", column("", String)) ds_versions_table = table(
"datastore_versions",
column("id", String),
column("registry_ext", String),
column("repl_strategy", String))
op.execute( op.execute(
ds_versions_table.update() ds_versions_table.update()
.where(ds_versions_table.c.id == dsv_id) .where(ds_versions_table.c.id == dsv_id)