Skip to content

Commit 52bfa16

Browse files
authored
Added entry_location_rocksdb.conf (#216)
1 parent ca9ded9 commit 52bfa16

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

operator/src/main/java/com/datastax/oss/kaap/controllers/BaseResourcesFactory.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
import java.util.Map;
8080
import java.util.Objects;
8181
import java.util.Optional;
82+
import java.util.regex.Matcher;
83+
import java.util.regex.Pattern;
8284
import java.util.stream.Collectors;
8385
import lombok.extern.jbosslog.JBossLog;
8486
import org.apache.commons.codec.digest.DigestUtils;
@@ -88,6 +90,15 @@
8890
@JBossLog
8991
public abstract class BaseResourcesFactory<T> {
9092

93+
// Regex to capture the version string after a colon and optionally extract major version
94+
// This pattern looks for a colon, then captures the entire version string
95+
// The first group (\\d+) specifically captures the major version
96+
public static final Pattern IMAGE_STRING_PATTERN = Pattern.compile(
97+
":(?<fullVersion>(\\d+)(?:\\.\\d+){0,2}(?:[\\-][a-zA-Z0-9\\.]+)?)");
98+
99+
public static final Pattern MAJOR_VERSION_PATTERN = Pattern.compile("^(\\d+)");
100+
101+
91102
public static final String CONFIG_PULSAR_PREFIX = "PULSAR_PREFIX_";
92103
public static final String DEPLOYMENT_REVISION_ANNOTATION = "deployment.kubernetes.io/revision";
93104
protected final KubernetesClient client;
@@ -1137,4 +1148,25 @@ protected static List<Container> getSidecars(List<Container> containers) {
11371148
}
11381149
return containers;
11391150
}
1151+
1152+
public int getPulsarMajorVersion(String imageString) {
1153+
int pulsarMajorVersion = 2;
1154+
if (imageString == null) {
1155+
return pulsarMajorVersion;
1156+
}
1157+
Matcher imageStringMatcher = IMAGE_STRING_PATTERN.matcher(imageString);
1158+
1159+
if (imageStringMatcher.find()) {
1160+
String fullVersion = imageStringMatcher.group("fullVersion");
1161+
System.out.println("Full Version: " + fullVersion);
1162+
// Extract the major version specifically from the fullVersion string
1163+
Matcher majorVersionMatcher = MAJOR_VERSION_PATTERN.matcher(fullVersion);
1164+
if (majorVersionMatcher.find()) {
1165+
String majorVersionStr = majorVersionMatcher.group(1);
1166+
System.out.println("Major Version: " + majorVersionStr);
1167+
pulsarMajorVersion = Integer.parseInt(majorVersionStr);
1168+
}
1169+
}
1170+
return pulsarMajorVersion;
1171+
}
11401172
}

operator/src/main/java/com/datastax/oss/kaap/controllers/autorecovery/AutorecoveryResourcesFactory.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,15 @@ public void patchDeployment() {
140140
addTlsVolumes(volumeMounts, volumes, getTlsSecretNameForAutorecovery());
141141
}
142142
String mainArg = "bin/apply-config-from-env.py conf/bookkeeper.conf && ";
143-
if (tlsEnabledOnBookKeeper) {
143+
144+
int pulsarMajorVersion = getPulsarMajorVersion(spec.getImage());
145+
if (pulsarMajorVersion >= 4) {
146+
mainArg += "bin/update-ini-from-env.py conf/entry_location_rocksdb.conf PULSAR_PREFIX_entry_location_rocksdb_ && ";
147+
} else if (pulsarMajorVersion >= 3) {
148+
mainArg += "bin/apply-config-from-env.py conf/entry_location_rocksdb.conf --prefix PULSAR_PREFIX_entry_location_rocksdb_TableOptions_ && ";
149+
}
150+
151+
if (tlsEnabledOnBookKeeper) {
144152
mainArg += "openssl pkcs8 -topk8 -inform PEM -outform PEM -in /pulsar/certs/tls.key "
145153
+ "-out /pulsar/tls-pk8.key -nocrypt && ";
146154
}

operator/src/main/java/com/datastax/oss/kaap/controllers/bookkeeper/BookKeeperResourcesFactory.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class BookKeeperResourcesFactory extends BaseResourcesFactory<BookKeeperS
5959
public static final int DEFAULT_BK_PORT = 3181;
6060
public static final int DEFAULT_HTTP_PORT = 8000;
6161

62+
6263
public static List<String> getInitContainerNames(String clusterName, String baseName) {
6364
return List.of(getMainContainerName(clusterName, baseName));
6465
}
@@ -247,6 +248,14 @@ public StatefulSet generateStatefulSet() {
247248
);
248249

249250
String mainArg = "bin/apply-config-from-env.py conf/bookkeeper.conf && ";
251+
252+
int pulsarMajorVersion = getPulsarMajorVersion(spec.getImage());
253+
if (pulsarMajorVersion >= 4) {
254+
mainArg += "bin/update-ini-from-env.py conf/entry_location_rocksdb.conf PULSAR_PREFIX_entry_location_rocksdb_ && ";
255+
} else if (pulsarMajorVersion >= 3) {
256+
mainArg += "bin/apply-config-from-env.py conf/entry_location_rocksdb.conf --prefix PULSAR_PREFIX_entry_location_rocksdb_TableOptions_ && ";
257+
}
258+
250259
final boolean tlsEnabledOnBookKeeper = isTlsEnabledOnBookKeeper();
251260
if (tlsEnabledOnBookKeeper) {
252261
mainArg +=

0 commit comments

Comments
 (0)