@@ -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
0 commit comments