forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
<feature>[utils]: Network group high availability strategy #3402
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-2
wants to merge
1
commit into
feature-5.5.6-dpu-net-ha2
Choose a base branch
from
sync/haoyu.ding/fv-81413@@3
base: feature-5.5.6-dpu-net-ha2
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.
+963
−0
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| CREATE TABLE IF NOT EXISTS `zstack`.`HaNetworkGroupVO` ( | ||
| `uuid` VARCHAR(32) NOT NULL UNIQUE COMMENT 'uuid', | ||
| `name` VARCHAR(255) NOT NULL, | ||
| `description` VARCHAR(2048) DEFAULT NULL, | ||
| `clusterUuid` VARCHAR(32) NOT NULL, | ||
| `type` VARCHAR(128) NOT NULL, | ||
| `minAvailableCount` INT(10) NOT NULL DEFAULT 1, | ||
| `configVersion` BIGINT UNSIGNED NOT NULL DEFAULT 0, | ||
| `state` VARCHAR(32) NOT NULL DEFAULT 'Enabled', | ||
| `lastOpDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, | ||
| `createDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
| PRIMARY KEY (`uuid`), | ||
| CONSTRAINT `fkHaNetworkGroupVOClusterEO` FOREIGN KEY (`clusterUuid`) REFERENCES `zstack`.`ClusterEO` (`uuid`) ON DELETE CASCADE | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `zstack`.`HaNetworkGroupL3NetworkRefVO` ( | ||
| `uuid` VARCHAR(32) NOT NULL UNIQUE COMMENT 'uuid', | ||
| `haNetworkGroupUuid` VARCHAR(32) NOT NULL, | ||
| `l3NetworkUuid` VARCHAR(32) NOT NULL, | ||
| `lastOpDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, | ||
| `createDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
| PRIMARY KEY (`uuid`), | ||
| INDEX `idxHaNetworkGroupL3NetworkRefVOhaNetworkGroupUuid` (`haNetworkGroupUuid`), | ||
| INDEX `idxHaNetworkGroupL3NetworkRefVOl3NetworkUuid` (`l3NetworkUuid`), | ||
| CONSTRAINT `fkHaNetworkGroupL3NetworkRefVOHaNetworkGroupVO` FOREIGN KEY (`haNetworkGroupUuid`) REFERENCES `zstack`.`HaNetworkGroupVO` (`uuid`) ON DELETE CASCADE, | ||
| CONSTRAINT `fkHaNetworkGroupL3NetworkRefVOL3NetworkEO` FOREIGN KEY (`l3NetworkUuid`) REFERENCES `zstack`.`L3NetworkEO` (`uuid`) ON DELETE CASCADE | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
|
||
| CREATE TABLE IF NOT EXISTS `zstack`.`HostHaNetworkGroupStatusVO` ( | ||
| `uuid` VARCHAR(32) NOT NULL UNIQUE COMMENT 'uuid', | ||
| `hostUuid` VARCHAR(32) NOT NULL, | ||
| `networkGroupUuid` VARCHAR(32) NOT NULL, | ||
| `status` VARCHAR(32) NOT NULL DEFAULT 'Unknown', | ||
| `lastOpDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, | ||
| `createDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
| PRIMARY KEY (`uuid`), | ||
| INDEX `idxHostHaNetworkGroupStatusVOhostUuid` (`hostUuid`), | ||
| INDEX `idxHostHaNetworkGroupStatusVOnetworkGroupUuid` (`networkGroupUuid`), | ||
| CONSTRAINT `fkHostHaNetworkGroupStatusVOHostEO` FOREIGN KEY (`hostUuid`) REFERENCES `zstack`.`HostEO` (`uuid`) ON DELETE CASCADE, | ||
| CONSTRAINT `fkHostHaNetworkGroupStatusVOHaNetworkGroupVO` FOREIGN KEY (`networkGroupUuid`) REFERENCES `zstack`.`HaNetworkGroupVO` (`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
104 changes: 104 additions & 0 deletions
104
sdk/src/main/java/org/zstack/sdk/ChangeHaNetworkGroupStateAction.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,104 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.zstack.sdk.*; | ||
|
|
||
| public class ChangeHaNetworkGroupStateAction extends AbstractAction { | ||
|
|
||
| private static final HashMap<String, Parameter> parameterMap = new HashMap<>(); | ||
|
|
||
| private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>(); | ||
|
|
||
| public static class Result { | ||
| public ErrorCode error; | ||
| public org.zstack.sdk.ChangeHaNetworkGroupStateResult value; | ||
|
|
||
| public Result throwExceptionIfError() { | ||
| if (error != null) { | ||
| throw new ApiException( | ||
| String.format("error[code: %s, description: %s, details: %s, globalErrorCode: %s]", error.code, error.description, error.details, error.globalErrorCode) | ||
| ); | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
| } | ||
|
|
||
| @Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String uuid; | ||
|
|
||
| @Param(required = true, validValues = {"enable","disable"}, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String stateEvent; | ||
|
|
||
| @Param(required = false) | ||
| public java.util.List systemTags; | ||
|
|
||
| @Param(required = false) | ||
| public java.util.List userTags; | ||
|
|
||
| @Param(required = false) | ||
| public String sessionId; | ||
|
|
||
| @Param(required = false) | ||
| public String accessKeyId; | ||
|
|
||
| @Param(required = false) | ||
| public String accessKeySecret; | ||
|
|
||
| @Param(required = false) | ||
| public String requestIp; | ||
|
|
||
| @NonAPIParam | ||
| public long timeout = -1; | ||
|
|
||
| @NonAPIParam | ||
| public long pollingInterval = -1; | ||
|
|
||
|
|
||
| private Result makeResult(ApiResult res) { | ||
| Result ret = new Result(); | ||
| if (res.error != null) { | ||
| ret.error = res.error; | ||
| return ret; | ||
| } | ||
|
|
||
| org.zstack.sdk.ChangeHaNetworkGroupStateResult value = res.getResult(org.zstack.sdk.ChangeHaNetworkGroupStateResult.class); | ||
| ret.value = value == null ? new org.zstack.sdk.ChangeHaNetworkGroupStateResult() : value; | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
| public Result call() { | ||
| ApiResult res = ZSClient.call(this); | ||
| return makeResult(res); | ||
| } | ||
|
|
||
| public void call(final Completion<Result> completion) { | ||
| ZSClient.call(this, new InternalCompletion() { | ||
| @Override | ||
| public void complete(ApiResult res) { | ||
| completion.complete(makeResult(res)); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| protected Map<String, Parameter> getParameterMap() { | ||
| return parameterMap; | ||
| } | ||
|
|
||
| protected Map<String, Parameter> getNonAPIParameterMap() { | ||
| return nonAPIParameterMap; | ||
| } | ||
|
|
||
| protected RestInfo getRestInfo() { | ||
| RestInfo info = new RestInfo(); | ||
| info.httpMethod = "PUT"; | ||
| info.path = "/ha/network-groups/{uuid}/actions"; | ||
| info.needSession = true; | ||
| info.needPoll = true; | ||
| info.parameterName = "changeHaNetworkGroupState"; | ||
| return info; | ||
| } | ||
|
|
||
| } |
14 changes: 14 additions & 0 deletions
14
sdk/src/main/java/org/zstack/sdk/ChangeHaNetworkGroupStateResult.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,14 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| import org.zstack.sdk.HaNetworkGroupInventory; | ||
|
|
||
| public class ChangeHaNetworkGroupStateResult { | ||
| public HaNetworkGroupInventory inventory; | ||
| public void setInventory(HaNetworkGroupInventory inventory) { | ||
| this.inventory = inventory; | ||
| } | ||
| public HaNetworkGroupInventory getInventory() { | ||
| return this.inventory; | ||
| } | ||
|
|
||
| } |
122 changes: 122 additions & 0 deletions
122
sdk/src/main/java/org/zstack/sdk/CreateHaNetworkGroupAction.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,122 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.zstack.sdk.*; | ||
|
|
||
| public class CreateHaNetworkGroupAction extends AbstractAction { | ||
|
|
||
| private static final HashMap<String, Parameter> parameterMap = new HashMap<>(); | ||
|
|
||
| private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>(); | ||
|
|
||
| public static class Result { | ||
| public ErrorCode error; | ||
| public org.zstack.sdk.CreateHaNetworkGroupResult value; | ||
|
|
||
| public Result throwExceptionIfError() { | ||
| if (error != null) { | ||
| throw new ApiException( | ||
| String.format("error[code: %s, description: %s, details: %s, globalErrorCode: %s]", error.code, error.description, error.details, error.globalErrorCode) | ||
| ); | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
| } | ||
|
|
||
| @Param(required = true, maxLength = 255, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String name; | ||
|
|
||
| @Param(required = false, maxLength = 2048, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String description; | ||
|
|
||
| @Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String clusterUuid; | ||
|
|
||
| @Param(required = true, validValues = {"Flat","Public"}, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String type; | ||
|
|
||
| @Param(required = true, nonempty = false, nullElements = false, emptyString = true, numberRange = {1L,2147483647L}, noTrim = false) | ||
| public int minAvailableCount = 0; | ||
|
|
||
| @Param(required = true, nonempty = true, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.util.List l3NetworkUuids; | ||
|
|
||
| @Param(required = false) | ||
| public java.lang.String resourceUuid; | ||
|
|
||
| @Param(required = false, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.util.List tagUuids; | ||
|
|
||
| @Param(required = false) | ||
| public java.util.List systemTags; | ||
|
|
||
| @Param(required = false) | ||
| public java.util.List userTags; | ||
|
|
||
| @Param(required = false) | ||
| public String sessionId; | ||
|
|
||
| @Param(required = false) | ||
| public String accessKeyId; | ||
|
|
||
| @Param(required = false) | ||
| public String accessKeySecret; | ||
|
|
||
| @Param(required = false) | ||
| public String requestIp; | ||
|
|
||
| @NonAPIParam | ||
| public long timeout = -1; | ||
|
|
||
| @NonAPIParam | ||
| public long pollingInterval = -1; | ||
|
|
||
|
|
||
| private Result makeResult(ApiResult res) { | ||
| Result ret = new Result(); | ||
| if (res.error != null) { | ||
| ret.error = res.error; | ||
| return ret; | ||
| } | ||
|
|
||
| org.zstack.sdk.CreateHaNetworkGroupResult value = res.getResult(org.zstack.sdk.CreateHaNetworkGroupResult.class); | ||
| ret.value = value == null ? new org.zstack.sdk.CreateHaNetworkGroupResult() : value; | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
| public Result call() { | ||
| ApiResult res = ZSClient.call(this); | ||
| return makeResult(res); | ||
| } | ||
|
|
||
| public void call(final Completion<Result> completion) { | ||
| ZSClient.call(this, new InternalCompletion() { | ||
| @Override | ||
| public void complete(ApiResult res) { | ||
| completion.complete(makeResult(res)); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| protected Map<String, Parameter> getParameterMap() { | ||
| return parameterMap; | ||
| } | ||
|
|
||
| protected Map<String, Parameter> getNonAPIParameterMap() { | ||
| return nonAPIParameterMap; | ||
| } | ||
|
|
||
| protected RestInfo getRestInfo() { | ||
| RestInfo info = new RestInfo(); | ||
| info.httpMethod = "POST"; | ||
| info.path = "/ha/network-groups"; | ||
| info.needSession = true; | ||
| info.needPoll = true; | ||
| info.parameterName = "params"; | ||
| return info; | ||
| } | ||
|
|
||
| } |
14 changes: 14 additions & 0 deletions
14
sdk/src/main/java/org/zstack/sdk/CreateHaNetworkGroupResult.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,14 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| import org.zstack.sdk.HaNetworkGroupInventory; | ||
|
|
||
| public class CreateHaNetworkGroupResult { | ||
| public HaNetworkGroupInventory inventory; | ||
| public void setInventory(HaNetworkGroupInventory inventory) { | ||
| this.inventory = inventory; | ||
| } | ||
| public HaNetworkGroupInventory getInventory() { | ||
| return this.inventory; | ||
| } | ||
|
|
||
| } |
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.
🧩 Analysis chain
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 48882
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 1696
🏁 Script executed:
Repository: MatheMatrix/zstack
Length of output: 30493
新增命令类缺少版本标注,且
enableHa处理逻辑不一致。UpdateVmEnableHaLiveCmd和ReconcileVmEnableHaOnHostCmd均缺少@GrayVersion注解。新增的命令类应遵循项目规范,明确标注其首次可用版本。StartVmCmd.enableHa标注为@GrayVersion("5.5.12"),但项目当前版本为 5.5.0,且同文件其他 5.5.x 特性标注为 5.5.0 或 5.5.6。版本号应与实际功能首次可用版本对齐,避免灰度阶段低版本 agent 接收不到该字段。UpdateVmEnableHaLiveCmd.setEnableHa()无 null 处理,而StartVmCmd.setEnableHa()做了enableHa == null ? false : enableHa的转换。两者应保持一致的 null 处理策略,以确保灰度下的行为预期一致。🤖 Prompt for AI Agents