Skip to content

Commit 54fd132

Browse files
authored
Merge pull request #585 from oracle/develop-feature-rolling-restart
Develop feature rolling restart
2 parents cb33f22 + 081c2cb commit 54fd132

File tree

18 files changed

+252
-12
lines changed

18 files changed

+252
-12
lines changed

model/src/main/java/oracle/kubernetes/operator/LabelConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public interface LabelConstants {
1717
String OPERATORNAME_LABEL = "weblogic.operatorName";
1818
String JOBNAME_LABEL = "job-name";
1919
String APP_LABEL = "app";
20+
String DOMAINRESTARTVERSION_LABEL = "weblogic.domainRestartVersion";
21+
String CLUSTERRESTARTVERSION_LABEL = "weblogic.clusterRestartVersion";
22+
String SERVERRESTARTVERSION_LABEL = "weblogic.serverRestartVersion";
2023

2124
static String forDomainUid(String uid) {
2225
return String.format("%s=%s", DOMAINUID_LABEL, uid);

model/src/main/java/oracle/kubernetes/weblogic/domain/ClusterConfigurator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ ClusterConfigurator withLivenessProbeSettings(
4747
ClusterConfigurator withServiceLabel(String name, String value);
4848

4949
ClusterConfigurator withServiceAnnotation(String name, String value);
50+
51+
ClusterConfigurator withRestartVersion(String restartVersion);
5052
}

model/src/main/java/oracle/kubernetes/weblogic/domain/DomainConfigurator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,12 @@ public abstract DomainConfigurator withContainerSecurityContext(
330330
*/
331331
public abstract DomainConfigurator withPodSecurityContext(
332332
V1PodSecurityContext podSecurityContext);
333+
334+
/**
335+
* Set the restart version for the Domain
336+
*
337+
* @param restartVersion
338+
* @return this object
339+
*/
340+
public abstract DomainConfigurator withRestartVersion(String restartVersion);
333341
}

model/src/main/java/oracle/kubernetes/weblogic/domain/ServerConfigurator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ ServerConfigurator withReadinessProbeSettings(
4545
ServerConfigurator withServiceLabel(String name, String value);
4646

4747
ServerConfigurator withServiceAnnotation(String name, String value);
48+
49+
ServerConfigurator withRestartVersion(String restartVersion);
4850
}

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/AdminServerSpecV2Impl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
public class AdminServerSpecV2Impl extends ServerSpecV2Impl {
88
public AdminServerSpecV2Impl(DomainSpec spec, AdminServer server) {
9-
super(spec, server, null, spec);
9+
super(spec, server, null, null);
1010
}
1111
}

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/BaseConfiguration.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ public abstract class BaseConfiguration {
4848
+ "Legal values are ADMIN_ONLY, NEVER, ALWAYS, or IF_NEEDED.")
4949
private String serverStartPolicy;
5050

51+
/**
52+
* Tells the operator whether the customer wants to restart the server pods. The value can be any
53+
* String and it can be defined on domain, cluster or server to restart the different pods. After
54+
* the value is added, the corresponding pods will be terminated and created again. If customer
55+
* modifies the value again after the pods were recreated, then the pods will again be terminated
56+
* and recreated.
57+
*
58+
* @since 2.0
59+
*/
60+
@Description(
61+
"If preseent, every time this value is updated the operator will restart"
62+
+ " the required servers")
63+
private String restartVersion;
64+
5165
/**
5266
* Fills in any undefined settings in this configuration from another configuration.
5367
*
@@ -205,12 +219,21 @@ void addServiceAnnotations(String name, String value) {
205219
serverPod.addServiceAnnotations(name, value);
206220
}
207221

222+
public String getRestartVersion() {
223+
return restartVersion;
224+
}
225+
226+
public void setRestartVersion(String restartVersion) {
227+
this.restartVersion = restartVersion;
228+
}
229+
208230
@Override
209231
public String toString() {
210232
return new ToStringBuilder(this)
211233
.append("serverStartState", serverStartState)
212234
.append("serverStartPolicy", serverStartPolicy)
213235
.append("serverPod", serverPod)
236+
.append("restartVersion", restartVersion)
214237
.toString();
215238
}
216239

@@ -226,6 +249,7 @@ public boolean equals(Object o) {
226249
.append(serverPod, that.serverPod)
227250
.append(serverStartState, that.serverStartState)
228251
.append(serverStartPolicy, that.serverStartPolicy)
252+
.append(restartVersion, that.restartVersion)
229253
.isEquals();
230254
}
231255

@@ -235,6 +259,7 @@ public int hashCode() {
235259
.append(serverPod)
236260
.append(serverStartState)
237261
.append(serverStartPolicy)
262+
.append(restartVersion)
238263
.toHashCode();
239264
}
240265
}

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/DomainSpec.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,8 @@ public ServerSpec getServerSpec(String serverName, String clusterName) {
706706
return new ManagedServerSpecV2Impl(
707707
DomainSpec.this,
708708
getServer(serverName),
709-
getClusterLimit(clusterName),
710709
getCluster(clusterName),
711-
DomainSpec.this);
710+
getClusterLimit(clusterName));
712711
}
713712

714713
private Integer getClusterLimit(String clusterName) {

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/DomainV2Configurator.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ public DomainConfigurator withPodSecurityContext(V1PodSecurityContext podSecurit
218218
return this;
219219
}
220220

221+
@Override
222+
public DomainConfigurator withRestartVersion(String restartVersion) {
223+
((BaseConfiguration) getDomainSpec()).setRestartVersion(restartVersion);
224+
return this;
225+
}
226+
221227
class ServerConfiguratorImpl implements ServerConfigurator {
222228
private Server server;
223229

@@ -328,6 +334,12 @@ public ServerConfigurator withServiceAnnotation(String name, String value) {
328334
server.addServiceAnnotations(name, value);
329335
return this;
330336
}
337+
338+
@Override
339+
public ServerConfigurator withRestartVersion(String restartVersion) {
340+
server.setRestartVersion(restartVersion);
341+
return this;
342+
}
331343
}
332344

333345
@Override
@@ -472,5 +484,11 @@ public ClusterConfigurator withServiceAnnotation(String name, String value) {
472484
cluster.addServiceAnnotations(name, value);
473485
return this;
474486
}
487+
488+
@Override
489+
public ClusterConfigurator withRestartVersion(String restartVersion) {
490+
cluster.setRestartVersion(restartVersion);
491+
return this;
492+
}
475493
}
476494
}

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/ManagedServerSpecV2Impl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public class ManagedServerSpecV2Impl extends ServerSpecV2Impl {
1515
* @param configurations the additional configurations to search for values if the server lacks
1616
*/
1717
public ManagedServerSpecV2Impl(
18-
DomainSpec spec, Server server, Integer clusterLimit, BaseConfiguration... configurations) {
19-
super(spec, server, clusterLimit, configurations);
18+
DomainSpec spec, Server server, Cluster cluster, Integer clusterLimit) {
19+
super(spec, server, cluster, clusterLimit);
2020
}
2121

2222
@Override

model/src/main/java/oracle/kubernetes/weblogic/domain/v2/Server.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ protected Server getConfiguration() {
2020
Server configuration = new Server();
2121
configuration.fillInFrom(this);
2222
configuration.setNodePort(nodePort);
23+
configuration.setRestartVersion(this.getRestartVersion());
2324
return configuration;
2425
}
2526

0 commit comments

Comments
 (0)