Skip to content

fixing domain resource generation for aux images with the V9 schema #191

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
Nov 3, 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
4 changes: 4 additions & 0 deletions electron/app/locales/en/webui.json
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@
"domain-design-image-registry-address-help": "The image registry hostname and port to use to log in to the registry, if required. This field's value is parsed from the Primary Image Tag field and an empty value assumes Docker Hub is the registry being used.",
"domain-design-image-pull-policy-label": "Primary Image Pull Policy",
"domain-design-image-pull-policy-help": "When to pull the domain's primary image from the image registry.",
"domain-design-image-wdt-install-home-label": "WebLogic Deploy Tooling Install Home in Primary Image",
"domain-design-image-wdt-install-home-help": "The location of the WebLogic Deploy Tooling installation within the primary image.",
"domain-design-image-model-home-label": "WebLogic Deploy Tooling Model Home in Primary Image",
"domain-design-image-model-home-help": "The directory location of the WebLogic Deploy Tooling model files within the primary image.",
"domain-design-image-registry-pull-requires-authentication-label": "Specify Image Pull Credentials",
"domain-design-image-registry-pull-requires-authentication-help": "Whether you want to specify authentication credentials for pulling the image from the registry.",
"domain-design-image-registry-use-existing-pull-secret-label": "Use Existing Image Pull Secret",
Expand Down
10 changes: 10 additions & 0 deletions webui/src/js/models/k8s-domain-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ define(['knockout', 'utils/observable-properties', 'utils/common-utilities', 'ut

this.imagePullPolicy = props.createProperty('IfNotPresent');

// These fields are exposed to the user only when using an existing Primary Image and
// not using an Auxiliary Image at all.
//
this.imageModelHome = props.createProperty('/u01/wdt/models');
this.imageWDTInstallHome = props.createProperty('/u01/wdt/weblogic-deploy');


// Auxiliary image-related properties
this.auxImageRegistryPullRequireAuthentication = props.createProperty(false);
this.auxImageRegistryUseExistingPullSecret = props.createProperty(true);
Expand All @@ -56,6 +63,9 @@ define(['knockout', 'utils/observable-properties', 'utils/common-utilities', 'ut
this.auxImageRegistryPullEmail = props.createProperty();
this.auxImageRegistryPullEmail.addValidator(...validationHelper.getEmailAddressValidators());
this.auxImagePullPolicy = props.createProperty('IfNotPresent');

// These fields are exposed to the user only when using an existing Auxiliary Image.
//
this.auxImageSourceModelHome = props.createProperty('/auxiliary/models');
this.auxImageSourceWDTInstallHome = props.createProperty('/auxiliary/weblogic-deploy');

Expand Down
47 changes: 38 additions & 9 deletions webui/src/js/utils/k8s-domain-v8-resource-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function(project, K8sDomainConfigMapGenerator, jsYaml, i18n) {
} else {
// Only set these if they are specified; otherwise, rely on the default values
if (wdtRelatedPaths.wdtHome) {
domainResource.spec.configuration.model.wdtHome = wdtRelatedPaths.wdtHome;
domainResource.spec.configuration.model.wdtInstallHome = wdtRelatedPaths.wdtHome;
}
if (wdtRelatedPaths.modelHome) {
domainResource.spec.configuration.model.modelHome = wdtRelatedPaths.modelHome;
Expand Down Expand Up @@ -216,30 +216,59 @@ function(project, K8sDomainConfigMapGenerator, jsYaml, i18n) {

result = { };
if (usingAuxImage()) {
const wdtHome = this.project.image.wdtHomePath.value;
const modelHome = this.project.image.modelHomePath.value;
let wdtHome;
let modelHome;
if (creatingAuxImage()) {
wdtHome = this.project.image.wdtHomePath.value;
modelHome = this.project.image.modelHomePath.value;
} else {
modelHome = this.project.k8sDomain.auxImageSourceModelHome.value;
wdtHome = this.project.k8sDomain.auxImageSourceWDTInstallHome.value;
const match = wdtHome.match(/(\/.+?)\/weblogic-deploy\/?/);
if (match) {
wdtHome = match[1];
}
}
result.targetWdtHomeDirName = 'weblogic-deploy';
result.sourceWdtHome = window.api.path.join(wdtHome, result.targetWdtHomeDirName);
result.sourceModelHome = modelHome;
result.targetModelHomeDirName = window.api.path.basename(modelHome);
} else {
// Only set these if they are not the default
if (this.project.image.wdtHomePath.hasValue()) {
result.wdtHome = this.project.image.wdtHomePath.value;
}
if (this.project.image.modelHomePath.hasValue()) {
result.modelHome = this.project.image.modelHomePath.value;
if (usingExistingPrimaryImage()) {
if (this.project.k8sDomain.imageWDTInstallHome.hasValue()) {
result.wdtHome = this.project.k8sDomain.imageWDTInstallHome.value;
}
if (this.project.k8sDomain.imageModelHome.hasValue()) {
result.modelHome = this.project.k8sDomain.imageModelHome.value;
}
} else {
// Only set these if they are not the default
if (this.project.image.wdtHomePath.hasValue()) {
result.wdtHome = this.project.image.wdtHomePath.value;
}
if (this.project.image.modelHomePath.hasValue()) {
result.modelHome = this.project.image.modelHomePath.value;
}
}
}
}
return result;
}
}

function usingExistingPrimaryImage() {
return project.settings.targetDomainLocation.value === 'mii' && !project.image.createPrimaryImage.value
&& !project.image.useAuxImage.value;
}

function usingAuxImage() {
return project.settings.targetDomainLocation.value === 'mii' && project.image.useAuxImage.value;
}

function creatingAuxImage() {
return usingAuxImage() && project.image.createAuxImage.value;
}

function getAuxImageCopyCommand(wdtRelatedPaths) {
const auxImageInternalTarget = '$AUXILIARY_IMAGE_TARGET_PATH';

Expand Down
113 changes: 74 additions & 39 deletions webui/src/js/utils/k8s-domain-v9-resource-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml', 'utils/i18n', 'utils/wkt-logger'],
function(project, K8sDomainConfigMapGenerator, jsYaml, i18n) {
const WDT_DIR_NAME = 'weblogic-deploy';

class K8sDomainV9ResourceGenerator {
constructor() {
this.project = project;
Expand Down Expand Up @@ -52,19 +54,8 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
domainResource.spec.serverPod = serverPod;
}

if (usingAuxImage()) {
const auxiliaryImage = {
image: this.project.image.auxImageTag.value,
};
if (this.project.k8sDomain.auxImagePullPolicy.hasValue()) {
auxiliaryImage.imagePullPolicy = this.project.k8sDomain.auxImagePullPolicy.value;
}
if (this.project.k8sDomain.auxImageSourceWDTInstallHome.hasValue()) {
auxiliaryImage.sourceWDTInstallHome = this.project.k8sDomain.auxImageSourceWDTInstallHome.value;
}
if (this.project.k8sDomain.auxImageSourceModelHome.hasValue()) {
auxiliaryImage.sourceModelHome = this.project.k8sDomain.auxImageSourceModelHome.value;
}
if (this.project.settings.targetDomainLocation.value === 'mii') {
const wdtRelatedPaths = this._getWdtRelatedPaths(domainResource);

if (!domainResource.spec.configuration) {
domainResource.spec.configuration = {
Expand All @@ -73,7 +64,26 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
} else if (!domainResource.spec.configuration.model) {
domainResource.spec.configuration.model = {};
}
domainResource.spec.configuration.model.auxiliaryImages = [ auxiliaryImage ];

if (usingAuxImage()) {
const auxiliaryImage = {
image: this.project.image.auxImageTag.value,
};
if (this.project.k8sDomain.auxImagePullPolicy.hasValue()) {
auxiliaryImage.imagePullPolicy = this.project.k8sDomain.auxImagePullPolicy.value;
}
auxiliaryImage.sourceWDTInstallHome = wdtRelatedPaths.sourceWDTInstallHome;
auxiliaryImage.sourceModelHome = wdtRelatedPaths.sourceModelHome;

domainResource.spec.configuration.model.auxiliaryImages = [ auxiliaryImage ];
} else {
if (wdtRelatedPaths.wdtInstallHome) {
domainResource.spec.configuration.model.wdtInstallHome = wdtRelatedPaths.wdtInstallHome;
}
if (wdtRelatedPaths.modelHome) {
domainResource.spec.configuration.model.modelHome = wdtRelatedPaths.modelHome;
}
}
}

if (this.project.k8sDomain.clusters.value.length === 0) {
Expand Down Expand Up @@ -113,17 +123,6 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
domainResource.spec.configuration.model.domainType = this.project.k8sDomain.domainType.value;
domainResource.spec.configuration.model.runtimeEncryptionSecret = this.project.k8sDomain.runtimeSecretName.value;

if (!usingAuxImage()) {
const wdtRelatedPaths = this._getWdtRelatedPaths(domainResource);
// Only set these if they are specified; otherwise, rely on the default values
if (wdtRelatedPaths.wdtHome) {
domainResource.spec.configuration.model.wdtHome = wdtRelatedPaths.wdtHome;
}
if (wdtRelatedPaths.modelHome) {
domainResource.spec.configuration.model.modelHome = wdtRelatedPaths.modelHome;
}
}

if (this.k8sConfigMapGenerator.shouldCreateConfigMap()) {
domainResource.spec.configuration.model.configMap = this.project.k8sDomain.modelConfigMapName.value;
}
Expand Down Expand Up @@ -237,24 +236,51 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',

_getWdtRelatedPaths() {
let result;

if (this.project.settings.targetDomainLocation.value === 'mii') {

result = { };

// WKO 4.0+ has different behavior and parameters than 3.x
//
let wdtInstallHome = this.project.image.wdtHomePath.value;
if (!wdtInstallHome.endsWith(WDT_DIR_NAME)) {
wdtInstallHome = window.api.path.join(wdtInstallHome, WDT_DIR_NAME);
}
if (usingAuxImage()) {
const wdtHome = this.project.image.wdtHomePath.value;
const modelHome = this.project.image.modelHomePath.value;
result.targetWdtHomeDirName = 'weblogic-deploy';
result.sourceWdtHome = window.api.path.join(wdtHome, result.targetWdtHomeDirName);
result.sourceModelHome = modelHome;
result.targetModelHomeDirName = window.api.path.basename(modelHome);
} else {
// Only set these if they are not the default
if (this.project.image.wdtHomePath.hasValue()) {
result.wdtHome = this.project.image.wdtHomePath.value;
if (usingExistingAuxImage()) {
// If the source fields are exposed in the UI, use the values from those fields.
//
if (this.project.k8sDomain.auxImageSourceWDTInstallHome.hasValue()) {
result.sourceWDTInstallHome = this.project.k8sDomain.auxImageSourceWDTInstallHome.value;
}
if (this.project.k8sDomain.auxImageSourceModelHome.hasValue()) {
result.sourceModelHome = this.project.k8sDomain.auxImageSourceModelHome.value;
}
} else {
// If creating a new image, then use the values from the image page.
//
result.sourceWDTInstallHome = wdtInstallHome;
result.sourceModelHome = this.project.image.modelHomePath.value;
}
if (this.project.image.modelHomePath.hasValue()) {
result.modelHome = this.project.image.modelHomePath.value;
// We intentionally do not set the wdtInstallHome and modelHome parameters
// since the default values will always be correct in V9 when using aux images.
//
} else {
if (usingExistingPrimaryImage()) {
// If these fields are exposed in the UI, use them if they have non-default values.
//
if (this.project.k8sDomain.imageWDTInstallHome.hasValue()) {
result.wdtInstallHome = this.project.k8sDomain.imageWDTInstallHome.value;
}
if (this.project.k8sDomain.imageModelHome.hasValue()) {
result.modelHome = this.project.k8sDomain.imageModelHome.value;
}
} else {
if (this.project.image.modelHomePath.hasValue()) {
result.wdtInstallHome = wdtInstallHome;
}
if (this.project.image.modelHomePath.hasValue()) {
result.modelHome = this.project.image.modelHomePath.value;
}
}
}
}
Expand All @@ -266,6 +292,15 @@ define(['models/wkt-project', 'utils/k8s-domain-configmap-generator', 'js-yaml',
return project.settings.targetDomainLocation.value === 'mii' && project.image.useAuxImage.value;
}

function usingExistingPrimaryImage() {
return project.settings.targetDomainLocation.value === 'mii' && !project.image.createPrimaryImage.value
&& !project.image.useAuxImage.value;
}

function usingExistingAuxImage() {
return usingAuxImage() && !project.image.createAuxImage.value;
}

function getOperatorNameForTargetDomainLocation(targetDomainLocation) {
switch (targetDomainLocation) {
case 'mii':
Expand Down
12 changes: 12 additions & 0 deletions webui/src/js/viewModels/domain-design-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ function (project, accUtils, utils, ko, i18n, screenUtils, BufferingDataProvider
return this.labelMapper(key);
}, this);

this.showPrimaryImageHomeFields = ko.computed(() => {
return this.project.settings.targetDomainLocation.observable() === 'mii' &&
!this.project.image.createPrimaryImage.observable() &&
!this.project.image.useAuxImage.observable();
}, this);

this.isPrimaryImageTagReadOnly = ko.computed(() => {
return this.project.image.createPrimaryImage.observable();
}, this);
Expand All @@ -137,6 +143,12 @@ function (project, accUtils, utils, ko, i18n, screenUtils, BufferingDataProvider
return this.project.image.createAuxImage.observable();
}, this);

this.showAuxImageSourceFields = ko.computed(() => {
return this.project.settings.targetDomainLocation.observable() === 'mii' &&
this.project.image.useAuxImage.observable() &&
!this.project.image.createAuxImage.observable();
}, this);

this.auxImageTagHelp = ko.computed(() => {
let key = 'use-aux-image-tag-help';
if (this.project.image.createAuxImage.observable()) {
Expand Down
17 changes: 16 additions & 1 deletion webui/src/js/views/domain-design-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,20 @@ <h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('image-title')]]">
help.instruction="[[labelMapper('image-pull-policy-help')]]">
</oj-select-single>
</oj-form-layout>

<oj-bind-if test="[[showPrimaryImageHomeFields]]">
<oj-form-layout max-columns="2" direction="row">
<oj-input-text label-hint="[[labelMapper('image-wdt-install-home-label')]]"
value="{{project.k8sDomain.imageWDTInstallHome.observable}}"
help.instruction="[[labelMapper('image-wdt-install-home-help')]]">
</oj-input-text>
<oj-input-text label-hint="[[labelMapper('image-model-home-label')]]"
value="{{project.k8sDomain.imageModelHome.observable}}"
help.instruction="[[labelMapper('image-model-home-help')]]">
</oj-input-text>
</oj-form-layout>
</oj-bind-if>

<oj-form-layout max-columns="2" direction="row">
<oj-switch label-hint="[[labelMapper('image-registry-pull-requires-authentication-label')]]"
value="{{project.k8sDomain.imageRegistryPullRequireAuthentication.observable}}"
Expand Down Expand Up @@ -232,7 +246,8 @@ <h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('aux-image-title')
help.instruction="[[labelMapper('aux-image-pull-policy-help')]]">
</oj-select-single>
</oj-form-layout>
<oj-bind-if test="[[project.image.createAuxImage.observable() === false]]">

<oj-bind-if test="[[showAuxImageSourceFields]]">
<oj-form-layout max-columns="2" direction="row">
<oj-input-text label-hint="[[labelMapper('aux-image-source-wdt-home-label')]]"
value="{{project.k8sDomain.auxImageSourceWDTInstallHome.observable}}"
Expand Down