Skip to content

Commit 9c59da1

Browse files
committed
applied excellent comments from @tbarnes-us.
Signed-off-by: galiacheng <haixia.cheng@microsoft.com> Changes to be committed: modified: samples/scripts/common/utility.sh modified: samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/create-domain-on-aks.sh
1 parent cc12c30 commit 9c59da1

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

kubernetes/samples/scripts/common/utility.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,10 @@ function checkPvState {
190190
# $1 - name of volume claim
191191
# $2 - expected state of volume claim
192192
function checkPvcState {
193-
194193
echo "Checking if the persistent volume claim ${1:?} is ${2:?}"
194+
local end_secs=$(SECONDS + 10)
195195
local pvc_state=`kubectl get pvc $1 -o jsonpath='{.status.phase}'`
196-
attempts=0
197-
while [ ! "$pvc_state" = "$2" ] && [ ! $attempts -eq 10 ]; do
198-
attempts=$((attempts + 1))
196+
while [ ! "$pvc_state" = "$2" ] && [ $SECONDS -le $end_secs ]; do
199197
sleep 1
200198
pvc_state=`kubectl get pvc $1 -o jsonpath='{.status.phase}'`
201199
done

kubernetes/samples/scripts/create-weblogic-domain-on-azure-kubernetes-service/create-domain-on-aks.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ function createFileShare {
327327
nameAvailable=$(echo "$ret" | grep "nameAvailable" | grep "false")
328328
if [ -n "$nameAvailable" ]; then
329329
echo $ret
330-
fail "Storage account ${aksClusterName} is unavaliable."
330+
fail "Storage account ${aksClusterName} is unavailable."
331331
fi
332332

333333
echo Creating Azure Storage Account ${storageAccountName}.
@@ -367,18 +367,18 @@ function createFileShare {
367367

368368
function configureStorageAccountNetwork {
369369
# get the resource group name of the AKS managed resources
370-
aksMCRGName=$(az aks show --name $aksClusterName --resource-group $azureResourceGroupName -o tsv --query "nodeResourceGroup")
370+
local aksMCRGName=$(az aks show --name $aksClusterName --resource-group $azureResourceGroupName -o tsv --query "nodeResourceGroup")
371371
echo ${aksMCRGName}
372372

373373
# get network name of AKS cluster
374-
aksNetworkName=$(az resource list --resource-group ${aksMCRGName} --resource-type Microsoft.Network/virtualNetworks -o tsv --query '[*].name')
374+
local aksNetworkName=$(az resource list --resource-group ${aksMCRGName} --resource-type Microsoft.Network/virtualNetworks -o tsv --query '[*].name')
375375
echo ${aksNetworkName}
376376

377377
# get subnet name of AKS agent pool
378-
aksSubnetName=$(az network vnet subnet list --resource-group ${aksMCRGName} --vnet-name ${aksNetworkName} -o tsv --query "[*].name")
378+
local aksSubnetName=$(az network vnet subnet list --resource-group ${aksMCRGName} --vnet-name ${aksNetworkName} -o tsv --query "[*].name")
379379
echo ${aksSubnetName}
380380

381-
aksSubnetId=$(az network vnet subnet list --resource-group ${aksMCRGName} --vnet-name ${aksNetworkName} -o tsv --query "[*].id")
381+
local aksSubnetId=$(az network vnet subnet list --resource-group ${aksMCRGName} --vnet-name ${aksNetworkName} -o tsv --query "[*].id")
382382
echo ${aksSubnetId}
383383

384384
az network vnet subnet update \
@@ -427,8 +427,8 @@ function createWebLogicDomain {
427427
}
428428

429429
function waitForJobComplete {
430-
attempts=0
431-
svcState="running"
430+
local attempts=0
431+
local svcState="running"
432432
while [ ! "$svcState" == "completed" ] && [ ! $attempts -eq 30 ]; do
433433
svcState="completed"
434434
attempts=$((attempts + 1))
@@ -439,25 +439,25 @@ function waitForJobComplete {
439439
# ${domainUID}-${adminServerName}, e.g. domain1-admin-server
440440
# ${domainUID}-${adminServerName}-ext, e.g. domain1-admin-server-ext
441441
# ${domainUID}-${adminServerName}-external-lb, e.g domain1-admin-server-external-lb
442-
adminServiceCount=$(kubectl get svc | grep -c "${domainUID}-${adminServerName}")
442+
local adminServiceCount=$(kubectl get svc | grep -c "${domainUID}-${adminServerName}")
443443
if [ ${adminServiceCount} -lt 3 ]; then svcState="running"; fi
444444

445445
# If the job is completed, there should have the following services created, .assuming initialManagedServerReplicas=2
446446
# ${domainUID}-${managedServerNameBase}1, e.g. domain1-managed-server1
447447
# ${domainUID}-${managedServerNameBase}2, e.g. domain1-managed-server2
448-
managedServiceCount=$(kubectl get svc | grep -c "${domainUID}-${managedServerNameBase}")
448+
local managedServiceCount=$(kubectl get svc | grep -c "${domainUID}-${managedServerNameBase}")
449449
if [ ${managedServiceCount} -lt ${initialManagedServerReplicas} ]; then svcState="running"; fi
450450

451451
# If the job is completed, there should have no service in pending status.
452-
pendingCount=$(kubectl get svc | grep -c "pending")
452+
local pendingCount=$(kubectl get svc | grep -c "pending")
453453
if [ ${pendingCount} -ne 0 ]; then svcState="running"; fi
454454

455455
# If the job is completed, there should have the following pods running
456456
# ${domainUID}-${adminServerName}, e.g. domain1-admin-server
457457
# ${domainUID}-${managedServerNameBase}1, e.g. domain1-managed-server1
458458
# to
459459
# ${domainUID}-${managedServerNameBase}n, e.g. domain1-managed-servern, n = initialManagedServerReplicas
460-
runningPodCount=$(kubectl get pods | grep "${domainUID}" | grep -c "Running")
460+
local runningPodCount=$(kubectl get pods | grep "${domainUID}" | grep -c "Running")
461461
if [[ $runningPodCount -le ${initialManagedServerReplicas} ]]; then svcState="running"; fi
462462

463463
echo ==============================Current Status==========================================

0 commit comments

Comments
 (0)