diff --git a/electron/app/js/kubectlUtils.js b/electron/app/js/kubectlUtils.js index c0464a7b9..f7a41410b 100644 --- a/electron/app/js/kubectlUtils.js +++ b/electron/app/js/kubectlUtils.js @@ -843,8 +843,8 @@ async function verifyVerrazzanoPlatformOperatorRollout(kubectlExe, options) { }); } -async function getVerrazzanoInstallationObject(kubectlExe, kubectlOptions, vzInstallName) { - const getArgs = [ 'get', 'Verrazzano', vzInstallName, '--output=json' ]; +async function getVerrazzanoInstallationObject(kubectlExe, kubectlOptions) { + const getArgs = [ 'get', 'Verrazzano', '--output=json' ]; const httpsProxyUrl = getHttpsProxyUrl(); const bypassProxyHosts = getBypassProxyHosts(); @@ -856,8 +856,12 @@ async function getVerrazzanoInstallationObject(kubectlExe, kubectlOptions, vzIns return new Promise(resolve => { executeFileCommand(kubectlExe, getArgs, env).then(vzJson => { - result.isSuccess = true; - result.payload = JSON.parse(vzJson); + const vzObjectList = JSON.parse(vzJson).items; + if (vzObjectList.length > 0) { + const vzObject = vzObjectList[0]; + result.isSuccess = true; + result.payload = vzObject; + } resolve(result); }).catch(err => { result.reason = getErrorMessage(err); diff --git a/electron/app/js/vzInstaller.js b/electron/app/js/vzInstaller.js index 52de097c1..c8f25f70a 100644 --- a/electron/app/js/vzInstaller.js +++ b/electron/app/js/vzInstaller.js @@ -79,19 +79,41 @@ async function verifyVerrazzanoInstallStatus(kubectlExe, k8sOptions, vzOptions) }; return new Promise(resolve => { - kubectlUtils.getVerrazzanoInstallationObject(kubectlExe, k8sOptions, vzOptions.name).then(result => { + kubectlUtils.getVerrazzanoInstallationObject(kubectlExe, k8sOptions).then(result => { if (!result.isSuccess) { status.isSuccess = false; - status.reason = i18n.t('vz-installer-check-install-status-failed-error-message', { name: vzOptions.name, error: result.reason }); + + // Two possible cases: + // 1. Verrazzano CRD is not installed + // 2. Some lower-level error in finding the Verrazzano object + // + if (_isVerrazzanoDefinitionNotFound(result.reason)) { + status.reason = i18n.t('vz-installer-check-install-status-no-resource-error-message'); + } else { + status.reason = i18n.t('vz-installer-check-install-status-failed-error-message', { name: vzOptions.name, error: result.reason }); + } } else { + // Two possible scenarios: + // 1. Verrazzano installed but under a different name (this is a failure condition). + // 2. Verrazzano installed with the same name. + // + const vzObject = result.payload; _getStatusFromConditions(result.payload, status); + if (vzOptions.name !== vzObject.metadata?.name) { + status.isSuccess = false; + status.reason = i18n.t('vz-installer-check-install-status-mismatched-names-error-message', + { name: vzObject.metadata?.name, version: status.version }); + } } - resolve(status); }); }); } +function _isVerrazzanoDefinitionNotFound(vzErrorMessage) { + return vzErrorMessage.includes('server doesn\'t have a resource type "verrazzano"'); +} + function _getStatusFromConditions(vzObject, status) { const version = vzObject.status?.version; const conditions = vzObject.status?.conditions || []; diff --git a/electron/app/locales/en/electron.json b/electron/app/locales/en/electron.json index a95a9e66b..7aeb77f7c 100644 --- a/electron/app/locales/en/electron.json +++ b/electron/app/locales/en/electron.json @@ -403,7 +403,9 @@ "project-save-model-files-error-message": "Failed to save one of the WebLogic Deploy Tooling model files associated with the project: {{error}}", "vz-installer-operator-not-ready-error-message": "Cannot proceed with Verrazzano installation because the Verrazzano Platform Operator is not ready: {{error}}", + "vz-installer-check-install-status-no-resource-error-message": "No Verrazzano installation exists", "vz-installer-check-install-status-failed-error-message": "Cannot proceed with Verrazzano install status check for {{name}} because of an error: {{error}}", + "vz-installer-check-install-status-mismatched-names-error-message": "Verrazzano {{version}} is installed under the name {{name}}", "wrc-home-error-title": "Invalid WebLogic Remote Console Location", "wrc-init-error-title": "Initializing WebLogic Remote Console Backend Failed",