Skip to content

updating to WDT 2.1.0 targets and enhancing PV behavior #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2022
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
32 changes: 13 additions & 19 deletions electron/app/js/wdtPrepareModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ const _vzTargetTypeName = i18n.t('prepare-model-wko-target-type-name');

async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepareConfig) {
const logger = getLogger();
const { javaHome, oracleHome, projectDirectory, modelsSubdirectory, modelFiles, variableFiles, wdtTargetType } = prepareConfig;
const { javaHome, oracleHome, projectDirectory, modelsSubdirectory, modelFiles,
variableFiles, wdtTargetType, targetDomainLocation } = prepareConfig;
const outputDirectory = await fsUtils.createTemporaryDirectory(projectDirectory, 'prepareModel');
const absoluteModelFiles = fsUtils.getAbsolutePathsList(modelFiles, projectDirectory);

const argList = [
'-oracle_home', oracleHome,
'-model_file', absoluteModelFiles.join(','),
'-output_dir', outputDirectory,
'-target', wdtTargetType
'-target', getToolTargetType(wdtTargetType, targetDomainLocation)
];

const absoluteVariableFiles = fsUtils.getAbsolutePathsList(variableFiles, projectDirectory);
Expand All @@ -50,7 +51,7 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
//
const env = {
JAVA_HOME: javaHome,
WDT_CUSTOM_CONFIG: getWdtCustomConfigDirectory(prepareConfig)
WDT_CUSTOM_CONFIG: getWdtCustomConfigDirectory()
};
getLogger().debug(`Invoking ${getPrepareModelShellScript()} with args ${JSON.stringify(argList)} and environment ${JSON.stringify(env)}`);

Expand All @@ -75,7 +76,7 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
}
} catch (err) {
results.isSuccess = false;
results.reason = i18n.t('prepare-model-execution-failed-error-message', { error: getErrorMessage(err) });
results.reason = i18n.t('prepare-model-execution-failed-error-message', { error: errorUtils.getErrorMessage(err) });
results.error = err;
logger.error(results.reason);
removeTempDirectory(outputDirectory).then().catch();
Expand Down Expand Up @@ -114,7 +115,7 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
await getModelFileContent(currentWindow, updatedModelFiles, updatedVariableFiles, []);
} catch (err) {
results.isSuccess = false;
results.reason = i18n.t('prepare-model-move-files-failed-error-message', { error: getErrorMessage(err) });
results.reason = i18n.t('prepare-model-move-files-failed-error-message', { error: errorUtils.getErrorMessage(err) });
results.error = err;
logger.error(results.reason);
removeTempDirectory(outputDirectory).then().catch();
Expand All @@ -128,7 +129,7 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
results['secrets'] = await getJsonSecretsContent(outputDirectory);
} catch (err) {
results.isSuccess = false;
results.reason = getErrorMessage(err);
results.reason = errorUtils.getErrorMessage(err);
results.error = err;
logger.error(results.reason);
removeTempDirectory(outputDirectory).then().catch();
Expand All @@ -139,7 +140,7 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
results['domain'] = await getTargetSpecContent(wdtTargetType, outputDirectory);
} catch (err) {
results.isSuccess = false;
results.reason = getErrorMessage(err);
results.reason = errorUtils.getErrorMessage(err);
results.error = err;
logger.error(results.reason);
removeTempDirectory(outputDirectory).then().catch();
Expand Down Expand Up @@ -167,18 +168,6 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
return Promise.resolve(results);
}

function getErrorMessage(err) {
let errorMessage;
if (!err) {
errorMessage = 'Unknown Error';
} else if (!err.message) {
errorMessage = err.toString();
} else {
errorMessage = err.message;
}
return errorMessage;
}

async function removeTempDirectory(outputDirectory) {
return new Promise(resolve => {
if (_deleteTempDirectory) {
Expand Down Expand Up @@ -438,6 +427,11 @@ async function getVzSpecContent(outputDirectory) {
});
}

function getToolTargetType(wdtTargetType, targetDomainLocation) {
const suffix = targetDomainLocation === 'mii' ? '' : `-${targetDomainLocation}`;
return `${wdtTargetType}${suffix}`;
}

function getFileExistsErrorMessage(targetType, fileName, err) {
const error = new Error(i18n.t('prepare-model-spec-file-exists-error-message',
{ targetType: targetType, fileName: fileName, error: errorUtils.getErrorMessage(err) }));
Expand Down
2 changes: 1 addition & 1 deletion electron/app/js/wdtValidateModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function validateModel(currentWindow, stdoutChannel, stderrChannel, valida

const env = {
JAVA_HOME: javaHome,
WDT_CUSTOM_CONFIG: getWdtCustomConfigDirectory(validateConfig)
WDT_CUSTOM_CONFIG: getWdtCustomConfigDirectory()
};
getLogger().debug(`Invoking ${getValidateModelShellScript()} with args ${JSON.stringify(argList)} and environment ${JSON.stringify(env)}`);

Expand Down
5 changes: 2 additions & 3 deletions electron/app/js/wktTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ function getValidateModelShellScript() {
return path.join(getWdtDirectory(), 'bin', 'validateModel' + scriptExtension);
}

function getWdtCustomConfigDirectory(config) {
const targetDomainLocation = config.targetDomainLocation || 'mii';
return path.join(getToolsDirectory(), 'wdt-config', targetDomainLocation);
function getWdtCustomConfigDirectory() {
return path.join(getToolsDirectory(), 'wdt-config');
}

function isWdtErrorExitCode(exitCode) {
Expand Down
7 changes: 5 additions & 2 deletions electron/app/locales/en/webui.json
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@
"domain-design-aux-image-registry-pull-email-help": "The image registry user's email address used to create the Kubernetes image pull secret for the auxiliary image.",

"domain-design-clusters-title": "Clusters",
"domain-design-clusters-table-aria-label": "Clusters configuration table",
"domain-design-no-clusters-message": "No clusters found for this domain. If your project has a model that defines clusters, please run Prepare Model to populate the clusters tables.",
"domain-design-clusters-name-heading": "Cluster Name",
"domain-design-clusters-replicas-heading": "Replicas",
Expand All @@ -554,6 +555,8 @@
"domain-design-clusters-memory-request-heading": "Kubernetes Memory Request",
"domain-design-edit-cluster-label": "Edit Cluster Settings",
"domain-design-cluster-dialog-title": "Edit Cluster Settings",
"domain-design-add-cluster-label": "Add Cluster",
"domain-design-delete-cluster-label": "Delete Cluster",

"domain-design-get-domain-status": "Get Domain Status",
"domain-design-domain-status-label": "Domain Status: ",
Expand All @@ -574,6 +577,8 @@

"domain-design-cluster-name-label": "Cluster Name",
"domain-design-cluster-name-help": "The cluster name in the domain for which to enter settings.",
"domain-design-cluster-name-is-empty-error": "Cluster Name cannot be empty",
"domain-design-cluster-name-not-unique-error": "{{name}} is already present in cluster list [{{existingNames}}]",
"domain-design-cluster-replicas-label": "Replicas",
"domain-design-cluster-replicas-help": "The number of managed servers to start for the cluster.",
"domain-design-cluster-min-heap-label": "Minimum Heap Size",
Expand Down Expand Up @@ -867,7 +872,6 @@
"wdt-discoverer-online-discovery-failed-error-prefix": "Unable to discover domain {{adminUrl}} in online mode",

"wdt-validator-aborted-error-title": "Validate Model Aborted",
"wdt-validator-domain-in-pv-message": "Validate Model has no meaning when the target domain location is an externally created Kubernetes persistent volume.",
"wdt-validator-invalid-java-home-error-prefix": "Unable to validate model due to the Java Home being invalid",
"wdt-validator-invalid-oracle-home-error-prefix": "Unable to validate model due to the Oracle Home being invalid",
"wdt-validator-project-not-saved-error-prefix": "Unable to validate model because project save failed",
Expand All @@ -883,7 +887,6 @@
"wdt-validator-validate-complete-message": "Validate Model successfully validated the model.",

"wdt-preparer-aborted-error-title": "Prepare Model Aborted",
"wdt-preparer-domain-in-pv-message": "Prepare Model has no meaning when the target domain location is an externally created Kubernetes persistent volume.",
"wdt-preparer-invalid-java-home-error-prefix": "Unable to prepare model due to the Java Home being invalid",
"wdt-preparer-invalid-oracle-home-error-prefix": "Unable to prepare model due to the Oracle Home being invalid",
"wdt-preparer-project-not-saved-error-prefix": "Unable to prepare model because project save failed",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"model_filters" : {
"discover": [
{ "name": "vz_prep", "path": "@@TARGET_CONFIG_DIR@@/vz_filter.py" },
{ "id": "wko_filter" }
]
},
Expand All @@ -10,6 +9,5 @@
"credentials_output_method" : "script",
"exclude_domain_bin_contents": true,
"wls_credentials_name" : "__weblogic-credentials__",
"additional_secrets": "runtime-encryption-secret",
"additional_output" : "vz-application.yaml"
}
14 changes: 14 additions & 0 deletions tools/wdt-config/targets/vz-pv/target.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"model_filters" : {
"discover": [
{ "id": "wko_filter" }
]
},
"variable_injectors" : {"PORT": {},"HOST": {},"URL": {}},
"validation_method" : "lax",
"credentials_output_method" : "script",
"exclude_domain_bin_contents": true,
"wls_credentials_name" : "__weblogic-credentials__",
"additional_output" : "vz-application.yaml",
"use_persistent_volume" : true
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"model_filters" : {
"discover": [
{ "name": "vz_prep", "path": "@@TARGET_CONFIG_DIR@@/vz_filter.py" },
{ "id": "wko_filter" }
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"model_filters" : {
"discover": [
{ "name": "wko_prep", "path": "@@TARGET_CONFIG_DIR@@/wko_operator_filter.py" },
{ "id": "wko_filter" }
]
},
Expand All @@ -10,6 +9,5 @@
"credentials_output_method" : "json",
"exclude_domain_bin_contents": true,
"wls_credentials_name" : "__weblogic-credentials__",
"additional_secrets": "runtime-encryption-secret",
"additional_output" : "wko-domain.yaml"
}
14 changes: 14 additions & 0 deletions tools/wdt-config/targets/wko-pv/target.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"model_filters" : {
"discover": [
{ "id": "wko_filter" }
]
},
"variable_injectors" : {"PORT": {},"HOST": {},"URL": {}},
"validation_method" : "wktui",
"credentials_output_method" : "json",
"exclude_domain_bin_contents": true,
"wls_credentials_name" : "__weblogic-credentials__",
"additional_output" : "wko-domain.yaml",
"use_persistent_volume" : true
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"model_filters" : {
"discover": [
{ "name": "wko_prep", "path": "@@TARGET_CONFIG_DIR@@/wko_operator_filter.py" },
{ "id": "wko_filter" }
]
},
Expand Down
13 changes: 8 additions & 5 deletions webui/src/js/models/k8s-domain-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ define(['knockout', 'utils/observable-properties', 'utils/common-utilities', 'ut
this.auxImagePullPolicy = props.createProperty('IfNotPresent');

this.clusterKeys = [
'name', 'maxServers', 'replicas', 'minHeap', 'maxHeap', 'cpuRequest', 'cpuLimit', 'memoryRequest',
'uid', 'name', 'maxServers', 'replicas', 'minHeap', 'maxHeap', 'cpuRequest', 'cpuLimit', 'memoryRequest',
'memoryLimit', 'disableDebugStdout', 'disableFan', 'useUrandom', 'additionalArguments'
];
this.clusters = props.createListProperty(this.clusterKeys).persistByKey('name');
this.clusters = props.createListProperty(this.clusterKeys).persistByKey('uid');

this.modelConfigMapName = props.createProperty('${1}-config-map', this.uid.observable);
this.modelConfigMapName.addValidator(...validationHelper.getK8sNameValidators());
Expand Down Expand Up @@ -204,19 +204,22 @@ define(['knockout', 'utils/observable-properties', 'utils/common-utilities', 'ut
};

this.setClusterRow = (prepareModelCluster) => {
let found;
let cluster;
for (const row of this.clusters.observable()) {
if (row.name === prepareModelCluster.clusterName) {
row.maxServers = prepareModelCluster.replicas;
if (row.replicas === undefined || row.replicas > row.maxServers) {
row.replicas = row.maxServers;
}
found = true;
cluster = row;
break;
}
}
if (!found) {
if (cluster) {
this.clusters.observable.replace(cluster, cluster);
} else {
this.clusters.addNewItem({
uid: utils.getShortUuid(),
name: prepareModelCluster.clusterName,
maxServers: prepareModelCluster.replicas,
replicas: prepareModelCluster.replicas
Expand Down
24 changes: 24 additions & 0 deletions webui/src/js/models/wkt-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,30 @@ function (ko, wdtConstructor, imageConstructor, kubectlConstructor, domainConstr
}
delete wktProjectJson.kubectl.extraPathDirectories;
}

// Version 1.1.1 changes domain clusters to be persisted by UID instead of name
// to allow us to support adding new clusters on the domain page for the
// Domain in PV use case...
//
if ('k8sDomain' in wktProjectJson && 'clusters' in wktProjectJson.k8sDomain) {
const currentClusters = wktProjectJson.k8sDomain.clusters;
const newClusters = {};
for (const clusterName in currentClusters) {
const cluster = currentClusters[clusterName];
// This is tricky because the only way to tell if the cluster is in
// the old format is if there is no name field...
//
if (cluster.name) {
break;
}
cluster.name = clusterName;
const uid = utils.getShortUuid();
newClusters[uid] = cluster;
}
if (Object.keys(newClusters).length > 0) {
wktProjectJson.k8sDomain.clusters = newClusters;
}
}
};

this.setFromJson = (wktProjectJson, modelContentsJson) => {
Expand Down
6 changes: 0 additions & 6 deletions webui/src/js/utils/wdt-preparer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ function(WdtActionsBase, project, wktConsole, i18n, projectIo, dialogHelper, val
const errPrefix = 'wdt-preparer';
const shouldCloseBusyDialog = !options.skipBusyDialog;

if (this.project.settings.targetDomainLocation.value === 'pv') {
const errMessage = i18n.t('wdt-preparer-domain-in-pv-message');
await window.api.ipc.invoke('show-info-message', errTitle, errMessage);
return Promise.resolve(false);
}

const validationObject = this.getValidationObject('flow-prepare-model-name');
if (validationObject.hasValidationErrors()) {
const validationErrorDialogConfig = validationObject.getValidationErrorDialogConfig(errTitle);
Expand Down
6 changes: 0 additions & 6 deletions webui/src/js/utils/wdt-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ function(WdtActionsBase, project, wktConsole, i18n, projectIo, dialogHelper, val
const errPrefix = 'wdt-validator';
const shouldCloseBusyDialog = !options.skipBusyDialog;

if (this.project.settings.targetDomainLocation.value === 'pv') {
const errMessage = i18n.t('wdt-validator-domain-in-pv-message');
await window.api.ipc.invoke('show-info-message', errTitle, errMessage);
return Promise.resolve(false);
}

const validationObject = this.getValidationObject('flow-validate-model-name');
if (validationObject.hasValidationErrors()) {
const validationErrorDialogConfig = validationObject.getValidationErrorDialogConfig(errTitle);
Expand Down
16 changes: 15 additions & 1 deletion webui/src/js/viewModels/cluster-edit-dialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright (c) 2021, Oracle and/or its affiliates.
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
* Licensed under The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
*/
'use strict';
Expand Down Expand Up @@ -36,15 +36,29 @@ function(accUtils, ko, i18n, project, ArrayDataProvider,

this.project = project;
this.cluster = args.cluster;
this.existingClusterNames = args.existingNames;
this.isDomainInPV = args.isDomainInPV;
this.i18n = i18n;

this.nameIsUnique = {
validate: (value) => {
const existingNames = this.existingClusterNames;
if (!value) {
throw new Error(this.labelMapper('name-is-empty-error'));
} else if (Array.isArray(existingNames) && existingNames.length > 0 && existingNames.includes(value)) {
throw new Error(this.labelMapper('name-not-unique-error',
{ name: value, existingNames: existingNames.join(',')}));
}
},
};
this.integerConverter = new ojConverterNumber.IntlNumberConverter({
style: 'decimal',
roundingMode: 'HALF_DOWN',
maximumFractionDigits: 0,
useGrouping: false
});


// create an observable property for each simple field
this['maxServers'] = this.cluster.maxServers;
SIMPLE_PROPERTIES.forEach(propertyName => {
Expand Down
Loading