Skip to content

Commit faa47c1

Browse files
authored
Merge pull request #1061 from oracle/admin-running
Correct and clarify use of serverStartState
2 parents 6dcf591 + 41105c1 commit faa47c1

File tree

26 files changed

+325
-267
lines changed

26 files changed

+325
-267
lines changed

docs-source/content/recent-changes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This document tracks recent changes to the operator, especially ones that introd
1010

1111
| Date | Version | Introduces backward incompatibilities | Change |
1212
| --- | --- | --- | --- |
13-
| April 30, 2019 | v2.2 | no | Added support for FMW Infrastructure domains. WebLogic server instances are now gracefully shutdown by default and shutdown options are configurable. Operator is now built and runs on JDK 11.
13+
| May 6, 2019 | v2.2 | no | Added support for FMW Infrastructure domains. WebLogic Server instances are now gracefully shut down by default and shutdown options are configurable. Operator is now built and runs on JDK 11.
1414
| April 4, 2019 | v2.1 | no | Customers can add init and sidecar containers to generated pods.
1515
| March 4, 2019 | v2.0.1 | no | OpenShift support is now certified. Many bug fixes, including fixes for configuration overrides, cluster services, and domain status processing.
1616
| January 24, 2019 | v2.0 | yes; not compatible with 1.x releases, but is compatible with 2.0-rc2. | Final version numbers and documentation updates.

docs-source/content/release-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ draft: false
88

99
| Date | Version | Introduces backward incompatibilities | Change |
1010
| --- | --- | --- | --- |
11-
| April 30, 2019 | v2.2 | no | Added support for FMW Infrastructure domains. WebLogic Server instances are now gracefully shutdown by default and shutdown options are configurable. Operator is now built and runs on JDK 11.
11+
| May 6, 2019 | v2.2 | no | Added support for FMW Infrastructure domains. WebLogic Server instances are now gracefully shut down by default and shutdown options are configurable. Operator is now built and runs on JDK 11.
1212
| April 4, 2019 | v2.1 | no | Customers can add init and sidecar containers to generated pods.
1313
| March 4, 2019 | v2.0.1 | no | OpenShift support is now certified. Many bug fixes, including fixes for configuration overrides, cluster services, and domain status processing.
1414
| January 24, 2019 | v2.0 | yes; not compatible with 1.x releases, but is compatible with 2.0-rc2. | Final version numbers and documentation updates.

docs-source/content/userguide/managing-domains/domain-lifecycle/startup.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ and which servers should be restarted. To start, stop, or restart servers, modif
1616
* [Rolling restarts](#rolling-restarts)
1717
* [Common restarting scenarios](#common-restarting-scenarios)
1818

19-
There are properties on the domain resource that specify which servers should be running
20-
and which servers should be restarted. To start, stop, or restart servers, modify these properties on the domain resource
19+
There are properties on the domain resource that specify which servers should be running,
20+
which servers should be restarted and the desired initial state. To start, stop, or restart servers, modify these properties on the domain resource
2121
(for example, by using `kubectl` or the Kubernetes REST API). The operator will notice the changes and apply them. Beginning,
2222
with operator version 2.2, there are now properties to control server shutdown handling, such as whether the shutdown
2323
will be graceful, the timeout, and if in-flight sessions are given the opportunity to complete.
@@ -69,6 +69,16 @@ Servers configured as `ALWAYS` count toward the cluster's `replicas` count.
6969
If more servers are configured as `ALWAYS` than the cluster's `replicas` count, they will all be started and the `replicas` count will be ignored.
7070
{{% /notice %}}
7171

72+
### Server start state
73+
74+
For some use cases, such as an externally managed zero downtime patching (ZDP), it may be necessary to start WebLogic Server
75+
so that at the end of its startup process, the server is in an administrative state. This can be achieved using the `serverStartState`
76+
property, which is available at domain, cluster, and server levels. When `serverStartState` is set to `ADMIN`, then servers will
77+
progress only to the administrative state. You could then use the WebLogic console, REST API, or a WLST script to make any necessary
78+
updates before advancing the server to the running state.
79+
80+
Changes to the `serverStartState` property do not affect already started servers.
81+
7282
### Common starting and stopping scenarios
7383

7484
#### Normal running state
@@ -240,7 +250,6 @@ The operator will restart servers when any of the follow properties on the domai
240250
* `readinessProbe`
241251
* `resources`
242252
* `restartVersion`
243-
* `serverStartState`
244253
* `volumes`
245254
* `volumeMounts`
246255

@@ -251,6 +260,11 @@ the domain resource will cause neither a restart nor a patch. It is possible to
251260
such a label or annotation by modifying the `restartVersion`.
252261
{{% /notice %}}
253262

263+
{{% notice note %}}
264+
Prior to version 2.2, the operator incorrectly restarted servers when the `serverStartState` property was changed. Now,
265+
this property has no affect on already running servers.
266+
{{% /notice %}}
267+
254268
### Rolling restarts
255269

256270
Clustered servers that need to be restarted are gradually restarted (for example, `rolling restarted`) so that the cluster is not taken out of service and in-flight work can be migrated to other servers in the cluster.

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,14 @@ public abstract void withDefaultLivenessProbeSettings(
184184
*/
185185
public abstract DomainConfigurator withDefaultServerStartPolicy(String startPolicy);
186186

187+
/**
188+
* Sets the server start state ("RUNNING" or "ADMIN") for the domain.
189+
*
190+
* @param startState the server start state
191+
* @return this object
192+
*/
193+
public abstract DomainConfigurator withServerStartState(String startState);
194+
187195
/**
188196
* Add an environment variable to the domain.
189197
*

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ public DomainConfigurator withDefaultServerStartPolicy(String startPolicy) {
6363
return this;
6464
}
6565

66+
@Override
67+
public DomainConfigurator withServerStartState(String startState) {
68+
((BaseConfiguration) getDomainSpec()).setServerStartState(startState);
69+
return this;
70+
}
71+
6672
@Override
6773
public DomainConfigurator withEnvironmentVariable(String name, String value) {
6874
((BaseConfiguration) getDomainSpec()).addEnvironmentVariable(name, value);

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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
import static oracle.kubernetes.operator.KubernetesConstants.DEFAULT_IMAGE;
99
import static oracle.kubernetes.operator.KubernetesConstants.IFNOTPRESENT_IMAGEPULLPOLICY;
1010

11-
import io.kubernetes.client.models.V1EnvVar;
1211
import io.kubernetes.client.models.V1LocalObjectReference;
1312
import io.kubernetes.client.models.V1PodSecurityContext;
1413
import io.kubernetes.client.models.V1ResourceRequirements;
1514
import io.kubernetes.client.models.V1SecurityContext;
16-
import java.util.ArrayList;
1715
import java.util.Collections;
1816
import java.util.List;
1917
import java.util.Map;
@@ -28,7 +26,6 @@
2826
@SuppressWarnings("WeakerAccess")
2927
public abstract class ServerSpecBase implements ServerSpec {
3028

31-
private static final String ADMIN_MODE_FLAG = "-Dweblogic.management.startupMode=ADMIN";
3229
protected DomainSpec domainSpec;
3330

3431
public ServerSpecBase(DomainSpec domainSpec) {
@@ -62,17 +59,6 @@ public List<V1LocalObjectReference> getImagePullSecrets() {
6259
return domainSpec.getImagePullSecrets();
6360
}
6461

65-
protected List<V1EnvVar> withStateAdjustments(List<V1EnvVar> env) {
66-
if (!getDesiredState().equals("ADMIN")) {
67-
return env;
68-
} else {
69-
List<V1EnvVar> adjustedEnv = new ArrayList<>(env);
70-
V1EnvVar var = getOrCreateVar(adjustedEnv, "JAVA_OPTIONS");
71-
var.setValue(prepend(var.getValue(), ADMIN_MODE_FLAG));
72-
return adjustedEnv;
73-
}
74-
}
75-
7662
@Override
7763
public String getConfigOverrides() {
7864
return domainSpec.getConfigOverrides();
@@ -83,23 +69,6 @@ public List<String> getConfigOverrideSecrets() {
8369
return domainSpec.getConfigOverrideSecrets();
8470
}
8571

86-
@SuppressWarnings("SameParameterValue")
87-
private V1EnvVar getOrCreateVar(List<V1EnvVar> env, String name) {
88-
for (V1EnvVar var : env) {
89-
if (var.getName().equals(name)) {
90-
return var;
91-
}
92-
}
93-
V1EnvVar var = new V1EnvVar().name(name);
94-
env.add(var);
95-
return var;
96-
}
97-
98-
@SuppressWarnings("SameParameterValue")
99-
private String prepend(String value, String prefix) {
100-
return value == null ? prefix : value.contains(prefix) ? value : prefix + ' ' + value;
101-
}
102-
10372
@Override
10473
@Nonnull
10574
public ProbeTuning getLivenessProbe() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private Server getBaseConfiguration(Server server) {
5050

5151
@Override
5252
public List<V1EnvVar> getEnvironmentVariables() {
53-
return withStateAdjustments(server.getEnv());
53+
return server.getEnv();
5454
}
5555

5656
@Override

model/src/test/java/oracle/kubernetes/weblogic/domain/DomainTestBase.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -337,20 +337,6 @@ public void whenSpecifiedOnServer_managedServerHasEnvironmentVariables() {
337337
assertThat(spec.getEnvironmentVariables(), containsInAnyOrder(createEnvironment()));
338338
}
339339

340-
@Test
341-
public void whenDesiredStateAdminAndSpecifiedOnServer_managedServerHasJavaOption() {
342-
configureServer(SERVER1)
343-
.withDesiredState("ADMIN")
344-
.withEnvironmentVariable(NAME1, VALUE1)
345-
.withEnvironmentVariable(NAME2, VALUE2);
346-
347-
ServerSpec spec = domain.getServer(SERVER1, CLUSTER_NAME);
348-
349-
assertThat(
350-
spec.getEnvironmentVariables(),
351-
hasItem(envVar("JAVA_OPTIONS", "-Dweblogic.management.startupMode=ADMIN")));
352-
}
353-
354340
@Test
355341
public void whenSpecifiedOnCluster_managedServerHasEnvironmentVariables() {
356342
configureCluster(CLUSTER_NAME)
@@ -370,9 +356,7 @@ public void whenDesiredStateAdminAndSpecifiedOnCluster_managedServerHasEnvironme
370356

371357
ServerSpec spec = domain.getServer(SERVER1, CLUSTER_NAME);
372358

373-
assertThat(
374-
spec.getEnvironmentVariables(),
375-
hasItem(envVar("JAVA_OPTIONS", "-Dweblogic.management.startupMode=ADMIN value")));
359+
assertThat(spec.getEnvironmentVariables(), hasItem(envVar("JAVA_OPTIONS", "value")));
376360
}
377361

378362
@Test
@@ -408,9 +392,6 @@ public void whenDomainReadFromYaml_Server2OverridesDefaults() throws IOException
408392
Domain domain = readDomain(DOMAIN_V2_SAMPLE_YAML);
409393
ServerSpec serverSpec = domain.getServer("server2", null);
410394

411-
assertThat(
412-
serverSpec.getEnvironmentVariables(),
413-
hasItem(envVar("JAVA_OPTIONS", "-Dweblogic.management.startupMode=ADMIN")));
414395
assertThat(serverSpec.getDesiredState(), equalTo("ADMIN"));
415396
}
416397

model/src/test/java/oracle/kubernetes/weblogic/domain/model/DomainV2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ public void whenDomainReadFromYaml_cluster2OverridesDefaults() throws IOExceptio
726726
assertThat(
727727
serverSpec.getEnvironmentVariables(),
728728
containsInAnyOrder(
729-
envVar("JAVA_OPTIONS", "-Dweblogic.management.startupMode=ADMIN -verbose"),
729+
envVar("JAVA_OPTIONS", "-verbose"),
730730
envVar("USER_MEM_ARGS", "-Xms64m -Xmx256m "),
731731
envVar("var1", "value0")));
732732
assertThat(serverSpec.getConfigOverrides(), equalTo("overrides-config-map"));

operator/src/main/java/oracle/kubernetes/operator/DomainStatusUpdater.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private Stream<ServerStartupInfo> getServerStartupInfos() {
183183
}
184184

185185
private boolean shouldBeRunning(ServerStartupInfo startupInfo) {
186-
return "RUNNING".equals(startupInfo.getDesiredState());
186+
return RUNNING_STATE.equals(startupInfo.getDesiredState());
187187
}
188188

189189
private boolean isNotRunning(@Nonnull String serverName) {

0 commit comments

Comments
 (0)