Copilot commented on code in PR #14033:
URL: https://github.com/apache/cloudstack/pull/14033#discussion_r4015200832
##########
engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java:
##########
@@ -513,8 +515,8 @@ protected void doUpgrades(GlobalLock lock) {
String csVersion = parseSystemVmMetadata();
final CloudStackVersion sysVmVersion =
CloudStackVersion.parse(csVersion);
final CloudStackVersion currentVersion =
CloudStackVersion.parse(currentVersionValue);
- SystemVmTemplateRegistration.CS_MAJOR_VERSION =
sysVmVersion.getMajorRelease() + "." + sysVmVersion.getMinorRelease();
- SystemVmTemplateRegistration.CS_TINY_VERSION =
String.valueOf(sysVmVersion.getPatchRelease());
+ SystemVmTemplateRegistration.CS_MAJOR_VERSION =
String.format("%d.%d", sysVmVersion.getMajorRelease(),
sysVmVersion.getMinorRelease());
+ SystemVmTemplateRegistration.CS_TINY_VERSION =
String.valueOf(sysVmVersion.usesNewVersioning() ?
sysVmVersion.getSecurityRelease() : sysVmVersion.getPatchRelease());
Review Comment:
The new-format branch cannot be reached with metadata generated for a 24.0.0
system VM: `engine/schema/templateConfig.sh` always writes `version =
$VERSION.${securityversion}`, so a three-component input produces `24.0.0.`.
`parseSystemVmMetadata()` passes that value to `CloudStackVersion.parse` before
this assignment and aborts on the trailing dot. Update metadata generation to
emit `24.0.0` for new-versioning releases while retaining the fourth legacy
component for older releases.
##########
utils/src/main/java/org/apache/cloudstack/utils/CloudStackVersion.java:
##########
@@ -100,8 +103,26 @@ public static CloudStackVersion parse(final String value) {
final int majorRelease = Integer.valueOf(components[0]);
final int minorRelease = Integer.valueOf(components[1]);
- final int patchRelease = Integer.valueOf(components[2]);
- final Integer securityRelease = components.length == 3 ? null :
Integer.valueOf(components[3]);
+ final int thirdComponent = Integer.valueOf(components[2]);
+
+ final int patchRelease;
+ final Integer securityRelease;
+
+ if (components.length == 4) {
+ checkArgument(isLegacyVersioning(majorRelease),
CloudStackVersion.class.getName() + ".parse(String) passed " + value +
+ ", but major versions at or above 24 do not support legacy
int.int.int.int format");
+ // Deprecated legacy format: major.minor.patch.security
+ patchRelease = thirdComponent;
+ securityRelease = Integer.valueOf(components[3]);
+ } else if (isNewVersioning(majorRelease)) {
+ // New format: major.minor.securityRelease (patch dropped)
+ patchRelease = 0;
+ securityRelease = thirdComponent;
Review Comment:
The new parser requires 24.x metadata to be exactly `major.minor.security`,
but `engine/schema/templateConfig.sh` still writes `version =
$VERSION.${securityversion}`. For a 24.0.0 template this produces `24.0.0.`
(and a 24.0.0.0 input produces four components), so `parseSystemVmMetadata()`
will reject the metadata before the upgrade can set
`CS_MAJOR_VERSION`/`CS_TINY_VERSION`. Update the metadata generation or
normalize this value before parsing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]