From 7a59f142d7d600f80047edfb6df36cd5799db42b Mon Sep 17 00:00:00 2001 From: Mohammad Rafi Date: Fri, 17 Oct 2025 17:30:26 -0400 Subject: [PATCH 1/2] removing update install source custom action --- .../suites/agent-package/upgrade_test.go | 1 + .../AgentCustomActions/CustomAction.cs | 6 -- .../CustomActions.Tests.csproj | 1 - .../InstallSource/InstallSourceTests.cs | 56 --------------- .../CustomActions/CustomActions.csproj | 1 - .../UpdateInstallSourceCustomAction.cs | 71 ------------------- .../Datadog Agent/AgentCustomActions.cs | 19 ----- 7 files changed, 1 insertion(+), 154 deletions(-) delete mode 100644 tools/windows/DatadogAgentInstaller/CustomActions.Tests/InstallSource/InstallSourceTests.cs delete mode 100644 tools/windows/DatadogAgentInstaller/CustomActions/UpdateInstallSourceCustomAction.cs diff --git a/test/new-e2e/tests/installer/windows/suites/agent-package/upgrade_test.go b/test/new-e2e/tests/installer/windows/suites/agent-package/upgrade_test.go index 32eb538e9b0671..9449439173aa7a 100644 --- a/test/new-e2e/tests/installer/windows/suites/agent-package/upgrade_test.go +++ b/test/new-e2e/tests/installer/windows/suites/agent-package/upgrade_test.go @@ -574,6 +574,7 @@ func (s *testAgentUpgradeSuite) TestUpgradeWithLocalSystemUser() { // TestDowngradeWithMissingInstallSource tests that a downgrade will succeed even if the original install source is missing func (s *testAgentUpgradeSuite) TestDowngradeWithMissingInstallSource() { + s.T().Skip("Skipping test due to removal of update install source custom action") // Arrange s.setAgentConfig() s.installCurrentAgentVersion() diff --git a/tools/windows/DatadogAgentInstaller/AgentCustomActions/CustomAction.cs b/tools/windows/DatadogAgentInstaller/AgentCustomActions/CustomAction.cs index 9ca2e88a480099..00a8e125c81653 100644 --- a/tools/windows/DatadogAgentInstaller/AgentCustomActions/CustomAction.cs +++ b/tools/windows/DatadogAgentInstaller/AgentCustomActions/CustomAction.cs @@ -59,12 +59,6 @@ public static ActionResult SetupInstaller(Session session) return Datadog.CustomActions.SetupInstallerCustomAction.SetupInstaller(session); } - [CustomAction] - public static ActionResult UpdateInstallSource(Session session) - { - return Datadog.CustomActions.UpdateInstallSourceCustomAction.UpdateInstallSource(session); - } - [CustomAction] public static ActionResult ReportFailure(Session session) { diff --git a/tools/windows/DatadogAgentInstaller/CustomActions.Tests/CustomActions.Tests.csproj b/tools/windows/DatadogAgentInstaller/CustomActions.Tests/CustomActions.Tests.csproj index 63f593a162a219..10eeeff9b8ea89 100644 --- a/tools/windows/DatadogAgentInstaller/CustomActions.Tests/CustomActions.Tests.csproj +++ b/tools/windows/DatadogAgentInstaller/CustomActions.Tests/CustomActions.Tests.csproj @@ -70,7 +70,6 @@ - diff --git a/tools/windows/DatadogAgentInstaller/CustomActions.Tests/InstallSource/InstallSourceTests.cs b/tools/windows/DatadogAgentInstaller/CustomActions.Tests/InstallSource/InstallSourceTests.cs deleted file mode 100644 index 2ad789a85bc1ee..00000000000000 --- a/tools/windows/DatadogAgentInstaller/CustomActions.Tests/InstallSource/InstallSourceTests.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.IO; -using AutoFixture.Xunit2; -using CustomActions.Tests; -using Datadog.CustomActions; -using Datadog.CustomActions.Interfaces; -using FluentAssertions; -using Microsoft.Deployment.WindowsInstaller; -using Moq; -using Xunit; - -namespace CustomActions.Tests.InstallSource -{ - public class UpdateInstallSourceCustomActionTests : SessionTestBaseSetup - { - - [Fact] - public void UpdateInstallSource_WithFleetInstall_ShouldSkipAndReturnSuccess() - { - // Arrange - Session.Setup(s => s["FLEET_INSTALL"]).Returns("1"); - Session.Setup(s => s["DATABASE"]).Returns("C:\\test.msi"); - Session.Setup(s => s["PROJECTLOCATION"]).Returns("C:\\Program Files\\Datadog"); - - // Act - Call the actual custom action - var result = UpdateInstallSourceCustomAction.UpdateInstallSource(Session.Object); - - // Assert - result.Should().Be(ActionResult.Success); - // Verify that the fleet install property was checked - Session.Verify(s => s["FLEET_INSTALL"], Times.Once); - Session.Verify(s => s.RunCommand(It.IsAny(), It.IsAny()), Times.Never); - } - - [Fact] - public void UpdateInstallSource_WithFipsInstall_ShouldSkipAndReturnSuccess() - { - // Arrange - Session.Setup(s => s["FLEET_INSTALL"]).Returns("0"); - Session.Setup(s => s["AgentFlavor"]).Returns(Constants.FipsFlavor); - Session.Setup(s => s["DATABASE"]).Returns("C:\\test.msi"); - Session.Setup(s => s["PROJECTLOCATION"]).Returns("C:\\Program Files\\Datadog"); - - // Act - Call the actual custom action - var result = UpdateInstallSourceCustomAction.UpdateInstallSource(Session.Object); - - // Assert - result.Should().Be(ActionResult.Success); - // Verify that both properties were checked - Session.Verify(s => s["FLEET_INSTALL"], Times.Once); - Session.Verify(s => s["AgentFlavor"], Times.Once); - Session.Verify(s => s.RunCommand(It.IsAny(), It.IsAny()), Times.Never); - } - - } -} diff --git a/tools/windows/DatadogAgentInstaller/CustomActions/CustomActions.csproj b/tools/windows/DatadogAgentInstaller/CustomActions/CustomActions.csproj index 008bb4e8f751ec..96bdf044d9c618 100644 --- a/tools/windows/DatadogAgentInstaller/CustomActions/CustomActions.csproj +++ b/tools/windows/DatadogAgentInstaller/CustomActions/CustomActions.csproj @@ -96,7 +96,6 @@ - diff --git a/tools/windows/DatadogAgentInstaller/CustomActions/UpdateInstallSourceCustomAction.cs b/tools/windows/DatadogAgentInstaller/CustomActions/UpdateInstallSourceCustomAction.cs deleted file mode 100644 index 21bed079086979..00000000000000 --- a/tools/windows/DatadogAgentInstaller/CustomActions/UpdateInstallSourceCustomAction.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Datadog.CustomActions.Extensions; -using Datadog.CustomActions.Interfaces; -using Datadog.CustomActions.Native; -using Datadog.CustomActions.Rollback; -using Microsoft.Deployment.WindowsInstaller; -using System; -using System.Diagnostics; -using System.IO; - -namespace Datadog.CustomActions -{ - public class UpdateInstallSourceCustomAction - { - /// - /// Update the install source on non fleet deployments of MSI. - /// - /// - /// This function will call the updateRegistryInstallSource function of the - // installer. - /// - /// The session object. - /// - public static ActionResult UpdateInstallSource(ISession session) - { - var msiPath = session.Property("DATABASE"); - // get installer path - var installerPath = session.Property("PROJECTLOCATION"); - installerPath = Path.Combine(installerPath, "bin", "datadog-installer.exe"); - - // check if this is a fleet install - // fleet install runs the MSI from the package dir so the install source is already set - var fleetInstall = session.Property("FLEET_INSTALL"); - if (!string.IsNullOrEmpty(fleetInstall) && fleetInstall == "1") - { - session.Log("Skipping install source update as this is a FLEET install."); - return ActionResult.Success; - } - - // check if this is a FIPS install - var agentFlavor = session.Property("AgentFlavor"); - if (!string.IsNullOrEmpty(agentFlavor) && agentFlavor == Constants.FipsFlavor) - { - session.Log("Skipping install source update as this is a FIPS install."); - return ActionResult.Success; - } - - // verify that msiPath is a valid path - if (!File.Exists(msiPath)) - { - session.Log($"msiPath does not exist: {msiPath}"); - return ActionResult.Failure; - } - - // run the package-command datadog-agent updateRegistryInstallSource - using (var proc = session.RunCommand(installerPath, $"package-command datadog-agent updateRegistryInstallSource")) - { - if (proc.ExitCode != 0) - { - session.Log($"install script exited with code: {proc.ExitCode}"); - return ActionResult.Failure; - } - return ActionResult.Success; - } - } - - public static ActionResult UpdateInstallSource(Session session) - { - return UpdateInstallSource(new SessionWrapper(session)); - } - } -} diff --git a/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentCustomActions.cs b/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentCustomActions.cs index 32c85113cf953f..a53b7e15376efc 100644 --- a/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentCustomActions.cs +++ b/tools/windows/DatadogAgentInstaller/WixSetup/Datadog Agent/AgentCustomActions.cs @@ -20,8 +20,6 @@ public class AgentCustomActions public ManagedAction SetupInstaller { get; set; } - public ManagedAction UpdateInstallSource { get; set; } - public ManagedAction EnsureGeneratedFilesRemoved { get; } public ManagedAction WriteConfig { get; } @@ -322,23 +320,6 @@ public AgentCustomActions() .SetProperties( "PROJECTLOCATION=[PROJECTLOCATION], FLEET_INSTALL=[FLEET_INSTALL], DATABASE=[DATABASE]"); - UpdateInstallSource = new CustomAction( - new Id(nameof(UpdateInstallSource)), - CustomActions.UpdateInstallSource, - Return.check, - // The built-in RegisterProduct action normally sets the install source, - // so our action must come after it to take effect. - When.Before, - Step.InstallFinalize, - Conditions.FirstInstall | Conditions.Upgrading - ) - { - Execute = Execute.deferred, - Impersonate = false - } - .SetProperties( - "PROJECTLOCATION=[PROJECTLOCATION], FLEET_INSTALL=[FLEET_INSTALL], DATABASE=[DATABASE], AgentFlavor=[AgentFlavor]"); - // Cleanup leftover files on uninstall CleanupOnUninstall = new CustomAction( new Id(nameof(CleanupOnUninstall)), From 89e3b88b4f8fb33994220e90a473e9cd82b100a3 Mon Sep 17 00:00:00 2001 From: Mohammad Rafi Date: Mon, 20 Oct 2025 10:03:15 -0400 Subject: [PATCH 2/2] removing old changelog --- ...-automation-msi-update-install-source-edbfaccf24bece0f.yaml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 releasenotes/notes/fleet-automation-msi-update-install-source-edbfaccf24bece0f.yaml diff --git a/releasenotes/notes/fleet-automation-msi-update-install-source-edbfaccf24bece0f.yaml b/releasenotes/notes/fleet-automation-msi-update-install-source-edbfaccf24bece0f.yaml deleted file mode 100644 index 49e77f8bc4a3d4..00000000000000 --- a/releasenotes/notes/fleet-automation-msi-update-install-source-edbfaccf24bece0f.yaml +++ /dev/null @@ -1,3 +0,0 @@ -enhancements: - - | - When installing the Agent through the MSI, the install source is now updated to the Installer stable package.