|
13 | 13 | import com.yugabyte.yw.common.certmgmt.CertConfigType; |
14 | 14 | import com.yugabyte.yw.common.certmgmt.CertificateHelper; |
15 | 15 | import com.yugabyte.yw.common.certmgmt.EncryptionInTransitUtil; |
| 16 | +import com.yugabyte.yw.common.config.GlobalConfKeys; |
| 17 | +import com.yugabyte.yw.common.config.RuntimeConfGetter; |
| 18 | +import com.yugabyte.yw.common.inject.StaticInjectorHolder; |
16 | 19 | import com.yugabyte.yw.models.CertificateInfo; |
17 | 20 | import com.yugabyte.yw.models.Universe; |
18 | 21 | import com.yugabyte.yw.models.helpers.CommonUtils; |
@@ -81,6 +84,56 @@ private void verifyCertificateValidity(Universe universe) { |
81 | 84 | } |
82 | 85 | } |
83 | 86 |
|
| 87 | + private void verifyNonRestartUpgradeSupport(Universe universe) { |
| 88 | + UserIntent userIntent = universe.getUniverseDetails().getPrimaryCluster().userIntent; |
| 89 | + String softwareVersion = userIntent.ybSoftwareVersion; |
| 90 | + |
| 91 | + // Check if YB version supports cert reload (>= 2.14.0.0-b1) |
| 92 | + if (Util.compareYbVersions(softwareVersion, "2.14.0.0-b1", true) < 0) { |
| 93 | + throw new PlatformServiceException( |
| 94 | + Status.BAD_REQUEST, |
| 95 | + "Non-restart certificate rotation is not supported for universe with software version: " |
| 96 | + + softwareVersion |
| 97 | + + ". Minimum required version is 2.14.0.0-b1."); |
| 98 | + } |
| 99 | + |
| 100 | + // Check if cert reload feature flag is enabled |
| 101 | + if (runtimeConfGetter == null) { |
| 102 | + runtimeConfGetter = StaticInjectorHolder.injector().instanceOf(RuntimeConfGetter.class); |
| 103 | + } |
| 104 | + boolean featureFlagEnabled = runtimeConfGetter.getGlobalConf(GlobalConfKeys.enableCertReload); |
| 105 | + if (!featureFlagEnabled) { |
| 106 | + throw new PlatformServiceException( |
| 107 | + Status.BAD_REQUEST, |
| 108 | + "Non-restart certificate rotation requires the cert reload feature to be enabled. " |
| 109 | + + "Please enable the feature flag 'yb.features.cert_reload.enabled' and retry."); |
| 110 | + } |
| 111 | + |
| 112 | + // Check if universe is configured for cert reload |
| 113 | + boolean universeConfigured = |
| 114 | + Boolean.parseBoolean( |
| 115 | + universe |
| 116 | + .getConfig() |
| 117 | + .getOrDefault(Universe.KEY_CERT_HOT_RELOADABLE, Boolean.FALSE.toString())); |
| 118 | + if (!universeConfigured) { |
| 119 | + throw new PlatformServiceException( |
| 120 | + Status.BAD_REQUEST, |
| 121 | + "Non-restart certificate rotation requires the universe to be configured for cert " |
| 122 | + + "reload. The universe will be automatically configured during the first cert " |
| 123 | + + "rotation, but for non-restart upgrades, it must be configured beforehand. " |
| 124 | + + "Please perform a rolling cert rotation first to configure the universe."); |
| 125 | + } |
| 126 | + |
| 127 | + // Check if node-to-node certs are expired (non-restart upgrade cannot proceed if expired) |
| 128 | + boolean n2nCertExpired = CertificateHelper.checkNode2NodeCertsExpiry(universe); |
| 129 | + if (n2nCertExpired) { |
| 130 | + throw new PlatformServiceException( |
| 131 | + Status.BAD_REQUEST, |
| 132 | + "Non-restart certificate rotation cannot be performed when node-to-node certificates " |
| 133 | + + "have expired. Please use rolling or non-rolling upgrade option instead."); |
| 134 | + } |
| 135 | + } |
| 136 | + |
84 | 137 | private void commonValidation(Universe universe) { |
85 | 138 | UniverseDefinitionTaskParams universeDetails = universe.getUniverseDetails(); |
86 | 139 | UserIntent userIntent = universeDetails.getPrimaryCluster().userIntent; |
@@ -113,8 +166,9 @@ private void verifyParamsForNormalUpgrade(Universe universe, boolean isFirstTry) |
113 | 166 | UUID currentRootCA = universeDetails.rootCA; |
114 | 167 | UUID currentClientRootCA = universeDetails.clientRootCA; |
115 | 168 |
|
| 169 | + // Validate non-restart upgrade option for non-Kubernetes universes |
116 | 170 | if (upgradeOption == UpgradeOption.NON_RESTART_UPGRADE) { |
117 | | - throw new PlatformServiceException(Status.BAD_REQUEST, "Cert upgrade cannot be non restart."); |
| 171 | + verifyNonRestartUpgradeSupport(universe); |
118 | 172 | } |
119 | 173 |
|
120 | 174 | // Make sure rootCA and clientRootCA respects the rootAndClientRootCASame property |
|
0 commit comments