-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[ceph]: support thirdparty_ceph to bm root volume #3227
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,79 @@ CALL CREATE_INDEX('ModelVO', 'idx_modelId', 'modelId'); | |
| -- Upgrade existing data: set modelId to uuid if modelId is NULL | ||
| -- This UPDATE is idempotent: WHERE clause ensures only NULL values are updated | ||
| UPDATE ModelVO SET modelId = uuid WHERE modelId IS NULL; | ||
|
|
||
|
|
||
| DELIMITER $$ | ||
|
|
||
| CREATE PROCEDURE UpdateBareMetal2InstanceProvisionNicVO() | ||
| BEGIN | ||
| DECLARE instanceUuid_exists INT; | ||
| DECLARE isPrimaryProvisionNic_exists_in_ProvisionNicVO INT; | ||
| DECLARE isPrimaryProvisionNic_exists_in_ChassisNicVO INT; | ||
|
|
||
| DECLARE EXIT HANDLER FOR SQLEXCEPTION | ||
| BEGIN | ||
| ROLLBACK; | ||
| SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'An error occurred during the update process.'; | ||
| END; | ||
|
|
||
| START TRANSACTION; | ||
|
|
||
| SELECT COUNT(*) | ||
| INTO instanceUuid_exists | ||
| FROM INFORMATION_SCHEMA.COLUMNS | ||
| WHERE TABLE_SCHEMA = 'zstack' | ||
| AND TABLE_NAME = 'BareMetal2InstanceProvisionNicVO' | ||
| AND COLUMN_NAME = 'instanceUuid'; | ||
|
|
||
| IF instanceUuid_exists = 0 THEN | ||
| CALL ADD_COLUMN('BareMetal2InstanceProvisionNicVO', 'instanceUuid', 'VARCHAR(32)', FALSE, ''); | ||
|
|
||
| UPDATE `zstack`.`BareMetal2InstanceProvisionNicVO` | ||
| SET `instanceUuid` = `uuid`; | ||
|
|
||
| ALTER TABLE `zstack`.`BareMetal2InstanceProvisionNicVO` | ||
| DROP FOREIGN KEY `fkBareMetal2InstanceProvisionNicVOInstanceVO`; | ||
|
|
||
| CALL ADD_CONSTRAINT('BareMetal2InstanceProvisionNicVO', 'fkBareMetal2InstanceProvisionNicVOInstanceVO', | ||
| 'instanceUuid', 'BareMetal2InstanceVO', 'uuid', 'CASCADE'); | ||
|
|
||
| UPDATE `zstack`.`BareMetal2InstanceProvisionNicVO` | ||
| SET `uuid` = REPLACE(UUID(), '-', ''); | ||
| END IF; | ||
|
|
||
| SELECT COUNT(*) | ||
| INTO isPrimaryProvisionNic_exists_in_ProvisionNicVO | ||
| FROM INFORMATION_SCHEMA.COLUMNS | ||
| WHERE TABLE_SCHEMA = 'zstack' | ||
| AND TABLE_NAME = 'BareMetal2InstanceProvisionNicVO' | ||
| AND COLUMN_NAME = 'isPrimaryProvisionNic'; | ||
|
|
||
| IF isPrimaryProvisionNic_exists_in_ProvisionNicVO = 0 THEN | ||
| CALL ADD_COLUMN('BareMetal2InstanceProvisionNicVO', 'isPrimaryProvisionNic', 'BOOLEAN', FALSE, FALSE); | ||
|
|
||
| UPDATE `zstack`.`BareMetal2InstanceProvisionNicVO` | ||
| SET `isPrimaryProvisionNic` = TRUE; | ||
| END IF; | ||
|
|
||
| SELECT COUNT(*) | ||
| INTO isPrimaryProvisionNic_exists_in_ChassisNicVO | ||
| FROM INFORMATION_SCHEMA.COLUMNS | ||
| WHERE TABLE_SCHEMA = 'zstack' | ||
| AND TABLE_NAME = 'BareMetal2ChassisNicVO' | ||
| AND COLUMN_NAME = 'isPrimaryProvisionNic'; | ||
|
|
||
| IF isPrimaryProvisionNic_exists_in_ChassisNicVO = 0 THEN | ||
| CALL ADD_COLUMN('BareMetal2ChassisNicVO', 'isPrimaryProvisionNic', 'BOOLEAN', FALSE, FALSE); | ||
|
|
||
| UPDATE `zstack`.`BareMetal2ChassisNicVO` | ||
| SET `isPrimaryProvisionNic` = TRUE | ||
| WHERE `isProvisionNic` = TRUE; | ||
| END IF; | ||
|
|
||
| COMMIT; | ||
| END$$ | ||
|
|
||
| DELIMITER ; | ||
| CALL UpdateBareMetal2InstanceProvisionNicVO(); | ||
| DROP PROCEDURE IF EXISTS UpdateBareMetal2InstanceProvisionNicVO; | ||
|
Comment on lines
+19
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -name "V5.5.6__schema.sql" -type fRepository: MatheMatrix/zstack Length of output: 98 🏁 Script executed: find . -path "*/db/upgrade/*.sql" -type f | head -20Repository: MatheMatrix/zstack Length of output: 777 🏁 Script executed: rg -l "ADD_COLUMN|ADD_CONSTRAINT" --type sqlRepository: MatheMatrix/zstack Length of output: 662 🏁 Script executed: cat -n ./conf/db/upgrade/V5.5.6__schema.sql | head -100Repository: MatheMatrix/zstack Length of output: 3734 🏁 Script executed: rg -A 20 "CREATE PROCEDURE ADD_COLUMN" --type sqlRepository: MatheMatrix/zstack Length of output: 44 🏁 Script executed: rg -A 20 "CREATE PROCEDURE ADD_CONSTRAINT" --type sqlRepository: MatheMatrix/zstack Length of output: 44 🏁 Script executed: rg "CREATE PROCEDURE \`?ADD_COLUMN\`?" --type sql -A 5Repository: MatheMatrix/zstack Length of output: 445 🏁 Script executed: rg "DROP PROCEDURE IF EXISTS" ./conf/db/upgrade/V5.5.6__schema.sqlRepository: MatheMatrix/zstack Length of output: 126 🏁 Script executed: rg -B 5 -A 5 "DROP FOREIGN KEY" ./conf/db/upgrade/V5.5.6__schema.sqlRepository: MatheMatrix/zstack Length of output: 565 🏁 Script executed: rg -B 5 -A 10 "DROP FOREIGN KEY" ./conf/db/upgrade/*.sql | head -100Repository: MatheMatrix/zstack Length of output: 9340 升级脚本需添加过程防护与外键删除存在性检查 过程的创建前缺少 建议修改-DELIMITER $$
+DELIMITER $$
+DROP PROCEDURE IF EXISTS UpdateBareMetal2InstanceProvisionNicVO$$
CREATE PROCEDURE UpdateBareMetal2InstanceProvisionNicVO()
BEGIN
DECLARE instanceUuid_exists INT;
+ DECLARE fk_bm2_provisionnic_instancevo_exists INT;
DECLARE isPrimaryProvisionNic_exists_in_ProvisionNicVO INT;
DECLARE isPrimaryProvisionNic_exists_in_ChassisNicVO INT;- ALTER TABLE `zstack`.`BareMetal2InstanceProvisionNicVO`
- DROP FOREIGN KEY `fkBareMetal2InstanceProvisionNicVOInstanceVO`;
+ SELECT COUNT(*)
+ INTO fk_bm2_provisionnic_instancevo_exists
+ FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
+ WHERE TABLE_SCHEMA = 'zstack'
+ AND TABLE_NAME = 'BareMetal2InstanceProvisionNicVO'
+ AND CONSTRAINT_NAME = 'fkBareMetal2InstanceProvisionNicVOInstanceVO'
+ AND CONSTRAINT_TYPE = 'FOREIGN KEY';
+
+ IF fk_bm2_provisionnic_instancevo_exists > 0 THEN
+ ALTER TABLE `zstack`.`BareMetal2InstanceProvisionNicVO`
+ DROP FOREIGN KEY `fkBareMetal2InstanceProvisionNicVOInstanceVO`;
+ END IF;🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 2303
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 3833
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 160
🏁 Script executed:
# Get the full migration script to see all procedures and logic wc -l conf/db/upgrade/V5.5.6__schema.sqlRepository: MatheMatrix/zstack
Length of output: 99
🏁 Script executed:
# Get the complete migration script to see all content cat -n conf/db/upgrade/V5.5.6__schema.sqlRepository: MatheMatrix/zstack
Length of output: 4205
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 418
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 737
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 399
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 519
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 593
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 46
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 929
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 582
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 1630
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 1067
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 89
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 557
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 1073
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 444
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 1325
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 133
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 593
🏁 Script executed:
# Check if the migration re-enables FOREIGN_KEY_CHECKS after the procedure tail -20 conf/db/upgrade/beforeMigrate.sqlRepository: MatheMatrix/zstack
Length of output: 602
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 1088
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 753
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 277
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 715
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 44
在 UUID 全量更新前,必须同步更新 BareMetal2BondingNicRefVO.provisionNicUuid
BareMetal2InstanceProvisionNicVO.uuid 被外表 BareMetal2BondingNicRefVO 的外键约束
fkBareMetal2BondingNicRefVOProvisionNicVO引用。当直接更新 uuid 为新值时,该外键约束(ON DELETE CASCADE,不包含 ON UPDATE CASCADE)不会自动更新关联的 provisionNicUuid,导致 FK 完整性失效。需要在 UPDATE uuid 语句(第 54-55 行)之前或之后,显式添加逻辑更新 BareMetal2BondingNicRefVO.provisionNicUuid 中的对应值,以维持引用一致性。例如:
🤖 Prompt for AI Agents