From 3ffb36a2dfae5611f4c7561f1fbb83bc67bdfb19 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 8 Aug 2023 17:35:13 -0700 Subject: [PATCH] Fixed: Don't block updates under docker unless configured in package_info (cherry picked from commit 5a7e34e291c2715aa67161e5c455d25e80f498df) --- frontend/src/System/Updates/Updates.js | 4 +-- .../src/System/Updates/UpdatesConnector.js | 3 -- .../UpdateTests/UpdateServiceFixture.cs | 33 ++++++++++++------- .../Update/InstallUpdateService.cs | 8 ++--- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/frontend/src/System/Updates/Updates.js b/frontend/src/System/Updates/Updates.js index 1f53e1b74..48260df82 100644 --- a/frontend/src/System/Updates/Updates.js +++ b/frontend/src/System/Updates/Updates.js @@ -31,7 +31,6 @@ class Updates extends Component { items, isInstallingUpdate, updateMechanism, - isDocker, updateMechanismMessage, shortDateFormat, longDateFormat, @@ -71,7 +70,7 @@ class Updates extends Component { hasUpdateToInstall &&
{ - (updateMechanism === 'builtIn' || updateMechanism === 'script') && !isDocker ? + updateMechanism === 'builtIn' || updateMechanism === 'script' ? state.system.updates, (state) => state.settings.general, createUISettingsSelector(), - createSystemStatusSelector(), createCommandExecutingSelector(commandNames.APPLICATION_UPDATE), ( currentVersion, @@ -26,7 +25,6 @@ function createMapStateToProps() { updates, generalSettings, uiSettings, - systemStatus, isInstallingUpdate ) => { const { @@ -45,7 +43,6 @@ function createMapStateToProps() { generalSettingsError: generalSettings.error, items, isInstallingUpdate, - isDocker: systemStatus.isDocker, updateMechanism: generalSettings.item.updateMechanism, updateMechanismMessage: status.packageUpdateMechanismMessage, shortDateFormat: uiSettings.shortDateFormat, diff --git a/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs b/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs index cf7b0e8f5..4029c0769 100644 --- a/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs +++ b/src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs @@ -90,17 +90,6 @@ namespace NzbDrone.Core.Test.UpdateTests .Returns(true); } - [Test] - public void should_not_update_if_inside_docker() - { - Mocker.GetMock().Setup(x => x.IsDocker).Returns(true); - - Subject.Execute(new ApplicationUpdateCommand()); - - Mocker.GetMock() - .Verify(c => c.Start(It.IsAny(), It.Is(s => s.StartsWith("12")), null, null, null), Times.Never()); - } - [Test] public void should_delete_sandbox_before_update_if_folder_exists() { @@ -338,6 +327,28 @@ namespace NzbDrone.Core.Test.UpdateTests .Verify(v => v.SaveConfigDictionary(It.Is>(d => d.ContainsKey("Branch") && (string)d["Branch"] == "fake")), Times.Once()); } + [Test] + public void should_not_update_with_built_in_updater_inside_docker_container() + { + Mocker.GetMock().Setup(x => x.PackageUpdateMechanism).Returns(UpdateMechanism.Docker); + + Subject.Execute(new ApplicationUpdateCommand()); + + Mocker.GetMock() + .Verify(c => c.Start(It.IsAny(), It.Is(s => s.StartsWith("12")), null, null, null), Times.Never()); + } + + [Test] + public void should_not_update_with_built_in_updater_when_external_updater_is_configured() + { + Mocker.GetMock().Setup(x => x.IsExternalUpdateMechanism).Returns(true); + + Subject.Execute(new ApplicationUpdateCommand()); + + Mocker.GetMock() + .Verify(c => c.Start(It.IsAny(), It.Is(s => s.StartsWith("12")), null, null, null), Times.Never()); + } + [TearDown] public void TearDown() { diff --git a/src/NzbDrone.Core/Update/InstallUpdateService.cs b/src/NzbDrone.Core/Update/InstallUpdateService.cs index 06c364894..c2244e81e 100644 --- a/src/NzbDrone.Core/Update/InstallUpdateService.cs +++ b/src/NzbDrone.Core/Update/InstallUpdateService.cs @@ -237,15 +237,15 @@ namespace NzbDrone.Core.Update return null; } - if (_osInfo.IsDocker) + if (OsInfo.IsNotWindows && !_configFileProvider.UpdateAutomatically && updateTrigger != CommandTrigger.Manual) { - _logger.ProgressDebug("Updating is disabled inside a docker container. Please update the container image."); + _logger.ProgressDebug("Auto-update not enabled, not installing available update."); return null; } - if (OsInfo.IsNotWindows && !_configFileProvider.UpdateAutomatically && updateTrigger != CommandTrigger.Manual) + if (_configFileProvider.UpdateMechanism == UpdateMechanism.BuiltIn && _deploymentInfoProvider.PackageUpdateMechanism == UpdateMechanism.Docker) { - _logger.ProgressDebug("Auto-update not enabled, not installing available update."); + _logger.ProgressDebug("Built-In updater disabled inside a docker container. Please update the container image."); return null; }