Skip to content

Commit ae64a17

Browse files
updating to WDT 2.1.0 targets and enhancing PV behavior (#104)
* updating to WDT 2.1.0 targets and enhancing PV behavior * updating copyrights
1 parent bb1b1f0 commit ae64a17

File tree

19 files changed

+173
-56
lines changed

19 files changed

+173
-56
lines changed

electron/app/js/wdtPrepareModel.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ const _vzTargetTypeName = i18n.t('prepare-model-wko-target-type-name');
3030

3131
async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepareConfig) {
3232
const logger = getLogger();
33-
const { javaHome, oracleHome, projectDirectory, modelsSubdirectory, modelFiles, variableFiles, wdtTargetType } = prepareConfig;
33+
const { javaHome, oracleHome, projectDirectory, modelsSubdirectory, modelFiles,
34+
variableFiles, wdtTargetType, targetDomainLocation } = prepareConfig;
3435
const outputDirectory = await fsUtils.createTemporaryDirectory(projectDirectory, 'prepareModel');
3536
const absoluteModelFiles = fsUtils.getAbsolutePathsList(modelFiles, projectDirectory);
3637

3738
const argList = [
3839
'-oracle_home', oracleHome,
3940
'-model_file', absoluteModelFiles.join(','),
4041
'-output_dir', outputDirectory,
41-
'-target', wdtTargetType
42+
'-target', getToolTargetType(wdtTargetType, targetDomainLocation)
4243
];
4344

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

@@ -75,7 +76,7 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
7576
}
7677
} catch (err) {
7778
results.isSuccess = false;
78-
results.reason = i18n.t('prepare-model-execution-failed-error-message', { error: getErrorMessage(err) });
79+
results.reason = i18n.t('prepare-model-execution-failed-error-message', { error: errorUtils.getErrorMessage(err) });
7980
results.error = err;
8081
logger.error(results.reason);
8182
removeTempDirectory(outputDirectory).then().catch();
@@ -114,7 +115,7 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
114115
await getModelFileContent(currentWindow, updatedModelFiles, updatedVariableFiles, []);
115116
} catch (err) {
116117
results.isSuccess = false;
117-
results.reason = i18n.t('prepare-model-move-files-failed-error-message', { error: getErrorMessage(err) });
118+
results.reason = i18n.t('prepare-model-move-files-failed-error-message', { error: errorUtils.getErrorMessage(err) });
118119
results.error = err;
119120
logger.error(results.reason);
120121
removeTempDirectory(outputDirectory).then().catch();
@@ -128,7 +129,7 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
128129
results['secrets'] = await getJsonSecretsContent(outputDirectory);
129130
} catch (err) {
130131
results.isSuccess = false;
131-
results.reason = getErrorMessage(err);
132+
results.reason = errorUtils.getErrorMessage(err);
132133
results.error = err;
133134
logger.error(results.reason);
134135
removeTempDirectory(outputDirectory).then().catch();
@@ -139,7 +140,7 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
139140
results['domain'] = await getTargetSpecContent(wdtTargetType, outputDirectory);
140141
} catch (err) {
141142
results.isSuccess = false;
142-
results.reason = getErrorMessage(err);
143+
results.reason = errorUtils.getErrorMessage(err);
143144
results.error = err;
144145
logger.error(results.reason);
145146
removeTempDirectory(outputDirectory).then().catch();
@@ -167,18 +168,6 @@ async function prepareModel(currentWindow, stdoutChannel, stderrChannel, prepare
167168
return Promise.resolve(results);
168169
}
169170

170-
function getErrorMessage(err) {
171-
let errorMessage;
172-
if (!err) {
173-
errorMessage = 'Unknown Error';
174-
} else if (!err.message) {
175-
errorMessage = err.toString();
176-
} else {
177-
errorMessage = err.message;
178-
}
179-
return errorMessage;
180-
}
181-
182171
async function removeTempDirectory(outputDirectory) {
183172
return new Promise(resolve => {
184173
if (_deleteTempDirectory) {
@@ -438,6 +427,11 @@ async function getVzSpecContent(outputDirectory) {
438427
});
439428
}
440429

430+
function getToolTargetType(wdtTargetType, targetDomainLocation) {
431+
const suffix = targetDomainLocation === 'mii' ? '' : `-${targetDomainLocation}`;
432+
return `${wdtTargetType}${suffix}`;
433+
}
434+
441435
function getFileExistsErrorMessage(targetType, fileName, err) {
442436
const error = new Error(i18n.t('prepare-model-spec-file-exists-error-message',
443437
{ targetType: targetType, fileName: fileName, error: errorUtils.getErrorMessage(err) }));

electron/app/js/wdtValidateModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function validateModel(currentWindow, stdoutChannel, stderrChannel, valida
4242

4343
const env = {
4444
JAVA_HOME: javaHome,
45-
WDT_CUSTOM_CONFIG: getWdtCustomConfigDirectory(validateConfig)
45+
WDT_CUSTOM_CONFIG: getWdtCustomConfigDirectory()
4646
};
4747
getLogger().debug(`Invoking ${getValidateModelShellScript()} with args ${JSON.stringify(argList)} and environment ${JSON.stringify(env)}`);
4848

electron/app/js/wktTools.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ function getValidateModelShellScript() {
4545
return path.join(getWdtDirectory(), 'bin', 'validateModel' + scriptExtension);
4646
}
4747

48-
function getWdtCustomConfigDirectory(config) {
49-
const targetDomainLocation = config.targetDomainLocation || 'mii';
50-
return path.join(getToolsDirectory(), 'wdt-config', targetDomainLocation);
48+
function getWdtCustomConfigDirectory() {
49+
return path.join(getToolsDirectory(), 'wdt-config');
5150
}
5251

5352
function isWdtErrorExitCode(exitCode) {

electron/app/locales/en/webui.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@
530530
"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.",
531531

532532
"domain-design-clusters-title": "Clusters",
533+
"domain-design-clusters-table-aria-label": "Clusters configuration table",
533534
"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.",
534535
"domain-design-clusters-name-heading": "Cluster Name",
535536
"domain-design-clusters-replicas-heading": "Replicas",
@@ -539,6 +540,8 @@
539540
"domain-design-clusters-memory-request-heading": "Kubernetes Memory Request",
540541
"domain-design-edit-cluster-label": "Edit Cluster Settings",
541542
"domain-design-cluster-dialog-title": "Edit Cluster Settings",
543+
"domain-design-add-cluster-label": "Add Cluster",
544+
"domain-design-delete-cluster-label": "Delete Cluster",
542545

543546
"domain-design-get-domain-status": "Get Domain Status",
544547
"domain-design-domain-status-label": "Domain Status: ",
@@ -559,6 +562,8 @@
559562

560563
"domain-design-cluster-name-label": "Cluster Name",
561564
"domain-design-cluster-name-help": "The cluster name in the domain for which to enter settings.",
565+
"domain-design-cluster-name-is-empty-error": "Cluster Name cannot be empty",
566+
"domain-design-cluster-name-not-unique-error": "{{name}} is already present in cluster list [{{existingNames}}]",
562567
"domain-design-cluster-replicas-label": "Replicas",
563568
"domain-design-cluster-replicas-help": "The number of managed servers to start for the cluster.",
564569
"domain-design-cluster-min-heap-label": "Minimum Heap Size",
@@ -852,7 +857,6 @@
852857
"wdt-discoverer-online-discovery-failed-error-prefix": "Unable to discover domain {{adminUrl}} in online mode",
853858

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

870874
"wdt-preparer-aborted-error-title": "Prepare Model Aborted",
871-
"wdt-preparer-domain-in-pv-message": "Prepare Model has no meaning when the target domain location is an externally created Kubernetes persistent volume.",
872875
"wdt-preparer-invalid-java-home-error-prefix": "Unable to prepare model due to the Java Home being invalid",
873876
"wdt-preparer-invalid-oracle-home-error-prefix": "Unable to prepare model due to the Oracle Home being invalid",
874877
"wdt-preparer-project-not-saved-error-prefix": "Unable to prepare model because project save failed",
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"model_filters" : {
33
"discover": [
4-
{ "name": "vz_prep", "path": "@@TARGET_CONFIG_DIR@@/vz_filter.py" },
54
{ "id": "wko_filter" }
65
]
76
},
@@ -10,6 +9,5 @@
109
"credentials_output_method" : "script",
1110
"exclude_domain_bin_contents": true,
1211
"wls_credentials_name" : "__weblogic-credentials__",
13-
"additional_secrets": "runtime-encryption-secret",
1412
"additional_output" : "vz-application.yaml"
1513
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"model_filters" : {
3+
"discover": [
4+
{ "id": "wko_filter" }
5+
]
6+
},
7+
"variable_injectors" : {"PORT": {},"HOST": {},"URL": {}},
8+
"validation_method" : "lax",
9+
"credentials_output_method" : "script",
10+
"exclude_domain_bin_contents": true,
11+
"wls_credentials_name" : "__weblogic-credentials__",
12+
"additional_output" : "vz-application.yaml",
13+
"use_persistent_volume" : true
14+
}

tools/wdt-config/mii/targets/vz/target.json renamed to tools/wdt-config/targets/vz/target.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"model_filters" : {
33
"discover": [
4-
{ "name": "vz_prep", "path": "@@TARGET_CONFIG_DIR@@/vz_filter.py" },
54
{ "id": "wko_filter" }
65
]
76
},
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"model_filters" : {
33
"discover": [
4-
{ "name": "wko_prep", "path": "@@TARGET_CONFIG_DIR@@/wko_operator_filter.py" },
54
{ "id": "wko_filter" }
65
]
76
},
@@ -10,6 +9,5 @@
109
"credentials_output_method" : "json",
1110
"exclude_domain_bin_contents": true,
1211
"wls_credentials_name" : "__weblogic-credentials__",
13-
"additional_secrets": "runtime-encryption-secret",
1412
"additional_output" : "wko-domain.yaml"
1513
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"model_filters" : {
3+
"discover": [
4+
{ "id": "wko_filter" }
5+
]
6+
},
7+
"variable_injectors" : {"PORT": {},"HOST": {},"URL": {}},
8+
"validation_method" : "wktui",
9+
"credentials_output_method" : "json",
10+
"exclude_domain_bin_contents": true,
11+
"wls_credentials_name" : "__weblogic-credentials__",
12+
"additional_output" : "wko-domain.yaml",
13+
"use_persistent_volume" : true
14+
}

tools/wdt-config/mii/targets/wko/target.json renamed to tools/wdt-config/targets/wko/target.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"model_filters" : {
33
"discover": [
4-
{ "name": "wko_prep", "path": "@@TARGET_CONFIG_DIR@@/wko_operator_filter.py" },
54
{ "id": "wko_filter" }
65
]
76
},

webui/src/js/models/k8s-domain-definition.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ define(['knockout', 'utils/observable-properties', 'utils/common-utilities', 'ut
5858
this.auxImagePullPolicy = props.createProperty('IfNotPresent');
5959

6060
this.clusterKeys = [
61-
'name', 'maxServers', 'replicas', 'minHeap', 'maxHeap', 'cpuRequest', 'cpuLimit', 'memoryRequest',
61+
'uid', 'name', 'maxServers', 'replicas', 'minHeap', 'maxHeap', 'cpuRequest', 'cpuLimit', 'memoryRequest',
6262
'memoryLimit', 'disableDebugStdout', 'disableFan', 'useUrandom', 'additionalArguments'
6363
];
64-
this.clusters = props.createListProperty(this.clusterKeys).persistByKey('name');
64+
this.clusters = props.createListProperty(this.clusterKeys).persistByKey('uid');
6565

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

206206
this.setClusterRow = (prepareModelCluster) => {
207-
let found;
207+
let cluster;
208208
for (const row of this.clusters.observable()) {
209209
if (row.name === prepareModelCluster.clusterName) {
210210
row.maxServers = prepareModelCluster.replicas;
211211
if (row.replicas === undefined || row.replicas > row.maxServers) {
212212
row.replicas = row.maxServers;
213213
}
214-
found = true;
214+
cluster = row;
215215
break;
216216
}
217217
}
218-
if (!found) {
218+
if (cluster) {
219+
this.clusters.observable.replace(cluster, cluster);
220+
} else {
219221
this.clusters.addNewItem({
222+
uid: utils.getShortUuid(),
220223
name: prepareModelCluster.clusterName,
221224
maxServers: prepareModelCluster.replicas,
222225
replicas: prepareModelCluster.replicas

webui/src/js/models/wkt-project.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,30 @@ function (ko, wdtConstructor, imageConstructor, kubectlConstructor, domainConstr
111111
}
112112
delete wktProjectJson.kubectl.extraPathDirectories;
113113
}
114+
115+
// Version 1.1.1 changes domain clusters to be persisted by UID instead of name
116+
// to allow us to support adding new clusters on the domain page for the
117+
// Domain in PV use case...
118+
//
119+
if ('k8sDomain' in wktProjectJson && 'clusters' in wktProjectJson.k8sDomain) {
120+
const currentClusters = wktProjectJson.k8sDomain.clusters;
121+
const newClusters = {};
122+
for (const clusterName in currentClusters) {
123+
const cluster = currentClusters[clusterName];
124+
// This is tricky because the only way to tell if the cluster is in
125+
// the old format is if there is no name field...
126+
//
127+
if (cluster.name) {
128+
break;
129+
}
130+
cluster.name = clusterName;
131+
const uid = utils.getShortUuid();
132+
newClusters[uid] = cluster;
133+
}
134+
if (Object.keys(newClusters).length > 0) {
135+
wktProjectJson.k8sDomain.clusters = newClusters;
136+
}
137+
}
114138
};
115139

116140
this.setFromJson = (wktProjectJson, modelContentsJson) => {

webui/src/js/utils/wdt-preparer.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ function(WdtActionsBase, project, wktConsole, i18n, projectIo, dialogHelper, val
2626
const errPrefix = 'wdt-preparer';
2727
const shouldCloseBusyDialog = !options.skipBusyDialog;
2828

29-
if (this.project.settings.targetDomainLocation.value === 'pv') {
30-
const errMessage = i18n.t('wdt-preparer-domain-in-pv-message');
31-
await window.api.ipc.invoke('show-info-message', errTitle, errMessage);
32-
return Promise.resolve(false);
33-
}
34-
3529
const validationObject = this.getValidationObject('flow-prepare-model-name');
3630
if (validationObject.hasValidationErrors()) {
3731
const validationErrorDialogConfig = validationObject.getValidationErrorDialogConfig(errTitle);

webui/src/js/utils/wdt-validator.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ function(WdtActionsBase, project, wktConsole, i18n, projectIo, dialogHelper, val
2626
const errPrefix = 'wdt-validator';
2727
const shouldCloseBusyDialog = !options.skipBusyDialog;
2828

29-
if (this.project.settings.targetDomainLocation.value === 'pv') {
30-
const errMessage = i18n.t('wdt-validator-domain-in-pv-message');
31-
await window.api.ipc.invoke('show-info-message', errTitle, errMessage);
32-
return Promise.resolve(false);
33-
}
34-
3529
const validationObject = this.getValidationObject('flow-validate-model-name');
3630
if (validationObject.hasValidationErrors()) {
3731
const validationErrorDialogConfig = validationObject.getValidationErrorDialogConfig(errTitle);

webui/src/js/viewModels/cluster-edit-dialog.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright (c) 2021, Oracle and/or its affiliates.
3+
* Copyright (c) 2021, 2022, Oracle and/or its affiliates.
44
* Licensed under The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
55
*/
66
'use strict';
@@ -36,15 +36,29 @@ function(accUtils, ko, i18n, project, ArrayDataProvider,
3636

3737
this.project = project;
3838
this.cluster = args.cluster;
39+
this.existingClusterNames = args.existingNames;
40+
this.isDomainInPV = args.isDomainInPV;
3941
this.i18n = i18n;
4042

43+
this.nameIsUnique = {
44+
validate: (value) => {
45+
const existingNames = this.existingClusterNames;
46+
if (!value) {
47+
throw new Error(this.labelMapper('name-is-empty-error'));
48+
} else if (Array.isArray(existingNames) && existingNames.length > 0 && existingNames.includes(value)) {
49+
throw new Error(this.labelMapper('name-not-unique-error',
50+
{ name: value, existingNames: existingNames.join(',')}));
51+
}
52+
},
53+
};
4154
this.integerConverter = new ojConverterNumber.IntlNumberConverter({
4255
style: 'decimal',
4356
roundingMode: 'HALF_DOWN',
4457
maximumFractionDigits: 0,
4558
useGrouping: false
4659
});
4760

61+
4862
// create an observable property for each simple field
4963
this['maxServers'] = this.cluster.maxServers;
5064
SIMPLE_PROPERTIES.forEach(propertyName => {

0 commit comments

Comments
 (0)