Skip to content

adding helm timeout field for operator/ingress install/update #166

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
Sep 21, 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
22 changes: 16 additions & 6 deletions electron/app/js/helmUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,22 @@ function getHelmEnv(httpsProxyUrl, bypassProxyHosts, helmOptions) {
function processHelmChartValues(args, helmChartValues) {
if (helmChartValues) {
for (const [propertyName, propertyValue] of Object.entries(helmChartValues)) {
if (propertyName === 'imagePullSecrets') {
args.push(...formatArrayOfObjectsSetArgument(propertyName, propertyValue));
} else if (propertyName === 'nodeSelector') {
args.push(...formatNodeSelectorSetArgument(propertyValue));
} else {
args.push('--set', formatSetArgument(propertyName, propertyValue));
switch (propertyName) {
case 'imagePullSecrets':
args.push(...formatArrayOfObjectsSetArgument(propertyName, propertyValue));
break;

case 'nodeSelector':
args.push(...formatNodeSelectorSetArgument(propertyValue));
break;

case 'timeout':
args.push('--timeout', `${propertyValue}m`);
break;

default:
args.push('--set', formatSetArgument(propertyName, propertyValue));
break;
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions electron/app/locales/en/webui.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,9 @@
"wko-design-node-selector-label-value-header": "Label Value",
"wko-design-node-selector-add-row-tooltip": "Add Node Selector Label",
"wko-design-node-selector-delete-row-tooltip": "Delete Node Selector Label",
"wko-design-helm-settings-title": "Helm Settings",
"wko-design-helm-timeout-label": "Helm Timeout in Minutes",
"wko-design-helm-timeout-help": "The number of minutes that the Helm command will wait for the WebLogic Kubernetes Operator install or update command to complete.",

"domain-page-hints-deployDomain": "Deploy WebLogic Domain to Kubernetes",
"domain-page-button-deployDomain": "Deploy Domain",
Expand Down Expand Up @@ -697,6 +700,8 @@
"ingress-design-install-ingress-controller-help": "Whether to install the selected ingress controller.",
"ingress-design-ingress-name-label": "Helm Release Name to Use",
"ingress-design-ingress-name-help": "The Helm release name used to install the ingress controller.",
"ingress-design-helm-timeout-label": "Helm Timeout in Minutes",
"ingress-design-helm-timeout-help": "The number of minutes that the Helm command will wait for the Ingress Controller install command to complete.",
"ingress-design-ingress-namespace-label": "Ingress Controller Namespace",
"ingress-design-ingress-namespace-help": "The Kubernetes namespace to use for the ingress controller.",
"ingress-design-voyager-provider-label": "Kubernetes Cluster Provider for Voyager",
Expand Down
2 changes: 2 additions & 0 deletions webui/src/js/models/ingress-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ define(['knockout', 'utils/observable-properties', 'utils/validation-helper'],
this.specifyDockerRegSecret = props.createProperty(false);
this.specifyIngressTLSSecret = props.createProperty(false);

this.helmTimeoutMinutes = props.createProperty(5);

this.ingressRouteKeys = [
'uid', 'name', 'virtualHost', 'targetServiceNameSpace', 'targetService', 'targetPort',
'path', 'annotations', 'accessPoint', 'tlsOption', 'markedForDeletion', 'isConsoleService'
Expand Down
2 changes: 2 additions & 0 deletions webui/src/js/models/wko-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ define(['utils/observable-properties', 'utils/validation-helper'],
//
this.nodeSelector = props.createListProperty(['uid', 'name', 'value']);

this.helmTimeoutMinutes = props.createProperty(5);

// internal fields that should not be read or written to the project file.
this.internal = {
operatorImagePullRegistryAddress: props.createProperty()
Expand Down
21 changes: 21 additions & 0 deletions webui/src/js/utils/cmd-script-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ define(['utils/script-adapter-base'],
return this.getEnvironmentVariableReference(name);
}

addHelmTimeoutCollectArgsBlock(comment, collectVarName, timeoutVarRef) {
if (comment) {
this.addComment(comment);
}

this._lines.push(
`IF DEFINED ${this._getVariableNameFromReference(timeoutVarRef)} (`,
`${this.indent(1)}SET "${collectVarName}=${this.getVariableReference(collectVarName)} ${timeoutVarRef}m"`,
')',
''
);
}

addNotEmptyCollectArgsBlock(collectVarName, varRef, valuePrefix) {
let value = `"${varRef}"`;
if (valuePrefix) {
Expand Down Expand Up @@ -256,6 +269,12 @@ define(['utils/script-adapter-base'],
')'
];

const helmTimeoutLines = [
`IF "${helmChartValues.timeout}" NEQ "" (`,
`${this.indent(1)}SET "${variableName}=${variableRef} --timeout ${helmChartValues.timeout}m"`,
')',
];

const initialValue = `--set domainNamespaceSelectionStrategy=${helmChartValues.domainNamespaceSelectionStrategy}`;
this.addVariableDefinition(variableName, initialValue);
this._lines.push(
Expand All @@ -274,6 +293,8 @@ define(['utils/script-adapter-base'],
...elkIntegrationLines,
'',
...javaLoggingLines,
'',
...helmTimeoutLines,
''
);
}
Expand Down
4 changes: 4 additions & 0 deletions webui/src/js/utils/ingress-controller-installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ function(IngressActionsBase, project, wktConsole, k8sHelper, i18n, dialogHelper,
if (ingressControllerProvider === 'nginx' && this.project.ingress.allowNginxSSLPassThrough) {
helmChartData['controller.extraArgs.enable-ssl-passthrough'] = true;
}

if (this.project.ingress.helmTimeoutMinutes.hasValue()) {
helmChartData['timeout'] = this.project.ingress.helmTimeoutMinutes.value;
}
return helmChartData;
}
}
Expand Down
17 changes: 17 additions & 0 deletions webui/src/js/utils/ingress-install-script-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ define(['models/wkt-project', 'utils/script-generator-base', 'utils/helm-helper'
this.adapter.addVariableDefinition('DOCKER_HUB_EMAIL', this.project.ingress.dockerRegSecretUserEmail.value);
this.adapter.addEmptyLine();

comment = [ 'The number of minutes for the helm command to wait for completion (e.g., 10)' ];
this.adapter.addVariableDefinition('HELM_TIMEOUT',
this._getOptionalScalarFieldValue(this.project.ingress.helmTimeoutMinutes), comment);
this.adapter.addEmptyLine();

this.adapter.addVariableEndBanner();

this.adapter.addKubectlExportAndUseContextBlock();
Expand Down Expand Up @@ -98,6 +103,10 @@ define(['models/wkt-project', 'utils/script-generator-base', 'utils/helm-helper'
this.adapter.addVoyagerHelmChartArgsBlock(comment, ingressControllerType, voyagerProvider,
voyagerApiEnableHealthCheck, voyagerApiEnableWebhook);

comment = [ 'The number of minutes for the helm command to wait for completion (e.g., 10)' ];
const helmTimeout = this.adapter.getVariableReference('HELM_TIMEOUT');
this.adapter.addIngressHelmChartTimeoutArgBlock(comment, helmTimeout);

comment = [ 'Add Docker Hub pull secret, if specified' ];
this.adapter.addIngressHelmChartPullSecretArgBlock(comment, ingressControllerType, useDockerHubSecret,
dockerHubSecretName);
Expand All @@ -121,6 +130,14 @@ define(['models/wkt-project', 'utils/script-generator-base', 'utils/helm-helper'
this.adapter.addScriptFooter();
return this.adapter.getScript();
}

_getOptionalScalarFieldValue(property) {
let result = '';
if (this._isSet(property)) {
result = property.value;
}
return result;
}
}

return IngressInstallScriptGenerator;
Expand Down
8 changes: 7 additions & 1 deletion webui/src/js/utils/operator-script-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ define(['models/wkt-project', 'utils/script-generator-base', 'utils/helm-helper'
this._getOptionalScalarFieldValue(this.project.wko.javaLoggingFileCount), comment);
this.adapter.addEmptyLine();

comment = [ 'The number of minutes for the helm command to wait for completion (e.g., 10)' ];
this.adapter.addVariableDefinition('HELM_TIMEOUT',
this._getOptionalScalarFieldValue(this.project.wko.helmTimeoutMinutes), comment);
this.adapter.addEmptyLine();

this.adapter.addVariableEndBanner();

const wkoHelmChartData = helmHelper.getOperatorHelmChartData();
Expand Down Expand Up @@ -224,7 +229,8 @@ define(['models/wkt-project', 'utils/script-generator-base', 'utils/helm-helper'
elasticSearchPort: this.adapter.getVariableReference('WKO_ELASTICSEARCH_PORT'),
javaLoggingLevel: this.adapter.getVariableReference('WKO_JAVA_LOGGING_LEVEL'),
javaLoggingFileSizeLimit: this.adapter.getVariableReference('WKO_JAVA_LOGGING_FILE_SIZE_LIMIT'),
javaLoggingFileCount: this.adapter.getVariableReference('WKO_JAVA_LOGGING_FILE_COUNT')
javaLoggingFileCount: this.adapter.getVariableReference('WKO_JAVA_LOGGING_FILE_COUNT'),
timeout: this.adapter.getVariableReference('HELM_TIMEOUT'),
};
}

Expand Down
21 changes: 21 additions & 0 deletions webui/src/js/utils/powershell-script-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ define(['utils/script-adapter-base'],
return `$${name}`;
}

addHelmTimeoutCollectArgsBlock(comment, collectVarName, timeoutVarRef) {
if (comment) {
this.addComment(comment);
}

this._lines.push(
`if ("${timeoutVarRef}" -ne "") {`,
`${this.indent(1)}$${collectVarName} = "${this.getVariableReference(collectVarName)} $(${timeoutVarRef})m"`,
'}',
''
);
}

addNotEmptyCollectArgsBlock(collectVarName, varRef, valuePrefix) {
let value = `""${varRef}""`;
if (valuePrefix) {
Expand Down Expand Up @@ -204,6 +217,12 @@ define(['utils/script-adapter-base'],
'}'
];

const helmTimeoutLines = [
`if ("${helmChartValues.timeout}" -ne "") {`,
`${this.indent(1)}$${variableName}="${variableRef} --timeout $(${helmChartValues.timeout})m"`,
'}',
];

const initialValue = `--set domainNamespaceSelectionStrategy=${helmChartValues.domainNamespaceSelectionStrategy}`;
this.addVariableDefinition(variableName, initialValue);
this._lines.push(
Expand All @@ -222,6 +241,8 @@ define(['utils/script-adapter-base'],
...elkIntegrationLines,
'',
...javaLoggingLines,
'',
...helmTimeoutLines,
''
);
}
Expand Down
9 changes: 9 additions & 0 deletions webui/src/js/utils/script-adapter-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ define([],
this._lines.push(...this._formatVoyagerHelmChartArgsBlock(comment, 'HELM_CHART_ARGS', ingressType, options), '');
}

addIngressHelmChartTimeoutArgBlock(comment, timeoutArg) {
this.addHelmTimeoutCollectArgsBlock(comment, 'HELM_CHART_ARGS', timeoutArg);
}

addIngressHelmChartPullSecretArgBlock(comment, ingressType, useSecret, secretName) {
this._lines.push(...this._formatIngressHelmChartPullSecretBlock(comment, 'HELM_CHART_ARGS',
ingressType, useSecret, secretName), '');
Expand Down Expand Up @@ -431,6 +435,11 @@ define([],
/* subclasses must implement. */
}

// eslint-disable-next-line no-unused-vars
addHelmTimeoutCollectArgsBlock(comment, collectVarName, timeoutVarRef) {
/* subclasses must implement. */
}

// eslint-disable-next-line no-unused-vars
addNotEmptyCollectArgsBlock(collectVarName, varRef, valuePrefix) {
/* subclasses must implement. */
Expand Down
21 changes: 21 additions & 0 deletions webui/src/js/utils/sh-script-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ define(['utils/script-adapter-base'],
this._lines.push(...block, '');
}

addHelmTimeoutCollectArgsBlock(comment, collectVarName, timeoutVarRef) {
if (comment) {
this.addComment(comment);
}

this._lines.push(
`if [ "${timeoutVarRef}" != "" ]; then`,
`${this.indent(1)}${collectVarName}="${this.getVariableReference(collectVarName)} ${timeoutVarRef}m"`,
'fi',
''
);
}

addNotEmptyCollectArgsBlock(collectVarName, varRef, valuePrefix) {
let value = `"${varRef}"`;
if (valuePrefix) {
Expand Down Expand Up @@ -207,6 +220,12 @@ define(['utils/script-adapter-base'],
'fi'
];

const helmTimeoutLines = [
`if [ "${helmChartValues.timeout}" != "" ]; then`,
`${this.indent(1)}${variableName}="${variableRef} --timeout ${helmChartValues.timeout}m"`,
'fi',
];

const initialValue = `--set domainNamespaceSelectionStrategy=${helmChartValues.domainNamespaceSelectionStrategy}`;
this.addVariableDefinition(variableName, initialValue);
this._lines.push(
Expand All @@ -225,6 +244,8 @@ define(['utils/script-adapter-base'],
...elkIntegrationLines,
'',
...javaLoggingLines,
'',
...helmTimeoutLines,
''
);
}
Expand Down
1 change: 1 addition & 0 deletions webui/src/js/utils/wko-actions-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function(WktActionsBase, project, wktConsole, i18n, projectIo, dialogHelper, val
this.addHelmChartValueIfSet(helmChartValues, 'enableClusterRoleBinding', this.project.wko.enableClusterRoleBinding);
this.addHelmChartValueIfSet(helmChartValues, 'image', this.project.wko.operatorImage);
this.addHelmChartValueIfSet(helmChartValues, 'imagePullPolicy', this.project.wko.operatorImagePullPolicy);
this.addHelmChartValueIfSet(helmChartValues, 'timeout', this.project.wko.helmTimeoutMinutes);

if (this.project.wko.operatorImagePullRequiresAuthentication.value) {
const imagePullSecret = this.project.wko.operatorImagePullSecretName.value;
Expand Down
6 changes: 6 additions & 0 deletions webui/src/js/views/ingress-design-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ <h6 class="wkt-subheading">
validators="[[project.ingress.validators.k8sNameValidator]]"
help.instruction="[[labelMapper('ingress-name-help')]]">
</oj-input-text>
<oj-input-number label-hint="[[labelMapper('helm-timeout-label')]]"
value="{{project.ingress.helmTimeoutMinutes.observable}}"
min="1"
max="60"
help.instruction="[[labelMapper('helm-timeout-help')]]">
</oj-input-number>
<oj-bind-if test="[[isVoyager() === true]]">
<oj-select-single label-hint="[[labelMapper('voyager-provider-label')]]"
value="{{project.ingress.voyagerProvider.observable}}"
Expand Down
11 changes: 11 additions & 0 deletions webui/src/js/views/operator-design-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,15 @@ <h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('node-selector-tit
</template>
</oj-table>
</div>
<div class="oj-panel">
<h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('helm-settings-title')]]"></oj-bind-text></h6>
<oj-form-layout max-columns="2" direction="column">
<oj-input-number label-hint="[[labelMapper('helm-timeout-label')]]"
value="{{project.wko.helmTimeoutMinutes.observable}}"
min="1"
max="60"
help.instruction="[[labelMapper('helm-timeout-help')]]">
</oj-input-number>
</oj-form-layout>
</div>
</oj-collapsible>