diff --git a/kubernetes/samples/scripts/domain-lifecycle/helper.sh b/kubernetes/samples/scripts/domain-lifecycle/helper.sh index 6d949885e74..3e4197878c7 100644 --- a/kubernetes/samples/scripts/domain-lifecycle/helper.sh +++ b/kubernetes/samples/scripts/domain-lifecycle/helper.sh @@ -693,8 +693,6 @@ function timestamp() { local ymdhms="`echo $timestamp | awk '{ print $1 }'`" # convert nano to milli local milli="`echo $timestamp | awk '{ print $2 }' | sed 's/\(^...\).*/\1/'`" - local secs_since_epoch="`echo $timestamp | awk '{ print $3 }'`" - local millis_since_opoch="${secs_since_epoch}${milli}" local timezone="`echo $timestamp | awk '{ print $4 }'`" echo "${ymdhms}.${milli} ${timezone}" } diff --git a/src/scripts/initialize-internal-operator-identity.sh b/src/scripts/initialize-internal-operator-identity.sh index 22b96bdb48e..e593727218c 100755 --- a/src/scripts/initialize-internal-operator-identity.sh +++ b/src/scripts/initialize-internal-operator-identity.sh @@ -34,56 +34,24 @@ function generateInternalIdentity { host="internal-weblogic-operator-svc" SANS="DNS:${host},DNS:${host}.${NAMESPACE},DNS:${host}.${NAMESPACE}.svc,DNS:${host}.${NAMESPACE}.svc.cluster.local" DAYS_VALID="3650" - TEMP_PW="temp_password" OP_PREFIX="weblogic-operator" - OP_ALIAS="${OP_PREFIX}-alias" - OP_JKS="${TEMP_DIR}/${OP_PREFIX}.jks" - OP_PKCS12="${TEMP_DIR}/${OP_PREFIX}.p12" - OP_CSR="${TEMP_DIR}/${OP_PREFIX}.csr" OP_CERT_PEM="${TEMP_DIR}/${OP_PREFIX}.cert.pem" OP_KEY_PEM="${TEMP_DIR}/${OP_PREFIX}.key.pem" - KEYTOOL=${JAVA_HOME}/bin/keytool - - # generate a keypair for the operator's internal service, putting it in a keystore - $KEYTOOL \ - -genkey \ - -keystore ${OP_JKS} \ - -alias ${OP_ALIAS} \ - -storepass ${TEMP_PW} \ - -keypass ${TEMP_PW} \ - -keysize 2048 \ - -keyalg RSA \ - -validity ${DAYS_VALID} \ - -dname "CN=weblogic-operator" \ - -ext KU=digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment,keyAgreement \ - -ext SAN="${SANS}" - - # extract the cert to a pem file - $KEYTOOL \ - -exportcert \ - -keystore ${OP_JKS} \ - -storepass ${TEMP_PW} \ - -alias ${OP_ALIAS} \ - -rfc \ - > ${OP_CERT_PEM} - - # convert the keystore to a pkcs12 file - $KEYTOOL \ - -importkeystore \ - -srckeystore ${OP_JKS} \ - -srcstorepass ${TEMP_PW} \ - -destkeystore ${OP_PKCS12} \ - -deststorepass ${TEMP_PW} \ - -deststoretype PKCS12 - - # extract the private key from the pkcs12 file to a pem file + + # generate a keypair for the operator's internal service + # openssl v1.1.1 is the required minimum to use 'addext' option for + # speciifying "Subject Alternative Names (SANS)" thus the following + # configuration cannot be used on Oracle Linux 7-slim. openssl \ - pkcs12 \ - -in ${OP_PKCS12} \ - -passin pass:${TEMP_PW} \ + req \ + -newkey rsa:2048 \ -nodes \ - -nocerts \ - -out ${OP_KEY_PEM} + -keyout ${OP_KEY_PEM} \ + -x509 \ + -days ${DAYS_VALID} \ + -out ${OP_CERT_PEM} \ + -subj "/C=US/ST=CALIFORNIA/L=REDWOOD CITY/O=WebLogic/OU=Development/CN=weblogic-operator" \ + -addext "subjectAltName = ${SANS}" # copy the certificate and key to the locations the operator runtime expects base64 -i ${OP_CERT_PEM} | tr -d '\n' > ${INTERNAL_CERT_BASE64_PEM} diff --git a/src/scripts/scaling/scalingAction.sh b/src/scripts/scaling/scalingAction.sh index 8b705f8b5c6..86d52554001 100755 --- a/src/scripts/scaling/scalingAction.sh +++ b/src/scripts/scaling/scalingAction.sh @@ -2,8 +2,6 @@ # Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. -echo "called scalingAction.sh" >> scalingAction.log - # script parameters scaling_action="" wls_domain_uid="" @@ -16,10 +14,352 @@ scaling_size=1 access_token="" kubernetes_master="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}" +# timestamp +# purpose: echo timestamp in the form yyyymmddThh:mm:ss.mmm ZZZ +# example: 20181001T14:00:00.001 UTC +function timestamp() { + local timestamp="`date --utc '+%Y-%m-%dT%H:%M:%S %N %s %Z' 2>&1`" + if [ ! "${timestamp/illegal/xyz}" = "${timestamp}" ]; then + # old shell versions don't support %N or --utc + timestamp="`date -u '+%Y-%m-%dT%H:%M:%S 000000 %s %Z' 2>&1`" + fi + local ymdhms="`echo $timestamp | awk '{ print $1 }'`" + # convert nano to milli + local milli="`echo $timestamp | awk '{ print $2 }' | sed 's/\(^...\).*/\1/'`" + local timezone="`echo $timestamp | awk '{ print $4 }'`" + echo "${ymdhms}.${milli} ${timezone}" +} + +function trace() { + echo "@[$(timestamp)][$wls_domain_namespace][$wls_domain_uid][$wls_cluster_name][INFO]" "$@" >> scalingAction.log +} + +function print_usage() { + echo "Usage: scalingAction.sh --action=[scaleUp | scaleDown] --domain_uid= --cluster_name= [--kubernetes_master=https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}] [--access_token=] [--wls_domain_namespace=default] [--operator_namespace=weblogic-operator] [--operator_service_name=weblogic-operator] [--scaling_size=1]" + echo " where" + echo " action - scaleUp or scaleDown" + echo " domain_uid - WebLogic Domain Unique Identifier" + echo " cluster_name - WebLogic Cluster Name" + echo " kubernetes_master - Kubernetes master URL, default=https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}" + echo " access_token - Service Account Bearer token for authentication and authorization for access to REST Resources" + echo " wls_domain_namespace - Kubernetes name space WebLogic Domain is defined in, default=default" + echo " operator_service_name - WebLogic Operator Service name, default=internal-weblogic-operator-svc" + echo " operator_service_account - Kubernetes Service Account for WebLogic Operator, default=weblogic-operator" + echo " operator_namespace - WebLogic Operator Namespace, default=weblogic-operator" + echo " scaling_size - number of WebLogic server instances by which to scale up or down, default=1" + exit 1 +} + +# Retrieve WebLogic Operator Service Account Token for Authorization +function initialize_access_token() { + if [ -z "$access_token" ] + then + access_token=`cat /var/run/secrets/kubernetes.io/serviceaccount/token` + fi +} + +function logScalingParameters() { + trace "scaling_action: $scaling_action" + trace "wls_domain_uid: $wls_domain_uid" + trace "wls_cluster_name: $wls_cluster_name" + trace "wls_domain_namespace: $wls_domain_namespace" + trace "operator_service_name: $operator_service_name" + trace "operator_service_account: $operator_service_account" + trace "operator_namespace: $operator_namespace" + trace "scaling_size: $scaling_size" +} + +# Query WebLogic Operator Service Port +function get_operator_internal_rest_port() { + local STATUS=$(curl \ + -v \ + --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ + -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \ + -X GET $kubernetes_master/api/v1/namespaces/$operator_namespace/services/$operator_service_name/status) + if [ $? -ne 0 ] + then + trace "Failed to retrieve status of $operator_service_name in name space: $operator_namespace" + trace "STATUS: $STATUS" + exit 1 + fi + + local port + if [ -x "$(command -v jq)" ]; then + local extractPortCmd="(.spec.ports[] | select (.name == \"rest\") | .port)" + port=$(echo "${STATUS}" | jq "${extractPortCmd}") + else +cat > cmds-$$.py << INPUT +import sys, json +for i in json.load(sys.stdin)["spec"]["ports"]: + if i["name"] == "rest": + print(i["port"]) +INPUT +port=$(echo "${STATUS}" | python cmds-$$.py) + fi + echo "$port" +} + +# Retrieve the api version of the deployed Custom Resource Domain +function get_domain_api_version() { + # Retrieve Custom Resource Definition for WebLogic domain + local CRD=$(curl \ + -v \ + --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ + -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \ + -X GET \ + $kubernetes_master/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/domains.weblogic.oracle) + if [ $? -ne 0 ] + then + trace "Failed to retrieve Custom Resource Definition for WebLogic domain" + trace "CRD: $CRD" + exit 1 + fi + +# Find domain version + local domain_api_version + if [ -x "$(command -v jq)" ]; then + domain_api_version=$(echo "${CRD}" | jq -r '.spec.version') + else +cat > cmds-$$.py << INPUT +import sys, json +print(json.load(sys.stdin)["spec"]["version"]) +INPUT +domain_api_version=`echo ${CRD} | python cmds-$$.py` + fi + echo "$domain_api_version" +} + +# Retrieve Custom Resource Domain +function get_custom_resource_domain() { + local DOMAIN=$(curl \ + -v \ + --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ + -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \ + $kubernetes_master/apis/weblogic.oracle/$domain_api_version/namespaces/$wls_domain_namespace/domains/$domain_uid) + if [ $? -ne 0 ]; then + trace "Failed to retrieve WebLogic Domain Custom Resource Definition" + exit 1 + fi + echo "$DOMAIN" +} + +# Verify if cluster is defined in clusters of the Custom Resource Domain +# args: +# $1 Custom Resource Domain +function is_defined_in_clusters() { + local DOMAIN="$1" + local in_cluster_startup="False" + if [ -x "$(command -v jq)" ]; then + local inClusterStartupCmd="(.items[].spec.clusters[] | select (.clusterName == \"${wls_cluster_name}\"))" + local clusterDefinedInCRD=$(echo "${DOMAIN}" | jq "${inClusterStartupCmd}") + if [ "${clusterDefinedInCRD}" != "" ]; then + in_cluster_startup="True" + fi + else +cat > cmds-$$.py << INPUT +import sys, json +outer_loop_must_break = False +for i in json.load(sys.stdin)["items"]: + j = i["spec"]["clusters"] + for index, cs in enumerate(j): + if j[index]["clusterName"] == "$wls_cluster_name": + outer_loop_must_break = True + print True + break +if outer_loop_must_break == False: + print False +INPUT +in_cluster_startup=`echo ${DOMAIN} | python cmds-$$.py` + fi + echo "$in_cluster_startup" +} + +# Gets the current replica count of the cluster +# args: +# $1 Custom Resource Domain +function get_num_ms_in_cluster() { + local DOMAIN="$1" + local num_ms + if [ -x "$(command -v jq)" ]; then + local numManagedServersCmd="(.items[].spec.clusters[] | select (.clusterName == \"${wls_cluster_name}\") | .replicas)" + num_ms=$(echo "${DOMAIN}" | jq "${numManagedServersCmd}") + else +cat > cmds-$$.py << INPUT +import sys, json +for i in json.load(sys.stdin)["items"]: + j = i["spec"]["clusters"] + for index, cs in enumerate(j): + if j[index]["clusterName"] == "$wls_cluster_name": + print j[index]["replicas"] +INPUT + num_ms=`echo ${DOMAIN} | python cmds-$$.py` + fi + + if [ "${num_ms}" == "null" ]; then + num_ms=0 + fi + + echo "$num_ms" +} + +# Gets the replica count at the Domain level +# args: +# $1 Custom Resource Domain +function get_num_ms_domain_scope() { + local DOMAIN="$1" + local num_ms + if [ -x "$(command -v jq)" ]; then + num_ms=$(echo "${DOMAIN}" | jq -r '.items[].spec.replicas' ) + else +cat > cmds-$$.py << INPUT +import sys, json +for i in json.load(sys.stdin)["items"]: + print i["spec"]["replicas"] +INPUT + num_ms=`echo ${DOMAIN} | python cmds-$$.py` + fi + + if [ "${num_ms}" == "null" ]; then + # if not defined then default to 0 + num_ms=0 + fi + + echo "$num_ms" +} + +# +# Function to get minimum replica count for cluster +# $1 - Domain resource in json format +# $2 - Name of the cluster +# $3 - Return value containing minimum replica count +# +function get_min_replicas { + local domainJson=$1 + local clusterName=$2 + local __result=$3 + + eval $__result=0 + if [ -x "$(command -v jq)" ]; then + minReplicaCmd="(.status.clusters[] | select (.clusterName == \"${clusterName}\")) \ + | .minimumReplicas" + minReplicas=$(echo ${domainJson} | jq "${minReplicaCmd}") + else +cat > cmds-$$.py << INPUT +import sys, json +for i in json.load(sys.stdin)["items"]: + j = i["status"]["clusters"] + for index, cs in enumerate(j): + if j[index]["clusterName"] == "$clusterName" + print j[index]["minimumReplicas"] +INPUT + minReplicas=`echo ${DOMAIN} | python cmds-$$.py` + fi + eval $__result=${minReplicas} +} + +# Get the current replica count for the WLS cluster if defined in the CRD's Cluster +# configuration. If WLS cluster is not defined in the CRD then return the Domain +# scoped replica value, if present. Returns replica count = 0 if no replica count found. +# args: +# $1 "True" if WLS cluster configuration defined in CRD, "False" otherwise +# $2 Custom Resource Domain +function get_replica_count() { + local in_cluster_startup="$1" + local DOMAIN="$2" + local num_ms + if [ "$in_cluster_startup" == "True" ] + then + trace "$wls_cluster_name defined in clusters" + num_ms=$(get_num_ms_in_cluster "$DOMAIN") + else + trace "$wls_cluster_name NOT defined in clusters" + num_ms=$(get_num_ms_domain_scope "$DOMAIN") + fi + + get_min_replicas "${DOMAIN}" "${wls_cluster_name}" minReplicas + if [ "${num_ms}" -lt "${minReplicas}" ]; then + # Reset managed server count to minimum replicas + num_ms=${minReplicas} + fi + + echo "$num_ms" +} + +# Determine the nuber of managed servers to scale +# args: +# $1 scaling action (scaleUp or scaleDown) +# $2 current replica count +# $3 scaling increment value +function calculate_new_ms_count() { + local scaling_action="$1" + local current_replica_count="$2" + local scaling_size="$3" + local new_ms + if [ "$scaling_action" == "scaleUp" ]; + then + # Scale up by specified scaling size + # shellcheck disable=SC2004 + new_ms=$(($current_replica_count + $scaling_size)) + else + # Scale down by specified scaling size + new_ms=$(($current_replica_count - $scaling_size)) + fi + echo "$new_ms" +} + +# Verify if requested managed server scaling count is less than the configured +# minimum replica count for the cluster. +# args: +# $1 Managed server count +# $2 Custom Resource Domain +# $3 Cluster name +function verify_minimum_ms_count_for_cluster() { + local new_ms="$1" + local domainJson="$2" + local clusterName="$3" + # check if replica count is less than minimum replicas + get_min_replicas "${domainJson}" "${clusterName}" minReplicas + if [ "${new_ms}" -lt "${minReplicas}" ]; then + trace "Scaling request to new managed server count $new_ms is less than configured minimum \ + replica count $minReplicas" + exit 1 + fi +} + +# Create the REST endpoint CA certificate in PEM format +# args: +# $1 certificate file name to create +function create_ssl_certificate_file() { + local pem_filename="$1" + if [ ${INTERNAL_OPERATOR_CERT} ]; + then + echo ${INTERNAL_OPERATOR_CERT} | base64 --decode > $pem_filename + else + trace "Operator Cert File not found" + exit 1 + fi +} + +# Create request body for scaling request +# args: +# $1 replica count +function get_request_body() { +local new_ms="$1" +local request_body=$(cat < --cluster_name= [--kubernetes_master=https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}] [--access_token=] [--wls_domain_namespace=default] [--operator_namespace=weblogic-operator] [--operator_service_name=weblogic-operator] [--scaling_size=1]" - echo " where" - echo " action - scaleUp or scaleDown" - echo " domain_uid - WebLogic Domain Unique Identifier" - echo " cluster_name - WebLogic Cluster Name" - echo " kubernetes_master - Kubernetes master URL, default=https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}" - echo " access_token - Service Account Bearer token for authentication and authorization for access to REST Resources" - echo " wls_domain_namespace - Kubernetes name space WebLogic Domain is defined in, default=default" - echo " operator_service_name - WebLogic Operator Service name, default=internal-weblogic-operator-svc" - echo " operator_service_account - Kubernetes Service Account for WebLogic Operator, default=weblogic-operator" - echo " operator_namespace - WebLogic Operator Namespace, default=weblogic-operator" - echo " scaling_size - number of WebLogic server instances by which to scale up or down, default=1" - exit 1 + print_usage fi -# Retrieve WebLogic Operator Service Account Token for Authorization -if [ -z "$access_token" ] -then - access_token=`cat /var/run/secrets/kubernetes.io/serviceaccount/token` -fi +# Initialize the client access token +initialize_access_token -echo "scaling_action: $scaling_action" >> scalingAction.log -echo "wls_domain_uid: $wls_domain_uid" >> scalingAction.log -echo "wls_cluster_name: $wls_cluster_name" >> scalingAction.log -echo "wls_domain_namespace: $wls_domain_namespace" >> scalingAction.log -echo "operator_service_name: $operator_service_name" >> scalingAction.log -echo "operator_service_account: $operator_service_account" >> scalingAction.log -echo "operator_namespace: $operator_namespace" >> scalingAction.log -echo "scaling_size: $scaling_size" >> scalingAction.log +# Log the script input parameters for debugging +logScalingParameters -# Query WebLogic Operator Service Port -STATUS=`curl -v --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -X GET $kubernetes_master/api/v1/namespaces/$operator_namespace/services/$operator_service_name/status` -if [ $? -ne 0 ] - then - echo "Failed to retrieve status of $operator_service_name in name space: $operator_namespace" >> scalingAction.log - echo "STATUS: $STATUS" >> scalingAction.log - exit 1 -fi - -cat > cmds.py << INPUT -import sys, json -for i in json.load(sys.stdin)["spec"]["ports"]: - if i["name"] == "rest": - print(i["port"]) -INPUT -port=`echo ${STATUS} | python cmds.py` -echo "port: $port" >> scalingAction.log - -# Retrieve Custom Resource Definition for WebLogic domain -CRD=`curl -v --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -X GET $kubernetes_master/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/domains.weblogic.oracle` -if [ $? -ne 0 ] - then - echo "Failed to retrieve Custom Resource Definition for WebLogic domain" >> scalingAction.log - echo "CRD: $CRD" >> scalingAction.log - exit 1 -fi +# Retrieve the operator's REST endpoint port +port=$(get_operator_internal_rest_port) +trace "port: $port" -# Find domain version -cat > cmds.py << INPUT -import sys, json -print(json.load(sys.stdin)["spec"]["version"]) -INPUT -domain_api_version=`echo ${CRD} | python cmds.py` -echo "domain_api_version: $domain_api_version" >> scalingAction.log +# Retrieve the api version of the deployed CRD +domain_api_version=$(get_domain_api_version) +trace "domain_api_version: $domain_api_version" -# Reteive Custom Resource Domain -DOMAIN=`curl -v --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" $kubernetes_master/apis/weblogic.oracle/$domain_api_version/namespaces/$wls_domain_namespace/domains/$domain_uid` -if [ $? -ne 0 ] - then - echo "Failed to retrieve WebLogic Domain Custom Resource Definition" >> scalingAction.log - echo "DOMAIN: $DOMAIN" >> scalingAction.log - exit 1 -fi -echo "DOMAIN: $DOMAIN" >> scalingAction.log +# Retrieve the Domain configuration +DOMAIN=$(get_custom_resource_domain) -# Verify if cluster is defined in clusters -cat > cmds.py << INPUT -import sys, json -outer_loop_must_break = False -for i in json.load(sys.stdin)["items"]: - j = i["spec"]["clusters"] - for index, cs in enumerate(j): - if j[index]["clusterName"] == "$wls_cluster_name": - outer_loop_must_break = True - print True - break -if outer_loop_must_break == False: - print False -INPUT -in_cluster_startup=`echo ${DOMAIN} | python cmds.py` +# Determine if WLS cluster has configuration in CRD +in_cluster_startup=$(is_defined_in_clusters "$DOMAIN") # Retrieve replica count, of WebLogic Cluster, from Domain Custom Resource # depending on whether the specified cluster is defined in clusters # or not. -if [ $in_cluster_startup == "True" ] -then - echo "$wls_cluster_name defined in clusters" >> scalingAction.log +current_replica_count=$(get_replica_count "$in_cluster_startup" "$DOMAIN") +trace "current number of managed servers is $current_replica_count" -cat > cmds.py << INPUT -import sys, json -for i in json.load(sys.stdin)["items"]: - j = i["spec"]["clusters"] - for index, cs in enumerate(j): - if j[index]["clusterName"] == "$wls_cluster_name": - print j[index]["replicas"] -INPUT - num_ms=`echo ${DOMAIN} | python cmds.py` -else - echo "$wls_cluster_name NOT defined in clusters" >> scalingAction.log -cat > cmds.py << INPUT -import sys, json -for i in json.load(sys.stdin)["items"]: - print i["spec"]["replicas"] -INPUT - num_ms=`echo ${DOMAIN} | python cmds.py` -fi -echo "current number of managed servers is $num_ms" >> scalingAction.log - -# Cleanup cmds.py -[ -e cmds.py ] && rm cmds.py +# Cleanup cmds-$$.py +[ -e cmds-$$.py ] && rm cmds-$$.py # Calculate new managed server count -if [ "$scaling_action" == "scaleUp" ] -then - # Scale up by specified scaling size - new_ms=$(($num_ms + $scaling_size)) -else - # Scale down by specified scaling size - new_ms=$(($num_ms - $scaling_size)) -fi +new_ms=$(calculate_new_ms_count "$scaling_action" "$current_replica_count" "$scaling_size") -echo "new_ms is $new_ms" >> scalingAction.log +# Verify the requested new managed server count is not less than +# configured minimum replica count for the cluster +verify_minimum_ms_count_for_cluster "$new_ms" "$DOMAIN" "$wls_cluster_name" -request_body=$(cat <> scalingAction.log +# Create the scaling request body +request_body=$(get_request_body "$new_ms") content_type="Content-Type: application/json" accept_resp_type="Accept: application/json" requested_by="X-Requested-By: WLDF" authorization="Authorization: Bearer $access_token" -pem_filename="weblogic_operator.pem" +pem_filename="weblogic_operator-$$.pem" # Create PEM file for Opertor SSL Certificate -if [ ${INTERNAL_OPERATOR_CERT} ] -then - echo ${INTERNAL_OPERATOR_CERT} | base64 --decode > $pem_filename -else - echo "Operator Cert File not found" >> scalingAction.log - exit 1 -fi +create_ssl_certificate_file "$pem_filename" # Operator Service REST URL for scaling operator_url="https://$operator_service_name.$operator_namespace.svc.cluster.local:$port/operator/v1/domains/$wls_domain_uid/clusters/$wls_cluster_name/scale" -echo "operator_url: $operator_url" >> scalingAction.log + +trace "domainName: $wls_domain_uid | clusterName: $wls_cluster_name | action: $scaling_action | port: $port | apiVer: $domain_api_version | inClusterPresent: $in_cluster_startup | oldReplica: $num_ms | newReplica: $new_ms | operator_url: $operator_url " # send REST request to Operator if [ -e $pem_filename ] then - result=`curl --cacert $pem_filename -X POST -H "$content_type" -H "$requested_by" -H "$authorization" -d "$request_body" $operator_url` + result=$(curl \ + -v \ + --cacert $pem_filename \ + -X POST \ + -H "$content_type" \ + -H "$requested_by" \ + -H "$authorization" \ + -d "$request_body" \ + $operator_url) else - echo "Operator PEM formatted file not found" >> scalingAction.log + trace "Operator PEM formatted file not found" exit 1 fi if [ $? -ne 0 ] then - echo "Failed scaling request to WebLogic Operator" >> scalingAction.log - echo $result >> scalingAction.log + trace "Failed scaling request to WebLogic Operator" + trace "$result" exit 1 fi -echo $result >> scalingAction.log # Cleanup generated operator PEM file -[ -e $pem_filename ] && rm $pem_filename +[ -e $pem_filename ] && rm $pem_filename \ No newline at end of file