forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(storage): local primary LUKS qcow2 creation only #4079
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
1
commit into
feature-zsv-5.1.0-encryption
Choose a base branch
from
sync/zstackio/encrypt-volume@@2
base: feature-zsv-5.1.0-encryption
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| CREATE TABLE IF NOT EXISTS `zstack`.`TpmKeyBackupVO` ( | ||
| `uuid` char(32) NOT NULL UNIQUE, | ||
| `lastOpDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
| `createDate` timestamp NOT NULL DEFAULT '1999-12-31 23:59:59', | ||
| PRIMARY KEY (`uuid`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
|
||
| DELETE FROM `EncryptedResourceKeyRefVO` | ||
| WHERE `resourceUuid` NOT IN (SELECT `uuid` FROM `ResourceVO`); | ||
| ALTER TABLE `EncryptedResourceKeyRefVO` | ||
| ADD CONSTRAINT `fkEncryptedResourceKeyRefResourceVO` FOREIGN KEY (`resourceUuid`) REFERENCES `ResourceVO`(`uuid`) | ||
| ON DELETE CASCADE; | ||
|
|
||
| -- Volume LUKS encryption flag (API opt-in + EncryptedResourceKeyRefVO binding) | ||
|
|
||
| ALTER TABLE `zstack`.`VolumeEO` ADD COLUMN `encrypted` tinyint(1) NOT NULL DEFAULT 0; | ||
| ALTER TABLE `zstack`.`VolumeSnapshotEO` ADD COLUMN `encrypted` tinyint(1) NOT NULL DEFAULT 0; | ||
|
|
||
| DROP VIEW IF EXISTS `zstack`.`VolumeVO`; | ||
| CREATE VIEW `zstack`.`VolumeVO` AS | ||
| SELECT uuid, name, description, primaryStorageUuid, vmInstanceUuid, diskOfferingUuid, | ||
| rootImageUuid, installPath, type, status, size, actualSize, deviceId, format, state, createDate, lastOpDate, | ||
| isShareable, volumeQos, lastVmInstanceUuid, lastDetachDate, lastAttachDate, protocol, encrypted | ||
| FROM `zstack`.`VolumeEO` | ||
| WHERE deleted IS NULL; | ||
|
|
||
| DROP VIEW IF EXISTS `zstack`.`VolumeSnapshotVO`; | ||
| CREATE VIEW `zstack`.`VolumeSnapshotVO` AS | ||
| SELECT uuid, name, description, type, volumeUuid, format, treeUuid, parentUuid, | ||
| primaryStorageUuid, primaryStorageInstallPath, distance, size, latest, | ||
| fullSnapshot, encrypted, volumeType, state, status, createDate, lastOpDate | ||
| FROM `zstack`.`VolumeSnapshotEO` | ||
| WHERE deleted IS NULL; |
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
28 changes: 28 additions & 0 deletions
28
header/src/main/java/org/zstack/header/secret/SecretHostEnsureLuksSecretFileMsg.java
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,28 @@ | ||
| package org.zstack.header.secret; | ||
|
|
||
| import org.zstack.header.host.HostMessage; | ||
| import org.zstack.header.log.NoLogging; | ||
| import org.zstack.header.message.NeedReplyMessage; | ||
|
|
||
| public class SecretHostEnsureLuksSecretFileMsg extends NeedReplyMessage implements HostMessage { | ||
| private String hostUuid; | ||
| @NoLogging | ||
| private String dekBase64; | ||
|
|
||
| @Override | ||
| public String getHostUuid() { | ||
| return hostUuid; | ||
| } | ||
|
|
||
| public void setHostUuid(String hostUuid) { | ||
| this.hostUuid = hostUuid; | ||
| } | ||
|
|
||
| public String getDekBase64() { | ||
| return dekBase64; | ||
| } | ||
|
|
||
| public void setDekBase64(String dekBase64) { | ||
| this.dekBase64 = dekBase64; | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
header/src/main/java/org/zstack/header/secret/SecretHostEnsureLuksSecretFileReply.java
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,18 @@ | ||
| package org.zstack.header.secret; | ||
|
|
||
| import org.zstack.header.message.MessageReply; | ||
|
|
||
| public class SecretHostEnsureLuksSecretFileReply extends MessageReply { | ||
| public static final String ERROR_CODE_KEYS_NOT_ON_DISK = "KEY_AGENT_KEYS_NOT_ON_DISK"; | ||
| public static final String ERROR_CODE_KEY_FILES_INTEGRITY_MISMATCH = "KEY_AGENT_KEY_FILES_INTEGRITY_MISMATCH"; | ||
|
|
||
| private String secFilePath; | ||
|
|
||
| public String getSecFilePath() { | ||
| return secFilePath; | ||
| } | ||
|
|
||
| public void setSecFilePath(String secFilePath) { | ||
| this.secFilePath = secFilePath; | ||
| } | ||
| } |
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.
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.
attach-existing 路径不能复用“创建失败就删卷”的回滚语义。
这里的
volumeInventory指向的是调用方传入的现有数据卷,但当前类的rollback()只要看到volumeInventory != null就会发送DeleteVolumeMsg。现在又在同一路径前面插入了原地加密流程,后续任一步失败都会把现有卷当成临时资源删掉,存在直接数据丢失风险。建议显式区分“本流程创建的卷”和“外部传入的卷”,只有前者才允许在回滚里删除。🔧 修正方向
class VmInstantiateOtherDiskFlow implements Flow { DiskAO diskAO; VolumeInventory volumeInventory; + boolean deleteVolumeOnRollback; ... CreateVolumeReply cr = reply.castReply(); volumeInventory = cr.getInventory(); + deleteVolumeOnRollback = true; innerTrigger.next(); ... volumeInventory = VolumeInventory.valueOf(vo); + deleteVolumeOnRollback = true; innerTrigger.next(); ... public void rollback(FlowRollback chain, Map data) { - if (volumeInventory == null) { + if (volumeInventory == null || !deleteVolumeOnRollback) { chain.rollback(); return; }Also applies to: 423-458
🤖 Prompt for AI Agents