Skip to content

Commit 5318b3a

Browse files
authored
OWLS-80960 - Allow replicas count to drop below min dynamic cluster size (#1627)
* introduce new Cluster element allowReplicasBelowMinDynClusterSize * description fix * unit test * update description for allowReplicasBelowMinDynClusterSize * minor edits to description
1 parent 11e8abd commit 5318b3a

File tree

15 files changed

+162
-6
lines changed

15 files changed

+162
-6
lines changed

docs/domains/Domain.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@
109109
"description": "The name of this cluster. Required",
110110
"type": "string"
111111
},
112+
"allowReplicasBelowMinDynClusterSize": {
113+
"description": "If true (the default), then the number of replicas is allowed to drop below the minimum dynamic cluster size configured in the WebLogic domain home configuration. Otherwise, the operator will ensure that the number of replicas is not less than the minimum dynamic cluster setting. This setting applies to dynamic clusters only.",
114+
"type": "boolean"
115+
},
112116
"serverPod": {
113117
"description": "Configuration affecting server pods.",
114118
"$ref": "#/definitions/ServerPod"

docs/domains/Domain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ An element representing a cluster in the domain configuration.
7777

7878
| Name | Type | Description |
7979
| --- | --- | --- |
80+
| `allowReplicasBelowMinDynClusterSize` | Boolean | If true (the default), then the number of replicas is allowed to drop below the minimum dynamic cluster size configured in the WebLogic domain home configuration. Otherwise, the operator will ensure that the number of replicas is not less than the minimum dynamic cluster setting. This setting applies to dynamic clusters only. |
8081
| `clusterName` | string | The name of this cluster. Required |
8182
| `clusterService` | [Kubernetes Resource](#kubernetes-resource) | Customization affecting ClusterIP Kubernetes services for the WebLogic cluster. |
8283
| `maxUnavailable` | number | The maximum number of cluster members that can be temporarily unavailable. Defaults to 1. |

docs/domains/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,10 @@
10291029
"description": "The name of this cluster. Required",
10301030
"type": "string"
10311031
},
1032+
"allowReplicasBelowMinDynClusterSize": {
1033+
"description": "If true (the default), then the number of replicas is allowed to drop below the minimum dynamic cluster size configured in the WebLogic domain home configuration. Otherwise, the operator will ensure that the number of replicas is not less than the minimum dynamic cluster setting. This setting applies to dynamic clusters only.",
1034+
"type": "boolean"
1035+
},
10321036
"serverPod": {
10331037
"description": "Configuration affecting server pods.",
10341038
"$ref": "#/definitions/ServerPod"

kubernetes/crd/domain-crd.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5478,6 +5478,14 @@ spec:
54785478
clusterName:
54795479
description: The name of this cluster. Required
54805480
type: string
5481+
allowReplicasBelowMinDynClusterSize:
5482+
description: If true (the default), then the number of replicas
5483+
is allowed to drop below the minimum dynamic cluster size
5484+
configured in the WebLogic domain home configuration. Otherwise,
5485+
the operator will ensure that the number of replicas is not
5486+
less than the minimum dynamic cluster setting. This setting
5487+
applies to dynamic clusters only.
5488+
type: boolean
54815489
serverPod:
54825490
description: Configuration affecting server pods.
54835491
type: object

kubernetes/crd/domain-v1beta1-crd.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5367,6 +5367,14 @@ spec:
53675367
clusterName:
53685368
description: The name of this cluster. Required
53695369
type: string
5370+
allowReplicasBelowMinDynClusterSize:
5371+
description: If true (the default), then the number of replicas
5372+
is allowed to drop below the minimum dynamic cluster size configured
5373+
in the WebLogic domain home configuration. Otherwise, the operator
5374+
will ensure that the number of replicas is not less than the
5375+
minimum dynamic cluster setting. This setting applies to dynamic
5376+
clusters only.
5377+
type: boolean
53705378
serverPod:
53715379
description: Configuration affecting server pods.
53725380
type: object

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public interface KubernetesConstants {
2525

2626
boolean DEFAULT_HTTP_ACCESS_LOG_IN_LOG_HOME = true;
2727
boolean DEFAULT_INCLUDE_SERVER_OUT_IN_POD_LOG = true;
28+
boolean DEFAULT_ALLOW_REPLICAS_BELOW_MIN_DYN_CLUSTER_SIZE = true;
2829

2930
String CONTAINER_NAME = "weblogic-server";
3031

operator/src/main/java/oracle/kubernetes/operator/steps/ManagedServersUpStep.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,11 @@ private void logIfReplicasLessThanClusterServersMin(WlsClusterConfig clusterConf
246246
private boolean lessThanMinConfiguredClusterSize(WlsClusterConfig clusterConfig) {
247247
if (clusterConfig != null) {
248248
String clusterName = clusterConfig.getClusterName();
249-
int configMinClusterSize
250-
= clusterConfig.getMinDynamicClusterSize();
251-
return clusterConfig.hasDynamicServers()
252-
&& domain.getReplicaCount(clusterName) < configMinClusterSize;
249+
if (clusterConfig.hasDynamicServers()
250+
&& !domain.isAllowReplicasBelowMinDynClusterSize(clusterName)) {
251+
int configMinClusterSize = clusterConfig.getMinDynamicClusterSize();
252+
return domain.getReplicaCount(clusterName) < configMinClusterSize;
253+
}
253254
}
254255
return false;
255256
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,6 @@ ClusterConfigurator withLivenessProbeSettings(
128128
ClusterConfigurator withToleration(V1Toleration toleration);
129129

130130
ClusterConfigurator withPrecreateServerService(boolean precreateServerService);
131+
132+
ClusterConfigurator withAllowReplicasBelowDynClusterSize(boolean allowReplicasBelowDynClusterSize);
131133
}

operator/src/main/java/oracle/kubernetes/weblogic/domain/EffectiveConfigurationFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ public interface EffectiveConfigurationFactory {
3030
boolean isShuttingDown();
3131

3232
List<String> getAdminServerChannelNames();
33+
34+
boolean isAllowReplicasBelowMinDynClusterSize(String clusterName);
3335
}

operator/src/main/java/oracle/kubernetes/weblogic/domain/model/Cluster.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package oracle.kubernetes.weblogic.domain.model;
55

66
import java.util.Map;
7+
import java.util.Optional;
78
import javax.annotation.Nonnull;
89
import javax.annotation.Nullable;
910

@@ -12,6 +13,7 @@
1213
import oracle.kubernetes.json.Description;
1314
import oracle.kubernetes.json.EnumClass;
1415
import oracle.kubernetes.json.Range;
16+
import oracle.kubernetes.operator.KubernetesConstants;
1517
import oracle.kubernetes.operator.ServerStartPolicy;
1618
import org.apache.commons.lang3.builder.EqualsBuilder;
1719
import org.apache.commons.lang3.builder.HashCodeBuilder;
@@ -57,6 +59,15 @@ public class Cluster extends BaseConfiguration implements Comparable<Cluster> {
5759
@Expose
5860
private KubernetesResource clusterService = new KubernetesResource();
5961

62+
/** Whether to allow the number of replicas to drop below the minimum dynamic cluster
63+
* size configured in the WebLogic domain home configuration. Default is true. */
64+
@Description("If true (the default), then the number of replicas is allowed to drop below the "
65+
+ "minimum dynamic cluster size configured in the WebLogic domain home configuration. "
66+
+ "Otherwise, the operator will ensure that the number of replicas is not less than "
67+
+ "the minimum dynamic cluster setting. This setting applies to dynamic clusters only."
68+
)
69+
private Boolean allowReplicasBelowMinDynClusterSize;
70+
6071
protected Cluster getConfiguration() {
6172
Cluster configuration = new Cluster();
6273
configuration.fillInFrom(this);
@@ -85,6 +96,22 @@ public void setReplicas(Integer replicas) {
8596
this.replicas = replicas;
8697
}
8798

99+
/**
100+
* Whether to allow number of replicas to drop below the minimum dynamic cluster size configured
101+
* in the WebLogic domain home configuration.
102+
*
103+
* @return whether to allow number of replicas to drop below the minimum dynamic cluster size
104+
* configured in the WebLogic domain home configuration.
105+
*/
106+
public boolean isAllowReplicasBelowMinDynClusterSize() {
107+
return Optional.ofNullable(allowReplicasBelowMinDynClusterSize)
108+
.orElse(KubernetesConstants.DEFAULT_ALLOW_REPLICAS_BELOW_MIN_DYN_CLUSTER_SIZE);
109+
}
110+
111+
public void setAllowReplicasBelowMinDynClusterSize(boolean value) {
112+
allowReplicasBelowMinDynClusterSize = value;
113+
}
114+
88115
@Nullable
89116
@Override
90117
public String getServerStartPolicy() {
@@ -145,6 +172,7 @@ public String toString() {
145172
.append("serverStartPolicy", serverStartPolicy)
146173
.append("clusterService", clusterService)
147174
.append("maxUnavailable", maxUnavailable)
175+
.append("allowReplicasBelowMinDynClusterSize", allowReplicasBelowMinDynClusterSize)
148176
.toString();
149177
}
150178

@@ -167,6 +195,7 @@ public boolean equals(Object o) {
167195
.append(serverStartPolicy, cluster.serverStartPolicy)
168196
.append(clusterService, cluster.clusterService)
169197
.append(maxUnavailable, cluster.maxUnavailable)
198+
.append(allowReplicasBelowMinDynClusterSize, cluster.allowReplicasBelowMinDynClusterSize)
170199
.isEquals();
171200
}
172201

@@ -179,6 +208,7 @@ public int hashCode() {
179208
.append(serverStartPolicy)
180209
.append(clusterService)
181210
.append(maxUnavailable)
211+
.append(allowReplicasBelowMinDynClusterSize)
182212
.toHashCode();
183213
}
184214

0 commit comments

Comments
 (0)