diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index a28047001..06356240d 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -75,6 +75,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, self._console_logger = None + self._get_throttled = lambda: False + def initialize(self): self._console_logger = logging.getLogger("octoprint.plugins.softwareupdate.console") @@ -98,6 +100,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, self._console_logger.setLevel(logging.DEBUG) self._console_logger.propagate = False + helpers = self._plugin_manager.get_helpers("pi_support", "get_throttled") + if helpers and "get_throttled" in helpers: + self._get_throttled = helpers["get_throttled"] + def on_after_startup(self): self._check_environment() self.get_current_versions() @@ -567,6 +573,12 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, @restricted_access @admin_permission.require(403) def perform_update(self): + throttled = self._get_throttled() + if throttled and isinstance(throttled, dict) and throttled.get("current_issue", False): + # currently throttled, we refuse to run + return flask.make_response("System is currently throttled, refusing to update " + "anything due to possible stability issues", 409) + if self._printer.is_printing() or self._printer.is_paused(): # do not update while a print job is running return flask.make_response("Printer is currently printing or paused", 409) diff --git a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js index 695302d45..249eb8937 100644 --- a/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js +++ b/src/octoprint/plugins/softwareupdate/static/js/softwareupdate.js @@ -5,6 +5,11 @@ $(function() { self.loginState = parameters[0]; self.printerState = parameters[1]; self.settings = parameters[2]; + + // optional + + self.piSupport = parameters[3]; // might be null! + self.popup = undefined; self.updateInProgress = false; @@ -51,7 +56,7 @@ $(function() { }); self.enableUpdate = ko.pureComputed(function() { - return !self.updateInProgress && self.environmentSupported(); + return !self.updateInProgress && self.environmentSupported() && !self.printerState.isPrinting() && !self.throttled(); }); self.enable_configSave = ko.pureComputed(function() { @@ -91,6 +96,10 @@ $(function() { return _.filter(self.versions.items(), function(info) { return info.updateAvailable && info.updatePossible; }); }); + self.throttled = ko.pureComputed(function() { + return self.piSupport && self.piSupport.currentIssue(); + }); + self.onUserLoggedIn = function() { self.performCheck(); }; @@ -484,36 +493,46 @@ $(function() { type: "error" }); self._updateClicked = false; - } else { - var html = "
" + gettext("This will update the following components and restart the server:") + "
"; - html += "" + gettext("Be sure to read through any linked release notes, especially those for OctoPrint since they might contain important information you need to know before upgrading.") + "
" - + "" + gettext("This action may disrupt any ongoing print jobs.") + "
" - + "" + gettext("Depending on your printer's controller and general setup, restarting OctoPrint may cause your printer to be reset.") + "
" - + "" + gettext("Are you sure you want to proceed?") + "
"; - showConfirmationDialog({ - title: gettext("Are you sure you want to update now?"), - html: html, - proceed: gettext("Proceed"), - onproceed: function() { - self.performUpdate((force === true), - _.map(items, function(info) { return info.key })); - }, - onclose: function() { - self._updateClicked = false; - } - }); + return; } + if (self.piSupport && self.piSupport.currentIssue()) { + self._showPopup({ + title: gettext("Can't update while throttled"), + text: gettext("Your system is currently throttled. OctoPrint refuses to run updates while in this state due to possible stability issues."), + type: "error" + }); + self._updateClicked = false; + return; + } + + var html = "" + gettext("This will update the following components and restart the server:") + "
"; + html += "" + gettext("Be sure to read through any linked release notes, especially those for OctoPrint since they might contain important information you need to know before upgrading.") + "
" + + "" + gettext("This action may disrupt any ongoing print jobs.") + "
" + + "" + gettext("Depending on your printer's controller and general setup, restarting OctoPrint may cause your printer to be reset.") + "
" + + "" + gettext("Are you sure you want to proceed?") + "
"; + showConfirmationDialog({ + title: gettext("Are you sure you want to update now?"), + html: html, + proceed: gettext("Proceed"), + onproceed: function() { + self.performUpdate((force === true), + _.map(items, function(info) { return info.key })); + }, + onclose: function() { + self._updateClicked = false; + } + }); }; self._showWorkingDialog = function(title) { @@ -795,7 +814,8 @@ $(function() { OCTOPRINT_VIEWMODELS.push({ construct: SoftwareUpdateViewModel, - dependencies: ["loginStateViewModel", "printerStateViewModel", "settingsViewModel"], + dependencies: ["loginStateViewModel", "printerStateViewModel", "settingsViewModel", "piSupportViewModel"], + optional: ["piSupportViewModel"], elements: ["#settings_plugin_softwareupdate", "#softwareupdate_confirmation_dialog", "#wizard_plugin_softwareupdate"] }); }); diff --git a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 index 0871b6fc8..9be154fe6 100644 --- a/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 +++ b/src/octoprint/plugins/softwareupdate/templates/softwareupdate_settings.jinja2 @@ -32,6 +32,26 @@ Please take a look at this FAQ entry on how to proceed. {% endtrans %} ++ OctoPrint is running on a throttled system, updates are disabled. +
++ To reduce the likelihood of running into update problems on throttled and hence potentially unstable systems + as seen in the past, OctoPrint doesn't support updating under such conditions. Please fix the current issue + before trying to update. Take a look at the displayed warning in the navigation bar to learn about what is + wrong and to get hints on how to solve the problem. +
+{% endtrans %}+ OctoPrint is currently printing, updates are disabled. +
++ Running updates is not supported while printing in order to not risk any kind of disruption to the print job. + Please let the print finish before trying to update. +
+{% endtrans %}