Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions conf/db/zsv/V5.1.0__schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,47 @@ DELETE shadow FROM ImageCacheShadowVO shadow
LEFT JOIN PrimaryStorageEO ps ON shadow.primaryStorageUuid = ps.uuid
WHERE ps.uuid IS NULL;
CALL ADD_CONSTRAINT('ImageCacheShadowVO', 'fkImageCacheShadowVOPrimaryStorageEOCascade', 'primaryStorageUuid', 'PrimaryStorageEO', 'uuid', 'CASCADE');

-- Feature: Platform Service deployment | ZSV-12505

CREATE TABLE IF NOT EXISTS `zstack`.`PlatformServicePackageVO` (
`uuid` char(32) NOT NULL UNIQUE,
`name` varchar(255) DEFAULT NULL,
`description` varchar(2048) DEFAULT NULL,
`serviceType` varchar(32) NOT NULL,
`artifactType` varchar(32) NOT NULL,
`imageUuid` char(32) DEFAULT NULL,
`status` varchar(32) NOT NULL,
`version` varchar(255) DEFAULT NULL,
`activeApiId` varchar(255) DEFAULT NULL,
`lastError` varchar(4096) DEFAULT NULL,
`lastOpDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`createDate` timestamp NOT NULL DEFAULT '1999-12-31 23:59:59',
Comment on lines +282 to +283

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

createDate 建议使用 CURRENT_TIMESTAMP 而非固定哨兵值

两张新表的 createDate 均设置为 DEFAULT '1999-12-31 23:59:59',而非 CURRENT_TIMESTAMP。虽然不是 0000-00-00,但同样属于人为哨兵日期,不能准确反映记录创建时间。

💡 建议修改
-    `createDate` timestamp NOT NULL DEFAULT '1999-12-31 23:59:59',
+    `createDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,

As per path instructions, "Do not use DEFAULT 0000-00-00 00:00:00, use DEFAULT CURRENT_TIMESTAMP instead" — 建议按此原则统一处理 createDate 的默认值。

Also applies to: 224-225

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@conf/db/zsv/V5.1.0__schema.sql` around lines 199 - 200, The `createDate`
default in the schema uses a fixed sentinel timestamp instead of the actual
creation time. Update the `createDate` column definitions in the affected table
DDLs within `V5.1.0__schema.sql` to use `DEFAULT CURRENT_TIMESTAMP` (consistent
with the `lastOpDate` pattern) rather than the hardcoded 1999-12-31 value, and
apply the same change to both occurrences referenced in the review.

Source: Path instructions

PRIMARY KEY (`uuid`),
INDEX `idxPlatformServicePackageVOServiceType` (`serviceType`),
INDEX `idxPlatformServicePackageVOImageUuid` (`imageUuid`),
INDEX `idxPlatformServicePackageVOStatus` (`status`),
INDEX `idxPlatformServicePackageVOActiveApiId` (`activeApiId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `zstack`.`PlatformServiceInstanceVO` (
`uuid` char(32) NOT NULL UNIQUE,
`name` varchar(255) DEFAULT NULL,
`description` varchar(2048) DEFAULT NULL,
`serviceType` varchar(32) NOT NULL,
`packageUuid` char(32) NOT NULL,
`vmInstanceUuid` char(32) DEFAULT NULL,
`state` varchar(32) NOT NULL,
`healthStatus` varchar(32) NOT NULL,
`activeApiId` varchar(255) DEFAULT NULL,
`lastError` varchar(4096) DEFAULT NULL,
`lastHealthCheckTime` timestamp NULL DEFAULT NULL,
`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`),
INDEX `idxPlatformServiceInstanceVOServiceType` (`serviceType`),
INDEX `idxPlatformServiceInstanceVOPackageUuid` (`packageUuid`),
INDEX `idxPlatformServiceInstanceVOVmInstanceUuid` (`vmInstanceUuid`),
INDEX `idxPlatformServiceInstanceVOState` (`state`),
INDEX `idxPlatformServiceInstanceVOActiveApiId` (`activeApiId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
4 changes: 4 additions & 0 deletions sdk/src/main/java/org/zstack/sdk/SourceClassMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,8 @@ public class SourceClassMap {
put("org.zstack.pciDevice.virtual.vfio_mdev.MdevDeviceState", "org.zstack.sdk.MdevDeviceState");
put("org.zstack.pciDevice.virtual.vfio_mdev.MdevDeviceStatus", "org.zstack.sdk.MdevDeviceStatus");
put("org.zstack.pciDevice.virtual.vfio_mdev.MdevDeviceType", "org.zstack.sdk.MdevDeviceType");
put("org.zstack.platformservice.api.PlatformServiceInstanceInventory", "org.zstack.sdk.platformservice.PlatformServiceInstanceInventory");
put("org.zstack.platformservice.api.PlatformServicePackageInventory", "org.zstack.sdk.platformservice.PlatformServicePackageInventory");
put("org.zstack.policyRoute.PolicyRouteRuleInventory", "org.zstack.sdk.PolicyRouteRuleInventory");
put("org.zstack.policyRoute.PolicyRouteRuleProtocol", "org.zstack.sdk.PolicyRouteRuleProtocol");
put("org.zstack.policyRoute.PolicyRouteRuleSetInventory", "org.zstack.sdk.PolicyRouteRuleSetInventory");
Expand Down Expand Up @@ -1314,6 +1316,8 @@ public class SourceClassMap {
put("org.zstack.sdk.managements.common.ManagementNodeStatusView", "org.zstack.managements.entity.common.ManagementNodeStatusView");
put("org.zstack.sdk.managements.common.ManagementsStatusView", "org.zstack.managements.entity.common.ManagementsStatusView");
put("org.zstack.sdk.managements.ha2.ZSha2StatusView", "org.zstack.managements.entity.ha2.ZSha2StatusView");
put("org.zstack.sdk.platformservice.PlatformServiceInstanceInventory", "org.zstack.platformservice.api.PlatformServiceInstanceInventory");
put("org.zstack.sdk.platformservice.PlatformServicePackageInventory", "org.zstack.platformservice.api.PlatformServicePackageInventory");
put("org.zstack.sdk.sns.SNSApplicationEndpointInventory", "org.zstack.sns.SNSApplicationEndpointInventory");
put("org.zstack.sdk.sns.SNSApplicationPlatformInventory", "org.zstack.sns.SNSApplicationPlatformInventory");
put("org.zstack.sdk.sns.SNSSmsEndpointInventory", "org.zstack.sns.SNSSmsEndpointInventory");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package org.zstack.sdk.platformservice;

import java.util.HashMap;
import java.util.Map;
import org.zstack.sdk.*;

public class CheckPlatformServiceHealthAction 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.platformservice.CheckPlatformServiceHealthResult value;

public Result throwExceptionIfError() {
if (error != null) {
throw new ApiException(
String.format("error[code: %s, description: %s, details: %s]", error.code, error.description, error.details)
);
}

return this;
}
}

@Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String uuid;

@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.platformservice.CheckPlatformServiceHealthResult value = res.getResult(org.zstack.sdk.platformservice.CheckPlatformServiceHealthResult.class);
ret.value = value == null ? new org.zstack.sdk.platformservice.CheckPlatformServiceHealthResult() : 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 = "/platform-services/instances/{uuid}/actions";
info.needSession = true;
info.needPoll = true;
info.parameterName = "checkPlatformServiceHealth";
return info;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.zstack.sdk.platformservice;

import org.zstack.sdk.platformservice.PlatformServiceInstanceInventory;

public class CheckPlatformServiceHealthResult {
public PlatformServiceInstanceInventory inventory;
public void setInventory(PlatformServiceInstanceInventory inventory) {
this.inventory = inventory;
}
public PlatformServiceInstanceInventory getInventory() {
return this.inventory;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package org.zstack.sdk.platformservice;

import java.util.HashMap;
import java.util.Map;
import org.zstack.sdk.*;

public class DeletePlatformServicePackageAction 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.platformservice.DeletePlatformServicePackageResult value;

public Result throwExceptionIfError() {
if (error != null) {
throw new ApiException(
String.format("error[code: %s, description: %s, details: %s]", error.code, error.description, error.details)
);
}

return this;
}
}

@Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String uuid;

@Param(required = false)
public java.lang.String deleteMode = "Permissive";

@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.platformservice.DeletePlatformServicePackageResult value = res.getResult(org.zstack.sdk.platformservice.DeletePlatformServicePackageResult.class);
ret.value = value == null ? new org.zstack.sdk.platformservice.DeletePlatformServicePackageResult() : 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 = "DELETE";
info.path = "/platform-services/packages/{uuid}";
info.needSession = true;
info.needPoll = true;
info.parameterName = "";
return info;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.zstack.sdk.platformservice;



public class DeletePlatformServicePackageResult {

}
Loading