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 0a04fad commit 3ffb36a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
4 changes: 1 addition & 3 deletions frontend/src/System/Updates/Updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Updates extends Component {
items,
isInstallingUpdate,
updateMechanism,
isDocker,
updateMechanismMessage,
shortDateFormat,
longDateFormat,
Expand Down Expand Up @@ -71,7 +70,7 @@ class Updates extends Component {
hasUpdateToInstall &&
<div className={styles.messageContainer}>
{
(updateMechanism === 'builtIn' || updateMechanism === 'script') && !isDocker ?
updateMechanism === 'builtIn' || updateMechanism === 'script' ?
<SpinnerButton
className={styles.updateAvailable}
kind={kinds.PRIMARY}
Expand Down Expand Up @@ -239,7 +238,6 @@ Updates.propTypes = {
generalSettingsError: PropTypes.object,
items: PropTypes.array.isRequired,
isInstallingUpdate: PropTypes.bool.isRequired,
isDocker: PropTypes.bool.isRequired,
updateMechanism: PropTypes.string,
updateMechanismMessage: PropTypes.string,
shortDateFormat: PropTypes.string.isRequired,
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/System/Updates/UpdatesConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ function createMapStateToProps() {
(state) => state.system.updates,
(state) => state.settings.general,
createUISettingsSelector(),
createSystemStatusSelector(),
createCommandExecutingSelector(commandNames.APPLICATION_UPDATE),
(
currentVersion,
status,
updates,
generalSettings,
uiSettings,
systemStatus,
isInstallingUpdate
) => {
const {
Expand All @@ -45,7 +43,6 @@ function createMapStateToProps() {
generalSettingsError: generalSettings.error,
items,
isInstallingUpdate,
isDocker: systemStatus.isDocker,
updateMechanism: generalSettings.item.updateMechanism,
updateMechanismMessage: status.packageUpdateMechanismMessage,
shortDateFormat: uiSettings.shortDateFormat,
Expand Down
33 changes: 22 additions & 11 deletions src/NzbDrone.Core.Test/UpdateTests/UpdateServiceFixture.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,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 3ffb36a

Please sign in to comment.