Skip to content

Commit

Permalink
Fixed: Don't block updates under docker unless configured in package_…
Browse files Browse the repository at this point in the history
…info

(cherry picked from commit 5a7e34e291c2715aa67161e5c455d25e80f498df)
  • Loading branch information
markus101 authored and mynameisbogdan committed Aug 17, 2023
1 parent b322d84 commit caf4a18
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
33 changes: 22 additions & 11 deletions src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs
Expand Up @@ -90,17 +90,6 @@ private void GivenInstallScript(string path)
.Returns(true);
}

[Test]
public void should_not_update_if_inside_docker()
{
Mocker.GetMock<IOsInfo>().Setup(x => x.IsDocker).Returns(true);

Subject.Execute(new ApplicationUpdateCommand());

Mocker.GetMock<IProcessProvider>()
.Verify(c => c.Start(It.IsAny<string>(), It.Is<string>(s => s.StartsWith("12")), null, null, null), Times.Never());
}

[Test]
public void should_delete_sandbox_before_update_if_folder_exists()
{
Expand Down Expand Up @@ -338,6 +327,28 @@ public void should_switch_to_branch_specified_in_updatepackage()
.Verify(v => v.SaveConfigDictionary(It.Is<Dictionary<string, object>>(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<IDeploymentInfoProvider>().Setup(x => x.PackageUpdateMechanism).Returns(UpdateMechanism.Docker);

Subject.Execute(new ApplicationUpdateCommand());

Mocker.GetMock<IProcessProvider>()
.Verify(c => c.Start(It.IsAny<string>(), It.Is<string>(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<IDeploymentInfoProvider>().Setup(x => x.IsExternalUpdateMechanism).Returns(true);

Subject.Execute(new ApplicationUpdateCommand());

Mocker.GetMock<IProcessProvider>()
.Verify(c => c.Start(It.IsAny<string>(), It.Is<string>(s => s.StartsWith("12")), null, null, null), Times.Never());
}

[TearDown]
public void TearDown()
{
Expand Down
8 changes: 4 additions & 4 deletions src/NzbDrone.Core/Update/InstallUpdateService.cs
Expand Up @@ -238,15 +238,15 @@ private UpdatePackage GetUpdatePackage(CommandTrigger updateTrigger)
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;
}

Expand Down

0 comments on commit caf4a18

Please sign in to comment.