From 812b274dd2a5862c635a4288340bbec252684ba4 Mon Sep 17 00:00:00 2001 From: Fernanda Meheust Date: Thu, 6 Jul 2023 22:25:46 +0200 Subject: [PATCH] Application information + output for LB IP + deploy script (#7) * Application information + output for LB IP + deploy script * Version --- interface.yaml | 10 ++++------ output.tf | 2 +- update_container_instance.sh | 21 ++++++++++++--------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/interface.yaml b/interface.yaml index b8600b6..fe61325 100644 --- a/interface.yaml +++ b/interface.yaml @@ -5,14 +5,12 @@ title: "App Stack for Java" description: | The App Stack for Java can deploy existing Java applications to serverless Container Instances behind a load balancer in the Oracle Cloud. It supports multiple options: the source code of the application is in DevOps, the application is uploaded as a war or jar, or as a container image. schemaVersion: 1.1.0 -version: "20230607" +version: "v0.1.3" +informationalText: | + For more information and product documentation please visit the App Stack project page . logoUrl: "https://cloudmarketplace.oracle.com/marketplace/content?contentId=58352039" -source: - type: marketplace - reference: 47726045 - locale: "en" variableGroups: @@ -817,7 +815,7 @@ outputGroups: outputs: app_url: type: link - title: Open Application URL + title: Application URL visible: true diff --git a/output.tf b/output.tf index a76068f..9bf43ac 100644 --- a/output.tf +++ b/output.tf @@ -5,5 +5,5 @@ output "app_url" { description = "Application URL : " - value = (var.create_fqdn ? "https://${local.domain_name}" : oci_load_balancer.flexible_loadbalancer.ip_address_details[0].ip_address) + value = (var.create_fqdn ? "https://${local.domain_name}" : "http://${oci_load_balancer.flexible_loadbalancer.ip_address_details[0].ip_address}") } diff --git a/update_container_instance.sh b/update_container_instance.sh index adf2204..9c53cfd 100644 --- a/update_container_instance.sh +++ b/update_container_instance.sh @@ -2,16 +2,18 @@ # Copyright (c) 2023, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. # drain backend from backend set -OUTPUT=$(oci lb backend update --backend-name $1 --backend-set-name $2 --backup false --drain true --load-balancer-id $3 --offline false --weight 1 --wait-for-state SUCCEEDED --wait-for-state FAILED) -if [[ $OUTPUT == *"FAILED"* ]] ; then +OUTPUT=$(oci lb backend update --backend-name $1 --backend-set-name $2 --backup false --drain true --load-balancer-id $3 --offline false --weight 1 --wait-for-state SUCCEEDED --wait-for-state FAILED | python3 -c "import sys, json; print(json.load(sys.stdin)['data']['lifecycle-state'])" | tr ‘[:lower:]’ ‘[:upper:]’) +echo $OUTPUT +if [ "$OUTPUT" = "FAILED" ] ; then exit 1 else echo "load balancer drained backend: $1" fi # update backend -OUTPUT=$(oci container-instances container-instance restart --container-instance-id $4 --wait-for-state SUCCEEDED --wait-for-state FAILED) -if [[ $OUTPUT == *"FAILED"* ]] ; then +OUTPUT=$(oci container-instances container-instance restart --container-instance-id $4 --wait-for-state SUCCEEDED --wait-for-state FAILED | python3 -c "import sys, json; print(json.load(sys.stdin)['data']['status'])" | tr ‘[:lower:]’ ‘[:upper:]’) +echo $OUTPUT +if [ "$OUTPUT" = "FAILED" ] ; then exit 1 else echo "updated container instance: $4" @@ -20,8 +22,9 @@ fi # wait for container instance to come up again sleep 30 OUTPUT="FAILED" +echo $OUTPUT i=0 -while [[ $OUTPUT != *"OK"* ]] +while [ "$OUTPUT" != "OK" ] do let "i+=1" if [ $i -gt 30 ] @@ -30,16 +33,16 @@ do exit 1 fi sleep 10 - OUTPUT=$(oci lb backend-health get --backend-name $1 --backend-set-name $2 --load-balancer-id $3) + OUTPUT=$(oci lb backend-health get --backend-name $1 --backend-set-name $2 --load-balancer-id $3 | python3 -c "import sys, json; print(json.load(sys.stdin)['data']['status'])" | tr ‘[:lower:]’ ‘[:upper:]’) echo $OUTPUT done # undrain backend from backend set -OUTPUT=$(oci lb backend update --backend-name $1 --backend-set-name $2 --backup false --drain false --load-balancer-id $3 --offline false --weight 1 --wait-for-state SUCCEEDED --wait-for-state FAILED) +OUTPUT=$(oci lb backend update --backend-name $1 --backend-set-name $2 --backup false --drain false --load-balancer-id $3 --offline false --weight 1 --wait-for-state SUCCEEDED --wait-for-state FAILED | python3 -c "import sys, json; print(json.load(sys.stdin)['data']['lifecycle-state'])" | tr ‘[:lower:]’ ‘[:upper:]’) echo $OUTPUT -if [[ $OUTPUT == *"FAILED"* ]] ; then +if [ "$OUTPUT" = "FAILED" ] ; then exit 1 else echo "load balancer undrained backend: $1" fi -exit 0 \ No newline at end of file +exit 0