Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright (c) 2021, Oracle Corporation and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.

import sys

def usage():
print(sys.argv[0] + '-user <domain-user> -password <domain-password> -t3ChannelAddress <address of the cluster> -t3ChannelPort <t3 channel port>')

if len(sys.argv) < 4:
usage()
sys.exit(0)

#domainUser is hard-coded to weblogic. You can change to other name of your choice. Command line paramter -user.
domainUser = 'weblogic'
#domainPassword will be passed by Command line parameter -password.
domainPassword = None
t3ChannelPort = None
t3ChannelAddress = None

i = 1
while i < len(sys.argv):
if sys.argv[i] == '-user':
domainUser = sys.argv[i + 1]
i += 2
elif sys.argv[i] == '-password':
domainPassword = sys.argv[i + 1]
i += 2
elif sys.argv[i] == '-t3ChannelAddress':
t3ChannelAddress = sys.argv[i + 1]
i += 2
elif sys.argv[i] == '-t3ChannelPort':
t3ChannelPort = sys.argv[i + 1]
i += 2
else:
print('Unexpected argument switch at position ' + str(i) + ': ' + str(sys.argv[i]))
usage()
sys.exit(1)

t3ConnectionUri='t3://'+t3ChannelAddress+':'+t3ChannelPort
connect(domainUser, domainPassword, t3ConnectionUri)
myapps=cmo.getAppDeployments()
inactiveApp=0
for app in myapps:
bean=getMBean('/AppDeployments/'+app.getName()+'/Targets/')
targetsbean=bean.getTargets()
for target in targetsbean:
domainRuntime()
cd('AppRuntimeStateRuntime/AppRuntimeStateRuntime')
appstatus=cmo.getCurrentState(app.getName(),target.getName())
if appstatus != 'STATE_ACTIVE':
inactiveApp=inactiveApp+1
serverConfig()

# TIGHT COUPLING: this exact print text is expected to indicate a successful return.
if inactiveApp == 0:
print("Summary: all applications are active!")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment:

// TIGHT COUPLING: this exact print text is expected to indicate a successful return.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @edburns fixed it in 848ce8b

else:
print("Summary: number of inactive application:" + inactiveApp + '.')
11 changes: 11 additions & 0 deletions weblogic-azure-aks/src/main/arm/scripts/setupWLSDomain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,16 @@ function setup_wls_domain() {
wait_for_image_update_completed

wait_for_pod_completed

# make sure all the application are active, if not, fail the deployment.
scriptCheckAppStatus=$scriptDir/checkApplicationStatus.py
chmod ugo+x $scriptDir/checkApplicationStatus.py
utility_validate_application_status \
${wlsDomainNS} \
${wlsAdminSvcName} \
${wlsUserName} \
${wlsPassword} \
${scriptCheckAppStatus}
}

# Main script
Expand Down Expand Up @@ -790,6 +800,7 @@ export sasTokenValidTime=3600
export storageFileShareName="weblogic"
export storageResourceGroup=${currentResourceGroup}
export sharedPath="/shared"
export wlsAdminSvcName="${wlsDomainUID}-admin-server"
export wlsDomainNS="${wlsDomainUID}-ns"
export wlsOptHelmChart="https://oracle.github.io/weblogic-kubernetes-operator/charts"
export wlsOptNameSpace="weblogic-operator-ns"
Expand Down
36 changes: 36 additions & 0 deletions weblogic-azure-aks/src/main/arm/scripts/utility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,42 @@ function utility_upload_file_to_fileshare() {
fi
}

#
# Make sure all the applications are running
# Exit with error if there is inactive application.
# $1 - namespace of the domain
# $2 - ClusterIP service name of admin server
# $3 - domain user
# $4 - domain password
# $5 - path of python script which checks application status, the script will run on admin server pod.
function utility_validate_application_status() {
local wlsDomainNS=$1
local wlsAdminSvcName=$2
local wlsUser=$3
local wlsPassword=$4
local pyScriptPath=$5

local podName=$(kubectl -n ${wlsDomainNS} get pod -l weblogic.serverName=admin-server -o json \
| jq '.items[0] | .metadata.name' \
| tr -d "\"")

# get non-ssl port
local adminTargetPort=$(kubectl get svc ${wlsAdminSvcName} -n ${wlsDomainNS} -o json | jq '.spec.ports[] | select(.name=="default") | .port')
local t3ChannelAddress="${podName}.${wlsDomainNS}"

local targetFilePath=/tmp/checkApplicationStatus.py
echo "copy ${pyScriptPath} to ${targetFilePath}"
kubectl cp ${pyScriptPath} -n ${wlsDomainNS} ${podName}:${targetFilePath}
kubectl exec -it ${podName} -n ${wlsDomainNS} -c "weblogic-server" \
-- bash -c "wlst.sh ${targetFilePath} -user ${wlsUser} -password ${wlsPassword} -t3ChannelAddress ${t3ChannelAddress} -t3ChannelPort ${adminTargetPort}" |
grep "Summary: all applications are active"

if [ $? == 1 ];then
echo "Failed to deploy application to WLS cluster. Please make sure the configurations are correct."
exit 1
fi
}

# Call this function to make sure pods of a domain are running.
# * Make sure the admin server pod is running
# * Make sure all the managed server pods are running
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var const_arguments = '${ocrSSOUser} ${ocrSSOPSW} ${aksClusterRGName} ${aksClust
var const_buildDockerImageScript='createVMAndBuildImage.sh'
var const_commonScript = 'common.sh'
var const_invokeSetUpDomainScript = 'invokeSetupWLSDomain.sh'
var const_pyCheckAppStatusScript = 'py-scripts/checkApplicationStatus.py'
var const_pvTempalte = 'pv.yaml.template'
var const_pvcTempalte = 'pvc.yaml.template'
var const_scriptLocation = uri(_artifactsLocation, 'scripts/')
Expand All @@ -88,6 +89,7 @@ resource deploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
uri(const_scriptLocation, '${const_commonScript}${_artifactsLocationSasToken}')
uri(const_scriptLocation, '${const_buildDockerImageScript}${_artifactsLocationSasToken}')
uri(const_scriptLocation, '${const_updateDomainConfigScript}${_artifactsLocationSasToken}')
uri(const_scriptLocation, '${const_pyCheckAppStatusScript}${_artifactsLocationSasToken}')
]
cleanupPreference: 'OnSuccess'
retentionInterval: 'P1D'
Expand Down