Skip to content

Commit 0b2b8fb

Browse files
committed
making the startup connectivity timeout configurable and persisting the generated runtime secret value
1 parent 263396c commit 0b2b8fb

File tree

11 files changed

+110
-27
lines changed

11 files changed

+110
-27
lines changed

electron/app/js/connectivityUtils.js

Lines changed: 7 additions & 7 deletions
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 v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
'use strict';
@@ -11,19 +11,18 @@ const { homepage } = require('../../package.json');
1111
const { getLogger } = require('./wktLogging');
1212
const errorUtils = require('./errorUtils');
1313

14-
const CONNECT_TIMEOUT = 5000;
15-
1614
// test connectivity for user settings configuration
1715
async function testConfiguredInternetConnectivity() {
1816
const userSettings = require('./userSettings');
1917
const httpsProxyUrl = userSettings.getHttpsProxyUrl();
20-
return testInternetConnectivity(httpsProxyUrl);
18+
const connectivityTimeout = userSettings.getConnectivityTestTimeout();
19+
return testInternetConnectivity(httpsProxyUrl, connectivityTimeout);
2120
}
2221

2322
// test connectivity using supplied arguments
24-
async function testInternetConnectivity(httpsProxyUrl) {
23+
async function testInternetConnectivity(httpsProxyUrl, connectivityTimeout = 5000) {
2524
const options = {
26-
timeout: CONNECT_TIMEOUT,
25+
timeout: connectivityTimeout,
2726
method: 'HEAD'
2827
};
2928
if (httpsProxyUrl) {
@@ -33,12 +32,13 @@ async function testInternetConnectivity(httpsProxyUrl) {
3332
const logger = getLogger();
3433
return new Promise((resolve) => {
3534
let timeout = false;
35+
logger.debug('Starting Internet connectivity test request to %s with a timeout of %s ms', homepage, connectivityTimeout);
3636
const httpsRequest = https.request(homepage, options, (res) => {
3737
logger.debug('Internet connectivity test request to %s returned HTTP status code %s', homepage, res.statusCode);
3838
resolve(res.statusCode === 200);
3939
});
4040
httpsRequest.on('timeout', () => {
41-
logger.error('Internet connectivity test timed out after %s ms', CONNECT_TIMEOUT);
41+
logger.error('Internet connectivity test timed out after %s ms', connectivityTimeout);
4242
timeout = true;
4343
httpsRequest.destroy();
4444
});

electron/app/js/userSettings.js

Lines changed: 34 additions & 3 deletions
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 v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
const { app } = require('electron');
@@ -13,7 +13,8 @@ const { getErrorMessage } = require('./errorUtils');
1313
const userSettableFieldNames = [
1414
'proxy',
1515
'logging',
16-
'skipQuickstartAtStartup'
16+
'skipQuickstartAtStartup',
17+
'connectivityTestTimeoutMilliseconds'
1718
];
1819

1920
const appPrivateFieldNames = [
@@ -54,7 +55,9 @@ let _userSettingsFileName;
5455
// "modelRight": 0.48
5556
// },
5657
// "navCollapsed": true
57-
// }
58+
// },
59+
// "skipQuickstartAtStartup": true,
60+
// "connectivityTestTimeoutMilliseconds": 10000
5861
// }
5962
//
6063
let _userSettingsObject;
@@ -158,6 +161,31 @@ function setSkipQuickstartAtStartup(value) {
158161
_userSettingsObject = settings;
159162
}
160163

164+
165+
function getConnectivityTestTimeout() {
166+
const settings = _getUserSettings();
167+
if ('connectivityTestTimeoutMilliseconds' in settings) {
168+
return settings['connectivityTestTimeoutMilliseconds'];
169+
} else {
170+
return getDefaultConnectivityTestTimeout();
171+
}
172+
}
173+
174+
function getDefaultConnectivityTestTimeout() {
175+
return 5000;
176+
}
177+
178+
function setConnectivityTestTimeout(value) {
179+
const settings = _getUserSettings();
180+
if (value === undefined || value === null || Number(value) === getDefaultConnectivityTestTimeout()) {
181+
if ('connectivityTestTimeoutMilliseconds' in settings) {
182+
delete settings['connectivityTestTimeoutMilliseconds'];
183+
}
184+
} else {
185+
settings['connectivityTestTimeoutMilliseconds'] = Number(value);
186+
}
187+
}
188+
161189
function setDividerLocation(name, percent) {
162190
const window = getOrCreateWindowSettings();
163191
let dividers = window['dividers'];
@@ -376,6 +404,9 @@ module.exports = {
376404
setNavigationCollapsed,
377405
getSkipQuickstartAtStartup,
378406
setSkipQuickstartAtStartup,
407+
getConnectivityTestTimeout,
408+
getDefaultConnectivityTestTimeout,
409+
setConnectivityTestTimeout,
379410
getBypassProxyHosts,
380411
setBypassProxyHosts,
381412
getWindowSize,

electron/app/js/wktWindow.js

Lines changed: 4 additions & 3 deletions
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 v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
const { app, BrowserWindow, dialog, Menu, shell } = require('electron');
@@ -568,7 +568,8 @@ class WktAppMenu {
568568
userSettingsJson: remoteUserSettings,
569569
defaults: {
570570
logDir: getDefaultLogDirectory(_wktMode),
571-
level: 'info'
571+
level: 'info',
572+
connectivityTestTimeoutMilliseconds: userSettings.getDefaultConnectivityTestTimeout()
572573
},
573574
isDevMode: _wktMode.isDevelopmentMode(),
574575
};
@@ -817,7 +818,7 @@ async function createWindow() {
817818

818819
function createNetworkWindow() {
819820
const width = _isJetDevMode ? 1000 : 640;
820-
const height = 480;
821+
const height = 560;
821822
const additionalArguments = _getAdditionalArguments();
822823
additionalArguments.push('--mainModule=network-page');
823824

electron/app/locales/en/webui.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"kubectl-config-context-help": "The Kubernetes config file context name for the cluster to which you want to connect. The default is to use whatever the current context is, if any.",
4141
"kubectl-add-row-icon-text": "Add Extra Kubernetes Client Path Directory",
4242
"kubectl-choose-path-icon-text": "Choose Extra Kubernetes Client Path Directory",
43+
"kubectl-choose-path-icon-text": "Choose Extra Kubernetes Client Path Directory",
4344
"kubectl-delete-row-icon-text": "Remove Extra Kubernetes Client Path Directory",
4445
"kubectl-extra-path-directory-header": "Extra Kubernetes Client Path Directories",
4546
"kubectl-helm-exe-file-path-label": "Helm Executable to Use",
@@ -148,6 +149,9 @@
148149
"user-settings-dialog-file-level-help": "The log level to use to filter output to the log file.",
149150
"user-settings-dialog-file-dir-label": "Log File Directory",
150151
"user-settings-dialog-file-dir-help": "The directory to use for writing the application log files.",
152+
"user-settings-dialog-startup-connectivity-test-title": "Startup Internet Connectivity Test Configuration",
153+
"user-settings-dialog-startup-connectivity-timeout-label": "Request Timeout Seconds",
154+
"user-settings-dialog-startup-connectivity-timeout-help": "The number of seconds the application will wait for the startup connectivity check response before timing out.",
151155
"user-settings-dialog-quickstart-section-title": "WebLogic Kubernetes Toolkit UI Introduction Configuration",
152156
"user-settings-dialog-quickstart-skip-label": "Skip Showing Introduction at Startup",
153157
"user-settings-dialog-quickstart-skip-help": "Whether or not to skip showing the WebLogic Kubernetes Toolkit UI Introduction at application startup.",

electron/app/main.js

Lines changed: 3 additions & 2 deletions
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 v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
const { app, BrowserWindow, dialog, ipcMain, shell } = require('electron');
@@ -854,12 +854,13 @@ class Main {
854854
});
855855

856856
ipcMain.handle('try-network-settings', async (event, settings) => {
857-
return connectivityUtils.testInternetConnectivity(settings['proxyUrl']);
857+
return connectivityUtils.testInternetConnectivity(settings['proxyUrl'], settings['timeout']);
858858
});
859859

860860
ipcMain.handle('restart-network-settings', async (event, settings) => {
861861
userSettings.setHttpsProxyUrl(settings['proxyUrl']);
862862
userSettings.setBypassProxyHosts(settings['bypassHosts']);
863+
userSettings.setConnectivityTestTimeout(settings['timeout']);
863864
userSettings.saveUserSettings();
864865
app.relaunch();
865866
app.quit();

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

Lines changed: 14 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 v 1.0 as shown at https://oss.oracle.com/licenses/upl.
55
*/
66
'use strict';
@@ -157,6 +157,19 @@ define(['knockout', 'utils/observable-properties', 'utils/common-utilities', 'ut
157157
this.setCredentialPathsForSecretsTable(json);
158158
props.createGroup(name, this).writeTo(json);
159159

160+
// Force the generated runtime secret to be written to the project.
161+
// This will allow us to keep the same generated password for the life
162+
// of the project (assuming the user doesn't intentionally change it).
163+
// See JIRA WKTUI-300 for details.
164+
//
165+
if (!json[name]) {
166+
json[name] = {
167+
runtimeSecretValue: this.runtimeSecretValue.value
168+
};
169+
} else if (!json[name].runtimeSecretValue) {
170+
json[name].runtimeSecretValue = this.runtimeSecretValue.value;
171+
}
172+
160173
const modelConfigMap = {};
161174
for (const entry of wdtModel.getMergedPropertiesContent().value) {
162175
if (entry.Override) {

webui/src/js/viewModels/network-page.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
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
define(['accUtils', 'knockout', 'utils/i18n', 'models/wkt-project',
7-
'ojs/ojinputtext', 'ojs/ojbutton', 'ojs/ojformlayout'],
7+
'ojs/ojinputtext', 'ojs/ojbutton', 'ojs/ojformlayout', 'ojs/ojinputnumber'],
88
function(accUtils, ko, i18n, project) {
99
function NetworkPageViewModel() {
1010

@@ -30,6 +30,7 @@ function(accUtils, ko, i18n, project) {
3030

3131
this.proxyUrl = ko.observable();
3232
this.bypassProxyHosts = ko.observable();
33+
this.requestTimeoutSeconds = ko.observable(5);
3334
this.connectOk = ko.observable(false);
3435
this.tryMessage = ko.observable();
3536

@@ -47,7 +48,8 @@ function(accUtils, ko, i18n, project) {
4748

4849
const settings = {
4950
proxyUrl: this.proxyUrl(),
50-
bypassHosts: this.bypassProxyHosts()
51+
bypassHosts: this.bypassProxyHosts(),
52+
timeout: this.requestTimeoutSeconds() * 1000
5153
};
5254

5355
window.api.ipc.invoke('try-network-settings', settings).then(success => {
@@ -60,7 +62,8 @@ function(accUtils, ko, i18n, project) {
6062
this.restartApp = () => {
6163
const settings = {
6264
proxyUrl: this.proxyUrl(),
63-
bypassHosts: this.bypassProxyHosts()
65+
bypassHosts: this.bypassProxyHosts(),
66+
timeout: this.requestTimeoutSeconds() * 1000
6467
};
6568

6669
// this will restart the app with success or failure, so no need to close.

webui/src/js/viewModels/user-settings-dialog.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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';
77

88
define(['accUtils', 'knockout', 'utils/observable-properties', 'utils/i18n', 'ojs/ojarraydataprovider', 'models/wkt-project',
99
'utils/wkt-logger', 'ojs/ojknockout', 'ojs/ojinputtext', 'ojs/ojlabel', 'ojs/ojbutton', 'ojs/ojdialog', 'ojs/ojformlayout',
10-
'ojs/ojswitch', 'ojs/ojselectsingle', 'ojs/ojvalidationgroup'],
10+
'ojs/ojswitch', 'ojs/ojselectsingle', 'ojs/ojvalidationgroup', 'ojs/ojinputnumber'],
1111
function(accUtils, ko, utils, i18n, ArrayDataProvider, project, wktLogger) {
1212
function UserSettingsDialogModel(payload) {
1313

@@ -46,6 +46,8 @@ function(accUtils, ko, utils, i18n, ArrayDataProvider, project, wktLogger) {
4646
this.consoleLogLevel = ko.observable(payload.defaults.level);
4747
this.fileLogLevel = ko.observable(payload.defaults.level);
4848
this.fileLogDir = ko.observable(payload.defaults.logDir);
49+
this.connectivityTestTimeoutSeconds = ko.observable(payload.defaults.connectivityTestTimeoutMilliseconds / 1000);
50+
this.internalConnectivityTestTimeoutMilliseconds = ko.observable(payload.defaults.connectivityTestTimeoutMilliseconds);
4951
this.skipQuickstart = ko.observable(false);
5052

5153
this.loadUserSettings = () => {
@@ -74,6 +76,10 @@ function(accUtils, ko, utils, i18n, ArrayDataProvider, project, wktLogger) {
7476
}
7577
}
7678

79+
if ('connectivityTestTimeoutMilliseconds' in this.userSettings) {
80+
this.connectivityTestTimeoutSeconds(this.userSettings.connectivityTestTimeoutMilliseconds / 1000);
81+
}
82+
7783
if ('skipQuickstartAtStartup' in this.userSettings) {
7884
this.skipQuickstart(this.userSettings.skipQuickstartAtStartup);
7985
}
@@ -91,6 +97,11 @@ function(accUtils, ko, utils, i18n, ArrayDataProvider, project, wktLogger) {
9197
this._storeSetting('logging.file.level', this.fileLogLevel, payload.defaults.level);
9298
this._storeSetting('logging.file.logDir', this.fileLogDir, payload.defaults.level);
9399
this._storeSetting('logging.console.level', this.consoleLogLevel, payload.defaults.level);
100+
if (this.connectivityTestTimeoutSeconds() >= 0) {
101+
this.internalConnectivityTestTimeoutMilliseconds(this.connectivityTestTimeoutSeconds() * 1000);
102+
this._storeSetting('connectivityTestTimeoutMilliseconds',
103+
this.internalConnectivityTestTimeoutMilliseconds, payload.defaults.connectivityTestTimeoutMilliseconds);
104+
}
94105
this._storeSetting('skipQuickstartAtStartup', this.skipQuickstart, false);
95106
};
96107

webui/src/js/views/network-page.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!--
2-
Copyright (c) 2021, Oracle and/or its affiliates.
2+
Copyright (c) 2021, 2022, Oracle and/or its affiliates.
33
Licensed under The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
44
-->
5-
<div class="wkt-dialog-content" id="projectSettings">
5+
<div class="wkt-dialog-content" id="networkSettings">
66
<h6><oj-bind-text value="[[labelMapper('title')]]"></oj-bind-text></h6>
77

88
<div class="oj-panel wkt-notop wkt-dialog-middle">
@@ -17,6 +17,11 @@ <h6><oj-bind-text value="[[labelMapper('title')]]"></oj-bind-text></h6>
1717
value="{{bypassProxyHosts}}"
1818
help.instruction="[[settingsLabelMapper('bypass-proxy-hosts-help')]]">
1919
</oj-input-text>
20+
<oj-input-number label-hint="[[settingsLabelMapper('startup-connectivity-timeout-label')]]"
21+
min="1" max="60" step="1"
22+
value="{{requestTimeoutSeconds}}"
23+
help.instruction="[[settingsLabelMapper('startup-connectivity-timeout-help')]]">
24+
</oj-input-number>
2025
<div class="wkt-network-try-block">
2126
<oj-button chroming="callToAction" on-oj-action="[[tryConnect]]">
2227
<span><oj-bind-text value="[[labelMapper('button-connect')]]"></oj-bind-text></span>

webui/src/js/views/user-settings-dialog.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
Copyright (c) 2021, Oracle and/or its affiliates.
2+
Copyright (c) 2021, 2022, Oracle and/or its affiliates.
33
Licensed under The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
44
-->
55
<oj-dialog id="userSettingsDialog" class="wkt-user-settings-dialog" initial-visibility="show">
@@ -46,6 +46,17 @@ <h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('logging-section-t
4646
</oj-form-layout>
4747
</div>
4848

49+
<div class="oj-panel">
50+
<h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('startup-connectivity-test-title')]]"></oj-bind-text></h6>
51+
<oj-form-layout max-columns="1" direction="row">
52+
<oj-input-number label-hint="[[labelMapper('startup-connectivity-timeout-label')]]"
53+
min="1" max="60" step="1"
54+
value="{{connectivityTestTimeoutSeconds}}"
55+
help.instruction="[[labelMapper('startup-connectivity-timeout-help')]]">
56+
</oj-input-number>
57+
</oj-form-layout>
58+
</div>
59+
4960
<div class="oj-panel">
5061
<h6 class="wkt-subheading"><oj-bind-text value="[[labelMapper('quickstart-section-title')]]"></oj-bind-text></h6>
5162
<oj-form-layout max-columns="1" direction="row">

0 commit comments

Comments
 (0)