From a3404a6c3efe61efb54fa7e152cb6b69d2e6b6ae Mon Sep 17 00:00:00 2001 From: galiacheng Date: Mon, 25 Oct 2021 11:10:50 +0800 Subject: [PATCH 1/6] On branch main: check application status after all configurations are set. Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/src/main/arm/scripts/setupWLSDomain.sh modified: weblogic-azure-aks/src/main/arm/scripts/utility.sh new file: weblogic-azure-aks/src/main/arm/scripts/validateApplications.sh modified: weblogic-azure-aks/src/main/bicep/mainTemplate.bicep modified: weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-create-wls-cluster.bicep new file: weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-validate-applications.bicep --- .../src/main/arm/scripts/setupWLSDomain.sh | 11 ---- .../src/main/arm/scripts/utility.sh | 2 +- .../main/arm/scripts/validateApplications.sh | 37 +++++++++++ .../src/main/bicep/mainTemplate.bicep | 17 +++++ .../_ds-create-wls-cluster.bicep | 2 - .../_ds-validate-applications.bicep | 63 +++++++++++++++++++ 6 files changed, 118 insertions(+), 14 deletions(-) create mode 100644 weblogic-azure-aks/src/main/arm/scripts/validateApplications.sh create mode 100644 weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-validate-applications.bicep diff --git a/weblogic-azure-aks/src/main/arm/scripts/setupWLSDomain.sh b/weblogic-azure-aks/src/main/arm/scripts/setupWLSDomain.sh index f585f5e7b..f8b2ede38 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/setupWLSDomain.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/setupWLSDomain.sh @@ -735,16 +735,6 @@ 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 @@ -800,7 +790,6 @@ 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" diff --git a/weblogic-azure-aks/src/main/arm/scripts/utility.sh b/weblogic-azure-aks/src/main/arm/scripts/utility.sh index fc4040a5e..61cd64f3d 100644 --- a/weblogic-azure-aks/src/main/arm/scripts/utility.sh +++ b/weblogic-azure-aks/src/main/arm/scripts/utility.sh @@ -172,7 +172,7 @@ function utility_validate_application_status() { grep "Summary: all applications are active" if [ $? == 1 ];then - echo "Failed to deploy application to WLS cluster. Please make sure the configurations are correct." + echo_stderr "Failed to deploy application to WLS cluster. Please make sure the configurations are correct." exit 1 fi } diff --git a/weblogic-azure-aks/src/main/arm/scripts/validateApplications.sh b/weblogic-azure-aks/src/main/arm/scripts/validateApplications.sh new file mode 100644 index 000000000..b24db54af --- /dev/null +++ b/weblogic-azure-aks/src/main/arm/scripts/validateApplications.sh @@ -0,0 +1,37 @@ +# 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. +# This script runs on Azure Container Instance with Alpine Linux that Azure Deployment script creates. + +# Connect to AKS cluster +function connect_aks_cluster() { + az aks get-credentials \ + --resource-group ${AKS_RESOURCE_GROUP_NAME} \ + --name ${AKS_NAME} \ + --overwrite-existing +} + +function validate_app() { + # make sure all the application are active, if not, fail the deployment. + local wlsDomainNS="${WLS_DOMAIN_UID}-ns" + local wlsAdminSvcName="${WLS_DOMAIN_UID}-admin-server" + scriptCheckAppStatus=$scriptDir/checkApplicationStatus.py + chmod ugo+x $scriptDir/checkApplicationStatus.py + utility_validate_application_status \ + ${wlsDomainNS} \ + ${wlsAdminSvcName} \ + ${WLS_DOMAIN_USER} \ + ${WLS_DOMAIN_PASSWORD} \ + ${scriptCheckAppStatus} +} + +# Main script +export script="${BASH_SOURCE[0]}" +export scriptDir="$(cd "$(dirname "${script}")" && pwd)" + +source ${scriptDir}/utility.sh + +install_kubectl + +connect_aks_cluster + +validate_app \ No newline at end of file diff --git a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep index 0545a0ed3..1a1560d88 100644 --- a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep +++ b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep @@ -622,6 +622,23 @@ module datasourceDeployment 'modules/_setupDBConnection.bicep' = if (enableDB) { ] } +module validateApplciations 'modules/_deployment-scripts/_ds-validate-applications.bicep' = { + name: 'validate-wls-application-status' + params:{ + _artifactsLocation: _artifactsLocation + _artifactsLocationSasToken: _artifactsLocationSasToken + aksClusterRGName: ref_wlsDomainDeployment.outputs.aksClusterRGName.value + aksClusterName: ref_wlsDomainDeployment.outputs.aksClusterName.value + identity: identity + wlsDomainUID: wlsDomainUID + wlsPassword: wlsPassword + wlsUserName: wlsUserName + } + dependsOn: [ + datasourceDeployment + ] +} + output aksClusterName string = ref_wlsDomainDeployment.outputs.aksClusterName.value output adminConsoleInternalUrl string = ref_wlsDomainDeployment.outputs.adminServerUrl.value output adminConsoleExternalUrl string = const_enableNetworking ? networkingDeployment.outputs.adminConsoleExternalUrl : '' diff --git a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-create-wls-cluster.bicep b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-create-wls-cluster.bicep index 33468b2b3..e7fafd739 100644 --- a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-create-wls-cluster.bicep +++ b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-create-wls-cluster.bicep @@ -62,7 +62,6 @@ 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/') @@ -89,7 +88,6 @@ 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' diff --git a/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-validate-applications.bicep b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-validate-applications.bicep new file mode 100644 index 000000000..44600e7a3 --- /dev/null +++ b/weblogic-azure-aks/src/main/bicep/modules/_deployment-scripts/_ds-validate-applications.bicep @@ -0,0 +1,63 @@ +// 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. + +param _artifactsLocation string +@secure() +param _artifactsLocationSasToken string = '' + +param aksClusterRGName string = '' +param aksClusterName string = '' +param identity object +param utcValue string = utcNow() +param wlsDomainUID string = 'sample-domain1' +@secure() +param wlsPassword string +@description('User name for WebLogic Administrator.') +param wlsUserName string = 'weblogic' + +var const_azcliVersion='2.15.0' +var const_pyCheckAppStatusScript = 'py-scripts/checkApplicationStatus.py' +var const_scriptLocation = uri(_artifactsLocation, 'scripts/') +var const_validateAppScript= 'validateApplications.sh' +var const_utilityScript= 'utility.sh' + + +resource deploymentScript 'Microsoft.Resources/deploymentScripts@2020-10-01' = { + name: 'ds-wls-validate-applications' + location: resourceGroup().location + kind: 'AzureCLI' + identity: identity + properties: { + azCliVersion: const_azcliVersion + environmentVariables: [ + { + name: 'AKS_RESOURCE_GROUP_NAME' + value: aksClusterRGName + } + { + name: 'AKS_NAME' + value: aksClusterName + } + { + name: 'WLS_DOMAIN_UID' + value: wlsDomainUID + } + { + name: 'WLS_DOMAIN_USER' + value: wlsUserName + } + { + name: 'WLS_DOMAIN_PASSWORD' + secureValue: wlsPassword + } + ] + primaryScriptUri: uri(const_scriptLocation, '${const_validateAppScript}${_artifactsLocationSasToken}') + supportingScriptUris: [ + uri(const_scriptLocation, '${const_utilityScript}${_artifactsLocationSasToken}') + uri(const_scriptLocation, '${const_pyCheckAppStatusScript}${_artifactsLocationSasToken}') + ] + cleanupPreference: 'OnSuccess' + retentionInterval: 'P1D' + forceUpdateTag: utcValue + } +} From 4c5968acd69cd4f0d111bea15e1e51e240a44b3a Mon Sep 17 00:00:00 2001 From: galiacheng Date: Wed, 27 Oct 2021 15:00:32 +0800 Subject: [PATCH 2/6] On branch main: set "check application ACTIVE state" as a configurable option. Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/src/main/arm/createUiDefinition.json modified: weblogic-azure-aks/src/main/bicep/mainTemplate.bicep --- weblogic-azure-aks/src/main/arm/createUiDefinition.json | 7 +++++++ weblogic-azure-aks/src/main/bicep/mainTemplate.bicep | 9 +++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/weblogic-azure-aks/src/main/arm/createUiDefinition.json b/weblogic-azure-aks/src/main/arm/createUiDefinition.json index f5ded01f9..fad419c39 100644 --- a/weblogic-azure-aks/src/main/arm/createUiDefinition.json +++ b/weblogic-azure-aks/src/main/arm/createUiDefinition.json @@ -612,6 +612,12 @@ }, "visible": "[bool(steps('section_aks').jeeAppInfo.uploadAppPackage)]" }, + { + "name": "validateApplications", + "type": "Microsoft.Common.CheckBox", + "label": "Fail deployment if application does not become ACTIVE.", + "visible": "[bool(steps('section_aks').jeeAppInfo.uploadAppPackage)]" + }, { "name": "appReplicas", "type": "Microsoft.Common.TextBox", @@ -1813,6 +1819,7 @@ "useOracleImage": "[bool(steps('section_aks').imageInfo.useOracleImage)]", "userProvidedAcr": "[last(split(steps('section_aks').imageInfo.userProvidedAcrSelector.id, '/'))]", "userProvidedImagePath": "[steps('section_aks').imageInfo.userProvidedImagePath]", + "validateApplications": "[bool(steps('section_aks').jeeAppInfo.validateApplications)]", "wdtRuntimePassword": "[basics('basicsRequired').wdtRuntimePassword]", "wlsClusterSize": "[basics('basicsOptional').wlsClusterSize]", "wlsDomainName": "[basics('basicsOptional').wlsDomainName]", diff --git a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep index 1a1560d88..e676f92e8 100644 --- a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep +++ b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep @@ -224,6 +224,7 @@ param userProvidedAcr string = 'null' param userProvidedImagePath string = 'null' @description('Use Oracle images or user provided patched images') param useOracleImage bool = true +param validateApplications bool = false @secure() @description('Password for model WebLogic Deploy Tooling runtime encrytion.') param wdtRuntimePassword string @@ -622,9 +623,13 @@ module datasourceDeployment 'modules/_setupDBConnection.bicep' = if (enableDB) { ] } -module validateApplciations 'modules/_deployment-scripts/_ds-validate-applications.bicep' = { +/* +* To check if all the applciations in WLS cluster become ACTIVE state after all configurations are completed. +* This should be the last step. +*/ +module validateApplciations 'modules/_deployment-scripts/_ds-validate-applications.bicep' = if (validateApplications) { name: 'validate-wls-application-status' - params:{ + params: { _artifactsLocation: _artifactsLocation _artifactsLocationSasToken: _artifactsLocationSasToken aksClusterRGName: ref_wlsDomainDeployment.outputs.aksClusterRGName.value From 8115ec473304edfd19cabe40d92fe1fd61a7ff60 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Wed, 27 Oct 2021 15:21:26 +0800 Subject: [PATCH 3/6] On branch main: add comments for Pbicep-dev Signed-off-by: galiacheng Changes to be committed: modified: weblogic-azure-aks/pom.xml modified: weblogic-azure-aks/src/main/bicep/mainTemplate.bicep --- weblogic-azure-aks/pom.xml | 6 ++++++ weblogic-azure-aks/src/main/bicep/mainTemplate.bicep | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/weblogic-azure-aks/pom.xml b/weblogic-azure-aks/pom.xml index a1fd1123f..3b1ea52f6 100644 --- a/weblogic-azure-aks/pom.xml +++ b/weblogic-azure-aks/pom.xml @@ -8,6 +8,12 @@ 4.0.0 + com.oracle.weblogic.azure wls-on-aks-azure-marketplace diff --git a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep index e676f92e8..c09539997 100644 --- a/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep +++ b/weblogic-azure-aks/src/main/bicep/mainTemplate.bicep @@ -13,7 +13,10 @@ * * Build marketplace offer for test: * Replace the partner center pid in mainTemplate.bicep, then run the following command to generate the ARM package, and upload it to partner center. -* $ mvn -Pbicep -Ddev -Passembly clean install +* If using azure-javaee-iaas-parent less than 1.0.13, use: +* $ mvn -Pbicep -Passembly -Ddev clean install +* otherwise, use +* $ mvn -Pbicep-dev -Passembly clean install */ param _artifactsLocation string = deployment().properties.templateLink.uri From 1b26d2281bfd79bfa9bea08a65a954a8446c8b48 Mon Sep 17 00:00:00 2001 From: galiacheng Date: Wed, 27 Oct 2021 15:27:57 +0800 Subject: [PATCH 4/6] On branch main: test main branch Signed-off-by: galiacheng --- .github/workflows/testWlsAks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testWlsAks.yml b/.github/workflows/testWlsAks.yml index b53e42af3..714abd314 100644 --- a/.github/workflows/testWlsAks.yml +++ b/.github/workflows/testWlsAks.yml @@ -26,7 +26,7 @@ env: wlsUserName: ${{ secrets.WLS_USERNAME }} wlsPassword: ${{ secrets.WLS_PSW }} userAssignedManagedIdentity: ${{ secrets.USER_ASSIGNED_MANAGED_IDENTITY_ID }} - aksRepoUserName: oracle + aksRepoUserName: galiacheng aksRepoBranchName: main resourceGroupForDB: wlsd-db-${{ github.run_id }}-${{ github.run_number }} resourceGroupForStorageAccount: wlsd-sa-${{ github.run_id }}-${{ github.run_number }} From 1dbc6edd2942056c5a5c06e60a351984ac615f6a Mon Sep 17 00:00:00 2001 From: galiacheng Date: Wed, 27 Oct 2021 15:30:46 +0800 Subject: [PATCH 5/6] On branch main: test main branch Signed-off-by: galiacheng --- .github/workflows/testWlsAks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testWlsAks.yml b/.github/workflows/testWlsAks.yml index 714abd314..b53e42af3 100644 --- a/.github/workflows/testWlsAks.yml +++ b/.github/workflows/testWlsAks.yml @@ -26,7 +26,7 @@ env: wlsUserName: ${{ secrets.WLS_USERNAME }} wlsPassword: ${{ secrets.WLS_PSW }} userAssignedManagedIdentity: ${{ secrets.USER_ASSIGNED_MANAGED_IDENTITY_ID }} - aksRepoUserName: galiacheng + aksRepoUserName: oracle aksRepoBranchName: main resourceGroupForDB: wlsd-db-${{ github.run_id }}-${{ github.run_number }} resourceGroupForStorageAccount: wlsd-sa-${{ github.run_id }}-${{ github.run_number }} From 4b7239b54ab492d857b33c3a59c1ed9e87d64ea5 Mon Sep 17 00:00:00 2001 From: Ed Burns Date: Wed, 27 Oct 2021 12:39:36 -0400 Subject: [PATCH 6/6] On branch galiacheng-main Add infobox with more explanation of checkbox and link to documentation modified: weblogic-azure-aks/src/main/arm/createUiDefinition.json --- .../src/main/arm/createUiDefinition.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/weblogic-azure-aks/src/main/arm/createUiDefinition.json b/weblogic-azure-aks/src/main/arm/createUiDefinition.json index fad419c39..68ad34ae0 100644 --- a/weblogic-azure-aks/src/main/arm/createUiDefinition.json +++ b/weblogic-azure-aks/src/main/arm/createUiDefinition.json @@ -612,6 +612,16 @@ }, "visible": "[bool(steps('section_aks').jeeAppInfo.uploadAppPackage)]" }, + { + "name": "validateApplicationsInfo", + "type": "Microsoft.Common.InfoBox", + "visible": "[bool(steps('section_aks').jeeAppInfo.uploadAppPackage)]", + "options": { + "icon": "Info", + "text": "If checked, verify the deployed app reaches the ACTIVE state and fail the deployment if it does not. See the documentation link for more information.", + "uri": "https://aka.ms/wls-aks-deployment-state" + } + }, { "name": "validateApplications", "type": "Microsoft.Common.CheckBox", @@ -1830,4 +1840,4 @@ "wlsUserName": "[basics('basicsRequired').wlsUserName]" } } -} \ No newline at end of file +}