summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDixsie Wolmers <dixsiew@gmail.com>2019-09-26 14:00:04 -0500
committerGunnar Mills <gmills@us.ibm.com>2019-10-07 20:32:46 +0000
commitfdcb35ee7d351cac68820247d7538cc3e1ebe3bb (patch)
treeb7de5a6c62022e55313a4463e40486587f079be0 /app
parentbb3714ef39f16f9329aefdf88d12aab1621fabea (diff)
downloadphosphor-webui-fdcb35ee7d351cac68820247d7538cc3e1ebe3bb.tar.gz
phosphor-webui-fdcb35ee7d351cac68820247d7538cc3e1ebe3bb.zip
Fix date and time settings bug
When time mode is initially set to Manual from NTP, NTP service is disabled and the NTP service is stopping but not stopped, setting time will return an error. There are no response messages to notify when NTP is completely stopped. To work around, a timeout is set to allow NTP to fully stop before saving date/time changes. https://github.com/openbmc/phosphor-time-manager/blob/master/README.md Signed-off-by: Dixsie Wolmers <dixsiew@gmail.com> Change-Id: Icb86dfe339a10567aecf9aedd9b0dd696937a398
Diffstat (limited to 'app')
-rw-r--r--app/configuration/controllers/date-time-controller.html2
-rw-r--r--app/configuration/controllers/date-time-controller.js127
2 files changed, 72 insertions, 57 deletions
diff --git a/app/configuration/controllers/date-time-controller.html b/app/configuration/controllers/date-time-controller.html
index d84d278..47c7ced 100644
--- a/app/configuration/controllers/date-time-controller.html
+++ b/app/configuration/controllers/date-time-controller.html
@@ -59,7 +59,7 @@
</div>
</fieldset>
<div class="time__submit-wrapper">
- <button type="button" class="btn btn-primary" ng-click="setTime()">Save settings</button>
+ <button type="button" class="btn btn-primary" ng-click="saveDateTimeSettings()">Save settings</button>
<button type="button" class="btn btn-secondary" ng-click="refresh()">Cancel</button>
</div>
</form>
diff --git a/app/configuration/controllers/date-time-controller.js b/app/configuration/controllers/date-time-controller.js
index 2f4fd3d..d678ab4 100644
--- a/app/configuration/controllers/date-time-controller.js
+++ b/app/configuration/controllers/date-time-controller.js
@@ -10,8 +10,8 @@ window.angular && (function(angular) {
'use strict';
angular.module('app.configuration').controller('dateTimeController', [
- '$scope', '$window', 'APIUtils', '$route', '$q', 'toastService',
- function($scope, $window, APIUtils, $route, $q, toastService) {
+ '$scope', 'APIUtils', '$route', '$q', 'toastService', '$timeout',
+ function($scope, APIUtils, $route, $q, toastService, $timeout) {
$scope.bmc = {};
// Only used when the owner is "Split"
$scope.host = {};
@@ -73,69 +73,84 @@ window.angular && (function(angular) {
console.log(JSON.stringify(error));
});
- var promises = [
- getTimePromise,
- getNTPPromise,
- ];
+ var promises = [getTimePromise, getNTPPromise];
$q.all(promises).finally(function() {
$scope.loading = false;
});
- $scope.setTime = function() {
+ /**
+ * https://github.com/openbmc/phosphor-time-manager/blob/master/README.md#special-note-on-changing-ntp-setting
+ * When time mode is initially set to Manual from NTP,
+ * NTP service is disabled and the NTP service is
+ * stopping but not stopped, setting time will return an error.
+ * There are no responses from backend to notify when NTP is stopped.
+ * To work around, a timeout is set to allow NTP to fully stop
+ * TODO: remove timeout if backend solves
+ * https://github.com/openbmc/openbmc/issues/3459
+ */
+ $scope.saveDateTimeSettings = function() {
$scope.loading = true;
- var promises = [setTimeMode(), setTimeOwner(), setNTPServers()];
-
- $q.all(promises).then(
- function() {
- // Have to set the time mode and time owner first to avoid a
- // insufficient permissions if the time mode or time owner had
- // changed.
- var manual_promises = [];
- if ($scope.time.mode == 'Manual') {
- // If owner is 'Split' set both.
- // If owner is 'Host' set only it.
- // Else set BMC only. See:
- // https://github.com/openbmc/phosphor-time-manager/blob/master/README.md
- if ($scope.time.owner != 'Host') {
- manual_promises.push(
- setBMCTime($scope.bmc.date.getTime() * 1000));
- }
- // Even though we are setting Host time, we are setting from
- // the BMC date and time fields labeled "BMC and Host Time"
- // currently.
- if ($scope.time.owner == 'Host') {
- manual_promises.push(
- setHostTime($scope.bmc.date.getTime() * 1000));
- }
- }
- // Set the Host if Split even if NTP. In split mode, the host has
- // its own date and time field. Set from it.
- if ($scope.time.owner == 'Split') {
- manual_promises.push(
- setHostTime($scope.host.date.getTime() * 1000));
- }
-
- $q.all(manual_promises)
- .then(
- function() {
- toastService.success('Date and time settings saved');
- },
- function(errors) {
- console.log(JSON.stringify(errors));
- toastService.error(
- 'Date and time settings could not be saved');
- })
- .finally(function() {
- $scope.loading = false;
- });
- },
- function(errors) {
- console.log(JSON.stringify(errors));
- toastService.error('Date and time settings could not be saved');
+ if ($scope.time.mode == 'Manual' || $scope.time.owner == 'Split') {
+ setTimeMode()
+ .then(setTimeOwner)
+ .then(setNTPServers)
+ .then($timeout(setDateTime, 20000));
+ } else {
+ setTimeMode()
+ .then(setTimeOwner)
+ .then(setNTPServers)
+ .then(
+ function() {
+ toastService.success('Date and time settings saved');
+ },
+ function(errors) {
+ console.log(JSON.stringify(errors));
+ toastService.error(
+ 'Date and time settings could not be saved');
+ })
+ .finally(function() {
+ $scope.loading = false;
+ });
+ }
+ };
+
+ const setDateTime = function() {
+ var manualPromises = [];
+ if ($scope.time.mode == 'Manual') {
+ // If owner is 'Split' set both.
+ // If owner is 'Host' set only it.
+ if ($scope.time.owner != 'Host') {
+ manualPromises.push(setBMCTime($scope.bmc.date.getTime() * 1000));
+ }
+ // Even though we are setting Host time, we are setting from
+ // the BMC date and time fields labeled "BMC and Host Time"
+ // currently.
+ if ($scope.time.owner == 'Host') {
+ manualPromises.push(setHostTime($scope.bmc.date.getTime() * 1000));
+ }
+ }
+ // Set the Host if Split even if NTP. In split mode, the host has
+ // its own date and time field set from it.
+ if ($scope.time.owner == 'Split') {
+ manualPromises.push(setHostTime($scope.host.date.getTime() * 1000));
+ }
+
+ $q.all(manualPromises)
+ .then(
+ function() {
+ toastService.success('Date and time settings saved');
+ },
+ function(errors) {
+ console.log(JSON.stringify(errors));
+ toastService.error(
+ 'Date and time settings could not be saved');
+ })
+ .finally(function() {
$scope.loading = false;
});
};
+
$scope.refresh = function() {
$route.reload();
};
OpenPOWER on IntegriCloud