|
10 | 10 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
11 | 11 | import com.google.common.collect.ImmutableSet; |
12 | 12 | import com.yugabyte.yw.commissioner.Common.CloudType; |
| 13 | +import com.yugabyte.yw.commissioner.tasks.UniverseTaskBase.ServerType; |
13 | 14 | import com.yugabyte.yw.common.PlatformServiceException; |
14 | 15 | import com.yugabyte.yw.common.Util; |
15 | 16 | import com.yugabyte.yw.common.config.GlobalConfKeys; |
16 | 17 | import com.yugabyte.yw.common.config.RuntimeConfigFactory; |
| 18 | +import com.yugabyte.yw.common.gflags.GFlagsUtil; |
17 | 19 | import com.yugabyte.yw.common.gflags.GFlagsValidation; |
18 | 20 | import com.yugabyte.yw.common.inject.StaticInjectorHolder; |
19 | 21 | import com.yugabyte.yw.models.Universe; |
20 | 22 | import com.yugabyte.yw.models.common.YbaApi; |
21 | 23 | import com.yugabyte.yw.models.common.YbaApi.YbaApiVisibility; |
| 24 | +import com.yugabyte.yw.models.helpers.NodeDetails; |
22 | 25 | import io.swagger.annotations.ApiModelProperty; |
| 26 | +import java.util.Map; |
23 | 27 | import java.util.Set; |
| 28 | +import java.util.regex.Matcher; |
| 29 | +import java.util.regex.Pattern; |
| 30 | +import lombok.extern.slf4j.Slf4j; |
| 31 | +import org.apache.commons.lang3.StringUtils; |
24 | 32 | import play.mvc.Http.Status; |
25 | 33 |
|
26 | 34 | @JsonIgnoreProperties(ignoreUnknown = true) |
27 | 35 | @JsonDeserialize(converter = SoftwareUpgradeParams.Converter.class) |
| 36 | +@Slf4j |
28 | 37 | public class SoftwareUpgradeParams extends UpgradeTaskParams { |
29 | 38 |
|
30 | 39 | public String ybSoftwareVersion = null; |
@@ -141,15 +150,55 @@ public void verifyParams(Universe universe, boolean isFirstTry) { |
141 | 150 | boolean isYsqlMajorVersionUpgrade = |
142 | 151 | gFlagsValidation.ysqlMajorVersionUpgrade(currentVersion, ybSoftwareVersion); |
143 | 152 |
|
144 | | - if (isYsqlMajorVersionUpgrade |
145 | | - && currentIntent.enableYSQL |
146 | | - && Util.compareYBVersions( |
147 | | - currentVersion, "2024.2.1.0-b1", "2.25.0.0-b1", true /* suppressFormatError */) |
148 | | - < 0) { |
149 | | - throw new PlatformServiceException( |
150 | | - Status.BAD_REQUEST, |
151 | | - "YSQL major version upgrade is only supported from 2024.2.1.0-b1. Please upgrade to a" |
152 | | - + " version >= 2024.2.1.0-b1 before proceeding with the upgrade."); |
| 153 | + if (isYsqlMajorVersionUpgrade && currentIntent.enableYSQL) { |
| 154 | + if (Util.compareYBVersions( |
| 155 | + currentVersion, "2024.2.1.0-b1", "2.25.0.0-b1", true /* suppressFormatError */) |
| 156 | + < 0) { |
| 157 | + throw new PlatformServiceException( |
| 158 | + Status.BAD_REQUEST, |
| 159 | + "YSQL major version upgrade is only supported from 2024.2.1.0-b1. Please upgrade to a" |
| 160 | + + " version >= 2024.2.1.0-b1 before proceeding with the upgrade."); |
| 161 | + } |
| 162 | + |
| 163 | + for (Cluster cluster : universe.getUniverseDetails().clusters) { |
| 164 | + for (NodeDetails node : universe.getNodesInCluster(cluster.uuid)) { |
| 165 | + if (node.isMaster) { |
| 166 | + validateYSQLHBAConfEntriesForYSQLMajorUpgrade( |
| 167 | + universe, cluster, node, ServerType.MASTER); |
| 168 | + } |
| 169 | + if (node.isTserver) { |
| 170 | + validateYSQLHBAConfEntriesForYSQLMajorUpgrade( |
| 171 | + universe, cluster, node, ServerType.TSERVER); |
| 172 | + } |
| 173 | + } |
| 174 | + } |
| 175 | + } |
| 176 | + } |
| 177 | + |
| 178 | + private void validateYSQLHBAConfEntriesForYSQLMajorUpgrade( |
| 179 | + Universe universe, Cluster cluster, NodeDetails node, ServerType serverType) { |
| 180 | + Map<String, String> gflag = |
| 181 | + GFlagsUtil.getGFlagsForNode( |
| 182 | + node, serverType, cluster, universe.getUniverseDetails().clusters); |
| 183 | + if (gflag.containsKey(GFlagsUtil.YSQL_HBA_CONF_CSV)) { |
| 184 | + String hbaConfValue = gflag.get(GFlagsUtil.YSQL_HBA_CONF_CSV); |
| 185 | + if (StringUtils.isEmpty(hbaConfValue)) { |
| 186 | + return; |
| 187 | + } |
| 188 | + String regex = "clientcert\\s*=\\s*(\\d+)"; |
| 189 | + Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); |
| 190 | + Matcher matcher = pattern.matcher(hbaConfValue); |
| 191 | + if (matcher.find()) { |
| 192 | + String value = matcher.group(1); |
| 193 | + if (value.equals("1")) { |
| 194 | + throw new PlatformServiceException( |
| 195 | + Status.BAD_REQUEST, |
| 196 | + "YSQL major version upgrade is not supported when clientcert=1 is present in the" |
| 197 | + + " ysql_hba_conf_csv. Please update the clientcert=1 entry with equivalent PG-15" |
| 198 | + + " value with before proceeding with the upgrade. Update the value to" |
| 199 | + + " clientcert=verify-ca or clientcert=verify-full before proceeding."); |
| 200 | + } |
| 201 | + } |
153 | 202 | } |
154 | 203 | } |
155 | 204 |
|
|
0 commit comments