Skip to content

Commit 6674f21

Browse files
committed
Merge branch 'lbshape' into 'release/4.2'
Added OCI load balancer options to use flexible shape, updated k8s OKE to 1.30.1 See merge request weblogic-cloud/weblogic-kubernetes-operator!4829
2 parents 7230727 + b94d841 commit 6674f21

File tree

6 files changed

+192
-72
lines changed

6 files changed

+192
-72
lines changed

Jenkinsfile.oke

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,19 @@ pipeline {
8383

8484
string(name: 'OKE_KUBE_VERSION',
8585
description: 'kube version for oke cluster',
86-
defaultValue: '1.29.1'
86+
defaultValue: '1.30.0'
8787
)
8888
string(name: 'IMAGE_ID',
8989
description: 'oci image id for node pool, find image OCID for your region from https://docs.oracle.com/iaas/images/',
9090
//defaultValue OKE1.26.2: 'ocid1.image.oc1.phx.aaaaaaaaaizmtmozeudeeuq7o5ir7dkl2bkxbbb3tgomshqbqn6jpomrsjza'
9191
//1.27.2 oke defaultValue: 'ocid1.image.oc1.phx.aaaaaaaaypr5r5drojwytghw6e6mvpjsscrnkuwtmqlmvmix7kjb2zcnc7wa'
92-
defaultValue: 'ocid1.image.oc1.phx.aaaaaaaa22u45gr3ikxnc6rius2qil2kz5k3e7p476c4usr6qnvql4l5dxea'
92+
//1.29.1 'ocid1.image.oc1.phx.aaaaaaaa22u45gr3ikxnc6rius2qil2kz5k3e7p476c4usr6qnvql4l5dxea'
93+
defaultValue: 'ocid1.image.oc1.phx.aaaaaaaahgrs3zcwrvutjtni557ttrt62uggseijsmqxacr7dym423uaokcq'
9394

9495
)
9596
string(name: 'KUBECTL_VERSION',
9697
description: 'kubectl version',
97-
defaultValue: '1.26.2'
98+
defaultValue: '1.30.0'
9899
)
99100
string(name: 'HELM_VERSION',
100101
description: 'Helm version',
@@ -144,7 +145,7 @@ pipeline {
144145
)
145146
string(name: 'NODE_SHAPE',
146147
description: '',
147-
defaultValue: "VM.Standard.E4.Flex"
148+
defaultValue: "VM.Standard.E5.Flex"
148149
)
149150
string(name: 'MOUNT_TARGET_OCID',
150151
description: 'only for debug runs on wko-oke-dev',
@@ -273,6 +274,7 @@ pipeline {
273274
--auth=instance_principal
274275
chmod +x ${WORKSPACE}/bin/kubectl
275276
kubectl version --client=true
277+
276278
'''
277279
}
278280
}
@@ -321,6 +323,7 @@ pipeline {
321323
chmod 600 ${wkotest_ssh_pk}
322324

323325
COMPARTMENT_OCID=${compartment_id}
326+
324327
export OCI_CLI_SUPPRESS_FILE_PERMISSIONS_WARNING=True
325328

326329
echo 'Set env vars needed for integration tests...'

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/NginxParams.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public class NginxParams {
3535
private static final String IP_FAMILY_POLICY = "controller.service.ipFamilyPolicy";
3636
private static final String IP_FAMILIES = "controller.service.ipFamilies";
3737
private static final String TYPE = "controller.service.type";
38-
3938

4039
// Adding some of the most commonly used params for now
4140
private int nodePortsHttp;

integration-tests/src/test/java/oracle/weblogic/kubernetes/actions/impl/TraefikParams.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class TraefikParams {
3333
private static final String TRAEFIK_IMAGE_TAG = "image.tag";
3434
private static final String INGRESS_CLASS_NAME = "ingressClass.name";
3535
private static final String TYPE = "service.type";
36-
3736

3837
public TraefikParams() {
3938
ingressClassName = UniqueName.uniqueName("traefik-");
@@ -72,7 +71,7 @@ public TraefikParams traefikImageTag(String traefikImageTag) {
7271
this.traefikImageTag = traefikImageTag;
7372
return this;
7473
}
75-
74+
7675
public String getIngressClassName() {
7776
return ingressClassName;
7877
}
@@ -106,7 +105,6 @@ public Map<String, Object> getValues() {
106105
values.put(TRAEFIK_IMAGE_TAG, traefikImageTag);
107106
values.put(INGRESS_CLASS_NAME, ingressClassName);
108107
values.put(TYPE, type);
109-
110108
values.values().removeIf(Objects::isNull);
111109
return values;
112110
}

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/LoadBalancerUtils.java

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import oracle.weblogic.kubernetes.actions.impl.primitive.HelmParams;
3636
import oracle.weblogic.kubernetes.extensions.InitializationTasks;
3737
import oracle.weblogic.kubernetes.logging.LoggingFacade;
38+
import org.jetbrains.annotations.Nullable;
3839

3940
import static oracle.weblogic.kubernetes.TestConstants.ADMIN_SERVER_NAME_BASE;
4041
import static oracle.weblogic.kubernetes.TestConstants.COMPARTMENT_OCID;
@@ -385,13 +386,15 @@ public static String getLoadBalancerIP(String namespace, String lbName, boolean
385386
return null;
386387
}
387388

388-
private static boolean checkLoadBalancerHealthy(String namespace, String lbServiceName) {
389+
private static boolean checkLoadBalancerHealthy(String namespace, String lbServiceName) {
390+
389391
String lbPublicIP = assertDoesNotThrow(() -> getLoadBalancerIP(namespace, lbServiceName));
390392
InitializationTasks.registerLoadBalancerExternalIP(lbPublicIP);
391393
LoggingFacade logger = getLogger();
392394
String testcompartmentid = System.getProperty("wko.it.oci.compartment.ocid");
393395
logger.info("wko.it.oci.compartment.ocid property " + testcompartmentid);
394396

397+
395398
final String command = "oci lb load-balancer list --compartment-id "
396399
+ testcompartmentid + " --query \"data[?contains(\\\"ip-addresses\\\"[0].\\\"ip-address\\\", '"
397400
+ lbPublicIP + "')].id | [0]\" --raw-output --all";
@@ -409,13 +412,44 @@ private static boolean checkLoadBalancerHealthy(String namespace, String lbServi
409412
// Clean up the string to extract the Load Balancer ID
410413
String lbOCID = result.stdout().trim();
411414

415+
boolean isFlexible = isLoadBalancerShapeFlexible(lbOCID);
416+
417+
if (!isFlexible) {
418+
logger.info("Updating load balancer shape to flexible");
419+
420+
final String command2 = "oci lb load-balancer update-load-balancer-shape --load-balancer-id "
421+
+ lbOCID + " --shape-name flexible --shape-details"
422+
+ " '{\"minimumBandwidthInMbps\": 10, \"maximumBandwidthInMbps\": 400}' --force";
423+
424+
result = assertDoesNotThrow(() -> exec(command2, true));
425+
logger.info("Command: {}, Exit value: {}, Stdout: {}, Stderr: {}",
426+
command2, result.exitValue(), result.stdout(), result.stderr());
427+
428+
if (result == null || result.stdout() == null) {
429+
return false;
430+
} else if (result.exitValue() != 0 && !result.stdout().contains("is currently being modified")) {
431+
return false;
432+
}
433+
434+
testUntil(
435+
assertDoesNotThrow(() -> checkWorkRequestUpdateShapeSucceeded(
436+
lbOCID), "isOCILoadBalancer work request to update shape is not ready"),
437+
logger,
438+
"load balancer shape is updating ");
439+
testUntil(
440+
assertDoesNotThrow(() -> checkLoadBalancerShapeFlexible(
441+
lbOCID), "checkLoadBalancerShape is not flexible "),
442+
logger,
443+
"load balancer shape can't be checked, retrying ");
444+
}
445+
412446
//check health status
413447
final String command1 = "oci lb load-balancer-health get --load-balancer-id " + lbOCID;
414448
logger.info("Command to retrieve Load Balancer health status is: {0} ", command1);
415449
result = assertDoesNotThrow(() -> exec(command1, true));
416450
logger.info("The command returned exit value: " + result.exitValue()
417451
+ " command output: " + result.stderr() + "\n" + result.stdout());
418-
452+
logger.info("result.stderr: \n{0}", result.stderr());
419453
if (result == null || result.exitValue() != 0 || result.stdout() == null) {
420454
return false;
421455
}
@@ -424,6 +458,58 @@ private static boolean checkLoadBalancerHealthy(String namespace, String lbServi
424458

425459
}
426460

461+
@Nullable
462+
private static boolean isLoadBalancerShapeFlexible(String lbOCID) {
463+
LoggingFacade logger = getLogger();
464+
465+
final String checkShapeCommand = "oci lb load-balancer get --load-balancer-id "
466+
+ lbOCID + " | jq '.data[\"shape-name\"], .data[\"shape-details\"]'";
467+
ExecResult result = assertDoesNotThrow(() -> exec(checkShapeCommand, true));
468+
logger.info("The command " + checkShapeCommand + " returned exit value: " + result.exitValue()
469+
+ " command output: " + result.stderr() + "\n" + result.stdout());
470+
logger.info("result.stderr: \n{0}", result.stderr());
471+
if (result == null || result.exitValue() != 0 || result.stdout() == null || !result.stdout().contains("flexible")) {
472+
return false;
473+
}
474+
return true;
475+
}
476+
477+
private static Callable<Boolean> checkLoadBalancerShapeFlexible(String loadBalancerOCID) {
478+
return () -> isLoadBalancerShapeFlexible(loadBalancerOCID);
479+
}
480+
481+
/**
482+
* Check work request status for load balancer.
483+
* @param loadBalancerOCID - load balancer OCID
484+
* @return true if succeeded , false over vise.
485+
*/
486+
public static boolean isWorkRequestUpdateShapeSucceeded(String loadBalancerOCID) {
487+
488+
LoggingFacade logger = getLogger();
489+
final String command = "oci lb work-request list --load-balancer-id "
490+
+ loadBalancerOCID
491+
+ " --query 'data[?type == `UpdateShape`].{id:id, lifecycleState:\"lifecycle-state\", "
492+
+ "message:message, timeFinished:\"time-finished\"}' "
493+
+ "| jq '.[] | select(.lifecycleState == \"SUCCEEDED\")'";
494+
ExecResult result = assertDoesNotThrow(() -> exec(command, true));
495+
logger.info("The command " + command + " returned exit value: " + result.exitValue()
496+
+ " command output: " + result.stderr() + "\n" + result.stdout());
497+
logger.info("result.stderr: \n{0}", result.stderr());
498+
if (result == null || result.exitValue() != 0 || result.stdout() == null || result.stderr().contains("ERROR")) {
499+
return false;
500+
}
501+
return true;
502+
}
503+
504+
/**
505+
* Check if lb work request status is succeeded.
506+
*
507+
* @param loadBalancerOCID lb ocid
508+
* @return true if succeeded, false otherwise
509+
*/
510+
public static Callable<Boolean> checkWorkRequestUpdateShapeSucceeded(String loadBalancerOCID) {
511+
return () -> isWorkRequestUpdateShapeSucceeded(loadBalancerOCID);
512+
}
427513

428514
/** Upgrade Traefik and wait for up to five minutes for the Traefik pod to be ready.
429515
*

integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/MonitoringUtils.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
import static oracle.weblogic.kubernetes.assertions.TestAssertions.isPrometheusAdapterReady;
106106
import static oracle.weblogic.kubernetes.assertions.TestAssertions.isPrometheusReady;
107107
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndCheckForServerNameInResponse;
108+
import static oracle.weblogic.kubernetes.utils.ApplicationUtils.callWebAppAndWaitTillReady;
108109
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterAndVerify;
109110
import static oracle.weblogic.kubernetes.utils.ClusterUtils.createClusterResource;
110111
import static oracle.weblogic.kubernetes.utils.CommonTestUtils.addSccToDBSvcAccount;
@@ -121,6 +122,7 @@
121122
import static oracle.weblogic.kubernetes.utils.ImageUtils.createTestRepoSecret;
122123
import static oracle.weblogic.kubernetes.utils.ImageUtils.imageRepoLoginAndPushImageToRegistry;
123124
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodExists;
125+
import static oracle.weblogic.kubernetes.utils.PodUtils.checkPodReady;
124126
import static oracle.weblogic.kubernetes.utils.PodUtils.getPodName;
125127
import static oracle.weblogic.kubernetes.utils.PodUtils.setPodAntiAffinity;
126128
import static oracle.weblogic.kubernetes.utils.SecretUtils.createSecretWithUsernamePassword;
@@ -261,6 +263,22 @@ public static void checkMetricsViaPrometheus(String searchKey, String expectedVa
261263
logger.info("Executing Curl cmd {0}", curlCmd);
262264
logger.info("Checking searchKey: {0}", searchKey);
263265
logger.info(" expected Value {0} ", expectedVal);
266+
if (OKE_CLUSTER) {
267+
try {
268+
if (!callWebAppAndWaitTillReady(curlCmd, 5)) {
269+
ExecResult result = ExecCommand.exec(KUBERNETES_CLI + " get all -A");
270+
logger.info(result.stdout());
271+
//restart core-dns service
272+
result = ExecCommand.exec(KUBERNETES_CLI + " rollout restart deployment coredns -n kube-system");
273+
logger.info(result.stdout());
274+
checkPodReady("coredns", null, "kube-system");
275+
result = ExecCommand.exec(curlCmd);
276+
logger.info(result.stdout());
277+
}
278+
} catch (Exception ex) {
279+
logger.warning(ex.getLocalizedMessage());
280+
}
281+
}
264282
testUntil(
265283
searchForKey(curlCmd, expectedVal),
266284
logger,

0 commit comments

Comments
 (0)