Skip to content

Commit fcb0b7c

Browse files
committed
Merge branch 'feature/dynamic-cluster' of https://github.com/oracle/weblogic-kubernetes-operator into feature/dynamic-cluster
2 parents 757ed25 + 99ed2f5 commit fcb0b7c

File tree

10 files changed

+100
-168
lines changed

10 files changed

+100
-168
lines changed

kubernetes/internal/create-weblogic-domain-job-template.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,8 @@ data:
231231
set('ServerTemplate', st1)
232232
set('ServerNamePrefix', "%MANAGED_SERVER_NAME_BASE%")
233233
set('DynamicClusterSize', number_of_ms)
234-
set('MaxDynamicClusterSize', 800)
235-
#set('CalculatedMachineNames', true)
234+
set('MaxDynamicClusterSize', number_of_ms)
236235
set('CalculatedListenPorts', false)
237-
#machineNameExpression = '%DOMAIN_UID%-%s-machine*' % cluster_name
238-
#set('MachineNameMatchExpression', machineNameExpression)
239236
set('Id', 1)
240237
241238
print('Done setting attributes for Dynamic Cluster: %s' % cluster_name);

operator/src/main/java/oracle/kubernetes/operator/helpers/PodHelper.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -639,16 +639,8 @@ protected V1Pod computeManagedPodConfig(TuningParameters configMapHelper, Packet
639639
V1ContainerPort containerPort = new V1ContainerPort();
640640
containerPort.setContainerPort(scan.getListenPort());
641641
containerPort.setProtocol("TCP");
642-
// containerPort.setName("weblogic"); // commented out as we are not exposing node manager port
643642
container.addPortsItem(containerPort);
644643

645-
// Commented out as we are not exposing node manager port
646-
// V1ContainerPort nmPort = new V1ContainerPort();
647-
// nmPort.setContainerPort(5556);
648-
// nmPort.setProtocol("TCP");
649-
// nmPort.setName("node-manager");
650-
// container.addPortsItem(nmPort);
651-
652644
V1Lifecycle lifecycle = new V1Lifecycle();
653645
V1Handler preStop = new V1Handler();
654646
V1ExecAction exec = new V1ExecAction();

operator/src/main/java/oracle/kubernetes/operator/logging/MessageKeys.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,4 @@ private MessageKeys() {}
141141
public static final String WLS_UPDATE_CLUSTER_SIZE_INVALID_CLUSTER = "WLSKO-0131";
142142
public static final String WLS_CLUSTER_SIZE_UPDATED = "WLSKO-0132";
143143
public static final String WLS_SERVER_TEMPLATE_NOT_FOUND = "WLSKO-0133";
144-
public static final String WLS_CREATING_MACHINE = "WLSKO-0134";
145144
}

operator/src/main/java/oracle/kubernetes/operator/wlsconfig/Util.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

operator/src/main/java/oracle/kubernetes/operator/wlsconfig/WlsClusterConfig.java

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,11 @@ public int getMaxDynamicClusterSize() {
171171
* It is the responsibility of the caller to persist the changes to ClusterStartup to kubernetes.
172172
*
173173
* @param clusterStartup The ClusterStartup to be validated against the WLS configuration
174-
* @param machineNamePrefix Optional, if this is not null, also validate whether the WebLogic domain already contains
175-
* all the machines that will be used by the dynamic cluster
176174
* @param suggestedConfigUpdates A List containing suggested WebLogic configuration update to be filled in by this
177175
* method. Optional.
178176
* @return true if the DomainSpec has been updated, false otherwise
179177
*/
180178
public boolean validateClusterStartup(ClusterStartup clusterStartup,
181-
String machineNamePrefix,
182179
List<ConfigUpdate> suggestedConfigUpdates) {
183180
LOGGER.entering();
184181

@@ -190,7 +187,7 @@ public boolean validateClusterStartup(ClusterStartup clusterStartup,
190187
}
191188

192189
// Warns if replicas is larger than the number of servers configured in the cluster
193-
validateReplicas(clusterStartup.getReplicas(), machineNamePrefix,"clusterStartup", suggestedConfigUpdates);
190+
validateReplicas(clusterStartup.getReplicas(),"clusterStartup", suggestedConfigUpdates);
194191

195192
LOGGER.exiting(modified);
196193

@@ -204,34 +201,33 @@ public boolean validateClusterStartup(ClusterStartup clusterStartup,
204201
*
205202
* @param replicas The configured replicas value for this cluster in the kubernetes weblogic domain spec
206203
* for this cluster
207-
* @param machineNamePrefix Optional, if this is not null, also validate whether the WebLogic domain already contains
208-
* all the machines that will be used by the dynamic cluster
209204
* @param source The name of the section in the domain spec where the replicas is specified,
210205
* for logging purposes
211206
* @param suggestedConfigUpdates A List containing suggested WebLogic configuration update to be filled in by this
212207
* method. Optional.
213208
*/
214-
public void validateReplicas(Integer replicas, String machineNamePrefix,
209+
public void validateReplicas(Integer replicas,
215210
String source, List<ConfigUpdate> suggestedConfigUpdates) {
216211
if (replicas == null) {
217212
return;
218213
}
219-
// log warning if replicas is too large and cluster only contains statically configured servers
220-
if (!hasDynamicServers() && replicas > getClusterSize()) {
221-
LOGGER.warning(MessageKeys.REPLICA_MORE_THAN_WLS_SERVERS, source, clusterName, replicas, getClusterSize());
214+
// log warning if replicas is too large and cluster
215+
int maxClusterSize = getClusterSize();
216+
if (hasDynamicServers()) {
217+
maxClusterSize += getMaxDynamicClusterSize();
218+
}
219+
if (replicas > maxClusterSize) {
220+
LOGGER.warning(MessageKeys.REPLICA_MORE_THAN_WLS_SERVERS, source, clusterName, replicas, maxClusterSize);
222221
}
223222
// recommend updating WLS dynamic cluster size and machines if requested to recommend
224223
// updates, ie, suggestedConfigUpdates is not null, and if replicas value is larger than
225-
// the current dynamic cluster size, or if some of the machines to be used for the dynamic
226-
// servers are not yet configured.
224+
// the current dynamic cluster size.
227225
//
228226
// Note: Never reduce the value of dynamicClusterSize even during scale down
229-
if (suggestedConfigUpdates != null) {
230-
if (hasDynamicServers()) {
231-
// if (replicas > getDynamicClusterSize() || !verifyMachinesConfigured(machineNamePrefix, replicas)) {
232-
if (replicas > getDynamicClusterSize() ) {
233-
suggestedConfigUpdates.add(new DynamicClusterSizeConfigUpdate(this, Math.max(replicas, getDynamicClusterSize())));
234-
}
227+
if (suggestedConfigUpdates != null && hasDynamicServers()) {
228+
if (replicas > getDynamicClusterSize() && getDynamicClusterSize() < getMaxDynamicClusterSize()) {
229+
// increase dynamic cluster size to satisfy replicas, but only up to the configured max dynamic cluster size
230+
suggestedConfigUpdates.add(new DynamicClusterSizeConfigUpdate(this, Math.min(replicas, getMaxDynamicClusterSize())));
235231
}
236232
}
237233
}
@@ -329,17 +325,14 @@ public String getUpdateDynamicClusterSizeUrl() {
329325

330326
/**
331327
* Return the payload used in the REST request for updating the dynamic cluster size. It will
332-
* be used to update the cluster size and if necessary, the max cluster size of the dynamic servers
333-
* of this cluster.
328+
* be used to update the cluster size of the dynamic servers of this cluster.
334329
*
335330
* @param clusterSize Desired dynamic cluster size
336331
* @return A string containing the payload to be used in the REST request for updating the dynamic
337332
* cluster size to the specified value.
338333
*/
339334
public String getUpdateDynamicClusterSizePayload(final int clusterSize) {
340-
return "{ dynamicClusterSize: " + clusterSize + ", " +
341-
" maxDynamicClusterSize: " + (clusterSize > getMaxDynamicClusterSize()? clusterSize: getMaxDynamicClusterSize()) +
342-
" }";
335+
return "{ dynamicClusterSize: " + clusterSize + " }";
343336
}
344337

345338
@Override

operator/src/main/java/oracle/kubernetes/operator/wlsconfig/WlsDomainConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public boolean validate(DomainSpec domainSpec, List<ConfigUpdate> suggestedConfi
306306
if (clusterName != null) {
307307
WlsClusterConfig wlsClusterConfig = getClusterConfig(clusterName);
308308
updated |= wlsClusterConfig.validateClusterStartup(clusterStartup,
309-
Util.getMachineNamePrefix(domainSpec, wlsClusterConfig), suggestedConfigUpdates);
309+
suggestedConfigUpdates);
310310
}
311311
}
312312
}
@@ -318,7 +318,6 @@ public boolean validate(DomainSpec domainSpec, List<ConfigUpdate> suggestedConfi
318318
if (clusterConfigs != null && clusterConfigs.size() == 1) {
319319
for (WlsClusterConfig wlsClusterConfig : clusterConfigs) {
320320
wlsClusterConfig.validateReplicas(domainSpec.getReplicas(),
321-
Util.getMachineNamePrefix(domainSpec, wlsClusterConfig),
322321
"domainSpec",
323322
suggestedConfigUpdates);
324323
}

operator/src/main/java/oracle/kubernetes/operator/wlsconfig/WlsRetriever.java

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,8 @@ public NextAction apply(Packet packet) {
210210

211211
String serviceURL = HttpClient.getServiceURL(info.getAdmin().getService().get());
212212

213-
Domain dom = info.getDomain();
214-
DomainSpec domainSpec = dom.getSpec();
215-
String machineNamePrefix = Util.getMachineNamePrefix(domainSpec, wlsClusterConfig);
216-
217213
boolean successful = updateDynamicClusterSizeWithServiceURL(wlsClusterConfig,
218-
machineNamePrefix, targetClusterSize, httpClient, serviceURL);
214+
targetClusterSize, httpClient, serviceURL);
219215

220216
if (successful) {
221217
LOGGER.info(MessageKeys.WLS_CLUSTER_SIZE_UPDATED, clusterName, targetClusterSize, (System.currentTimeMillis() - startTime));
@@ -471,37 +467,11 @@ private String executePostUrlWithRetry(final String url, final String payload, f
471467
return jsonResult;
472468
}
473469

474-
/**
475-
* Method called by the Callable that is submitted from the updateDynamicClusterSize method for updating the
476-
* WLS dynamic cluster size configuration.
477-
*
478-
* @param wlsClusterConfig The WlsClusterConfig object of the WLS cluster whose cluster size needs to be updated. The
479-
* caller should make sure that the cluster is a dynamic cluster.
480-
* @param machineNamePrefix Prefix of names of new machines to be created
481-
* @param targetClusterSize The target dynamic cluster size
482-
* @return true if the request to update the cluster size is successful, false if it was not successful
483-
*/
484-
485-
private boolean doUpdateDynamicClusterSize(final WlsClusterConfig wlsClusterConfig,
486-
final String machineNamePrefix,
487-
final int targetClusterSize) throws Exception {
488-
LOGGER.entering();
489-
490-
String serviceURL = connectAndGetServiceURL();
491-
492-
boolean result = updateDynamicClusterSizeWithServiceURL(wlsClusterConfig, machineNamePrefix,
493-
targetClusterSize, httpClient, serviceURL);
494-
495-
LOGGER.exiting(result);
496-
return result;
497-
}
498-
499470
/**
500471
* Static method to update the WebLogic dynamic cluster size configuration.
501472
*
502473
* @param wlsClusterConfig The WlsClusterConfig object of the WLS cluster whose cluster size needs to be updated. The
503474
* caller should make sure that the cluster is a dynamic cluster.
504-
* @param machineNamePrefix Prefix of names of new machines to be created
505475
* @param targetClusterSize The target dynamic cluster size
506476
* @param httpClient HttpClient object for issuing the REST request
507477
* @param serviceURL service URL of the WebLogic admin server
@@ -510,22 +480,12 @@ private boolean doUpdateDynamicClusterSize(final WlsClusterConfig wlsClusterConf
510480
*/
511481

512482
private static boolean updateDynamicClusterSizeWithServiceURL(final WlsClusterConfig wlsClusterConfig,
513-
final String machineNamePrefix,
514483
final int targetClusterSize,
515484
final HttpClient httpClient,
516485
final String serviceURL) {
517486
LOGGER.entering();
518487

519488
boolean result = false;
520-
// Create machine(s)
521-
// Commented out as we are not configuring machines for servers
522-
// String newMachineNames[] = wlsClusterConfig.getMachineNamesForDynamicServers(machineNamePrefix, targetClusterSize);
523-
// for (String machineName: newMachineNames) {
524-
// LOGGER.info(MessageKeys.WLS_CREATING_MACHINE, machineName);
525-
// httpClient.executePostUrlOnServiceClusterIP(WlsMachineConfig.getCreateUrl(),
526-
// serviceURL, WlsMachineConfig.getCreatePayload(machineName));
527-
// }
528-
529489
// Update the dynamic cluster size of the WebLogic cluster
530490
String jsonResult = httpClient.executePostUrlOnServiceClusterIP(
531491
wlsClusterConfig.getUpdateDynamicClusterSizeUrl(),

operator/src/main/resources/Operator.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,3 @@ WLSKO-0130=Failed to update WebLogic dynamic cluster size for cluster {0} within
132132
WLSKO-0131=Failed to update WebLogic dynamic cluster size for cluster {0}. Cluster is not a dynamic cluster
133133
WLSKO-0132=Updated cluster size for WebLogic dynamic cluster {0} to {1}. Time taken {2} ms
134134
WLSKO-0133=Cannot find WebLogic server template with name {0} which is referenced by WebLogic cluster {1}
135-
WLSKO-0134=Creating WebLogic machine named {0}

operator/src/test/java/oracle/kubernetes/operator/wlsconfig/UtilTest.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)