forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
<feature>[kvm]: user vm mount model #3758
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
Open
zstack-robot-1
wants to merge
2
commits into
5.5.16
Choose a base branch
from
sync/zhong.xian/feat/ZSTAC-83157@@2
base: 5.5.16
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| -- ZSTAC-75319: Add normalizedModelName column for GPU spec dedup | ||
| CALL ADD_COLUMN('GpuDeviceSpecVO', 'normalizedModelName', 'VARCHAR(255)', 1, NULL); | ||
| CALL CREATE_INDEX('GpuDeviceSpecVO', 'idx_gpu_spec_normalized_model', 'normalizedModelName'); | ||
|
|
||
| -- Add totalScore and endTime columns to ModelEvaluationTaskVO for ZQL sorting support | ||
| -- Previously these values were only stored inside the opaque JSON TEXT field, | ||
| -- making them invisible to ZQL ORDER BY queries. | ||
| CALL ADD_COLUMN('ModelEvaluationTaskVO', 'totalScore', 'DOUBLE', 1, NULL); | ||
| CALL ADD_COLUMN('ModelEvaluationTaskVO', 'endTime', 'DATETIME', 1, NULL); | ||
|
|
||
| -- Add indexes to support efficient sorting | ||
| CALL CREATE_INDEX('ModelEvaluationTaskVO', 'idx_ModelEvaluationTaskVO_totalScore', 'totalScore'); | ||
| CALL CREATE_INDEX('ModelEvaluationTaskVO', 'idx_ModelEvaluationTaskVO_endTime', 'endTime'); | ||
|
|
||
| -- Backfill totalScore from opaque JSON for existing completed tasks | ||
| -- Uses Json_getKeyValue defined in beforeMigrate.sql for MySQL 5.5+ compatibility | ||
| UPDATE `zstack`.`ModelEvaluationTaskVO` | ||
| SET `totalScore` = CAST(Json_getKeyValue(`opaque`, 'total_score') AS DECIMAL(20,6)) | ||
| WHERE `opaque` IS NOT NULL | ||
| AND `totalScore` IS NULL | ||
| AND Json_getKeyValue(`opaque`, 'total_score') IS NOT NULL; | ||
|
|
||
| -- Backfill endTime from opaque JSON for existing completed/failed tasks | ||
| -- end_time format from Python agent: "MMM dd, yyyy hh:mm:ss a" (e.g. "Jan 01, 2025 10:30:00 AM") | ||
| UPDATE `zstack`.`ModelEvaluationTaskVO` | ||
| SET `endTime` = STR_TO_DATE( | ||
| Json_getKeyValue(`opaque`, 'end_time'), | ||
| '%b %d, %Y %h:%i:%s %p' | ||
| ) | ||
| WHERE `opaque` IS NOT NULL | ||
| AND `endTime` IS NULL | ||
| AND Json_getKeyValue(`opaque`, 'end_time') IS NOT NULL | ||
| AND Json_getKeyValue(`opaque`, 'end_time') != ''; | ||
|
|
||
| -- dGPU (TensorFusion) support tables | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `zstack`.`DGpuProfileVO` ( | ||
| `uuid` VARCHAR(32) NOT NULL, | ||
| `gpuSpecUuid` VARCHAR(32) NOT NULL, | ||
| `memorySize` BIGINT UNSIGNED NOT NULL, | ||
| `shmemSize` BIGINT UNSIGNED NOT NULL DEFAULT 268435456, | ||
| `createDate` TIMESTAMP NOT NULL, | ||
| `lastOpDate` TIMESTAMP NOT NULL, | ||
| PRIMARY KEY (`uuid`), | ||
| UNIQUE KEY `uk_dgpu_profile` (`gpuSpecUuid`, `memorySize`), | ||
| CONSTRAINT `fk_dgpu_profile_spec` | ||
| FOREIGN KEY (`gpuSpecUuid`) REFERENCES `zstack`.`GpuDeviceSpecVO`(`uuid`) ON DELETE CASCADE | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `zstack`.`DGpuDeviceVO` ( | ||
| `uuid` VARCHAR(32) NOT NULL, | ||
| `name` VARCHAR(255) NOT NULL, | ||
| `parentGpuUuid` VARCHAR(32) NOT NULL, | ||
| `gpuSpecUuid` VARCHAR(32) NOT NULL, | ||
| `hostUuid` VARCHAR(32) NOT NULL, | ||
| `vmInstanceUuid` VARCHAR(32) DEFAULT NULL, | ||
| `allocatedMemory` BIGINT UNSIGNED NOT NULL, | ||
| `shmemSize` BIGINT UNSIGNED NOT NULL DEFAULT 268435456, | ||
| `smPercentLimit` INT NOT NULL DEFAULT 0, | ||
| `protocol` VARCHAR(16) NOT NULL DEFAULT 'shmem', | ||
| `status` VARCHAR(32) NOT NULL, | ||
| `vendorId` VARCHAR(64) DEFAULT NULL, | ||
| `vendor` VARCHAR(255) DEFAULT NULL, | ||
| `createDate` TIMESTAMP NOT NULL, | ||
| `lastOpDate` TIMESTAMP NOT NULL, | ||
| PRIMARY KEY (`uuid`), | ||
| INDEX `idx_dgpu_device_parent` (`parentGpuUuid`), | ||
| INDEX `idx_dgpu_device_spec` (`gpuSpecUuid`), | ||
| INDEX `idx_dgpu_device_host` (`hostUuid`), | ||
| INDEX `idx_dgpu_device_vm` (`vmInstanceUuid`), | ||
| CONSTRAINT `fk_dgpu_device_parent` | ||
| FOREIGN KEY (`parentGpuUuid`) REFERENCES `zstack`.`PciDeviceVO`(`uuid`) ON DELETE CASCADE, | ||
| CONSTRAINT `fk_dgpu_device_spec` | ||
| FOREIGN KEY (`gpuSpecUuid`) REFERENCES `zstack`.`GpuDeviceSpecVO`(`uuid`) ON DELETE RESTRICT, | ||
| CONSTRAINT `fk_dgpu_device_host` | ||
| FOREIGN KEY (`hostUuid`) REFERENCES `zstack`.`HostEO`(`uuid`) ON DELETE CASCADE, | ||
| CONSTRAINT `fk_dgpu_device_vm` | ||
| FOREIGN KEY (`vmInstanceUuid`) REFERENCES `zstack`.`VmInstanceEO`(`uuid`) ON DELETE SET NULL | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `zstack`.`VmInstanceDGpuStrategyVO` ( | ||
| `id` BIGINT NOT NULL AUTO_INCREMENT, | ||
| `vmInstanceUuid` VARCHAR(32) NOT NULL, | ||
| `gpuSpecUuid` VARCHAR(32) NOT NULL, | ||
| `memorySize` BIGINT UNSIGNED NOT NULL, | ||
| `shmemSize` BIGINT UNSIGNED NOT NULL DEFAULT 268435456, | ||
| `gpuDeviceUuid` VARCHAR(32) DEFAULT NULL, | ||
| `chooser` VARCHAR(16) NOT NULL, | ||
| `autoDetachOnStop` TINYINT(1) NOT NULL DEFAULT 1, | ||
| `createDate` TIMESTAMP NOT NULL, | ||
| `lastOpDate` TIMESTAMP NOT NULL, | ||
| PRIMARY KEY (`id`), | ||
| UNIQUE KEY `uk_vm_dgpu_strategy` (`vmInstanceUuid`), | ||
| INDEX `idx_vm_dgpu_strategy_spec` (`gpuSpecUuid`), | ||
| CONSTRAINT `fk_vm_dgpu_strategy_vm` | ||
| FOREIGN KEY (`vmInstanceUuid`) REFERENCES `zstack`.`VmInstanceEO`(`uuid`) ON DELETE CASCADE, | ||
| CONSTRAINT `fk_vm_dgpu_strategy_spec` | ||
| FOREIGN KEY (`gpuSpecUuid`) REFERENCES `zstack`.`GpuDeviceSpecVO`(`uuid`) ON DELETE CASCADE, | ||
| CONSTRAINT `fk_vm_dgpu_strategy_device` | ||
| FOREIGN KEY (`gpuDeviceUuid`) REFERENCES `zstack`.`PciDeviceVO`(`uuid`) ON DELETE SET NULL | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
|
||
| -- ZSTAC-83157: VM model mount feature | ||
| CREATE TABLE IF NOT EXISTS `zstack`.`VmModelMountVO` ( | ||
| `uuid` VARCHAR(32) NOT NULL, | ||
| `vmInstanceUuid` VARCHAR(32) NOT NULL, | ||
| `modelUuid` VARCHAR(32) NOT NULL, | ||
| `modelName` VARCHAR(256) DEFAULT NULL, | ||
| `mountPath` VARCHAR(512) NOT NULL, | ||
| `sourcePath` VARCHAR(1024) NOT NULL, | ||
| `status` VARCHAR(32) NOT NULL, | ||
| `hostUuid` VARCHAR(32) DEFAULT NULL, | ||
| `accountUuid` VARCHAR(32) DEFAULT NULL, | ||
| `createDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
| `lastOpDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
| PRIMARY KEY (`uuid`), | ||
| UNIQUE KEY `uk_vm_mountpath` (`vmInstanceUuid`, `mountPath`(255)), | ||
| CONSTRAINT `fk_vm_model_mount_vm` | ||
| FOREIGN KEY (`vmInstanceUuid`) REFERENCES `zstack`.`VmInstanceEO`(`uuid`) ON DELETE CASCADE, | ||
| CONSTRAINT `fk_vm_model_mount_model` | ||
| FOREIGN KEY (`modelUuid`) REFERENCES `zstack`.`ModelVO`(`uuid`) ON DELETE CASCADE | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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: 575
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 239
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 2167
统一
VmModelMountVO的唯一约束,避免升级路径行为漂移。V5.5.12 中该表定义包含
uk_vm_model (vmInstanceUuid, modelUuid)(第 118 行),但在 V5.5.16 中缺失。由于中间没有迁移脚本处理此变化,这会导致不同安装/升级路径产生不同的约束:uk_vm_modeluk_vm_model若无意移除,请在此处补回
uk_vm_model;若有意移除,需要在 V5.5.13~V5.5.15 中补充显式 DROP 语句处理既有环境。同时,
createDate字段的时间戳默认值应从DEFAULT '0000-00-00 00:00:00'改为DEFAULT CURRENT_TIMESTAMP,以符合项目编码规范。建议修复(若保留唯一性)
PRIMARY KEY (`uuid`), UNIQUE KEY `uk_vm_mountpath` (`vmInstanceUuid`, `mountPath`(255)), + UNIQUE KEY `uk_vm_model` (`vmInstanceUuid`, `modelUuid`), CONSTRAINT `fk_vm_model_mount_vm`🤖 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.
Comment from zhong.xian:
已经没有5.5.12版本,所以不存在这个问题
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.
@zstack-robot-2,感谢 zhong.xian 的说明,了解到 V5.5.12 已不存在,因此uk_vm_model约束漂移的问题不适用,我收回该部分建议。不过,
createDate字段使用DEFAULT '0000-00-00 00:00:00'的问题仍然独立存在,违反了项目 SQL 编码规范(Do not useDEFAULT 0000-00-00 00:00:00, useDEFAULT CURRENT_TIMESTAMPinstead),请修正:✏️ Learnings added
🧠 Learnings used