Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitlab/e2e_install_packages/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,6 @@ new-e2e-installer-windows:
- EXTRA_PARAMS: --run "TestAgentMSIInstallsDotnetLibrary/TestMSISkipRollbackIfInstalled$"
- EXTRA_PARAMS: --run "TestAgentMSIInstallsDotnetLibrary/TestUninstallKeepsLibrary$"
- EXTRA_PARAMS: --run "TestAgentMSIInstallsDotnetLibrary/TestUninstallScript$"
- EXTRA_PARAMS: --run "TestAgentMSIInstallsDotnetLibrary/TestMSIPurge$"
- EXTRA_PARAMS: --run "TestAgentScriptInstallsDotnetLibrary/TestInstallFromScript$"
- EXTRA_PARAMS: --run "TestAgentScriptInstallsDotnetLibrary/TestScriptThenRemoteUpgrade$"
12 changes: 9 additions & 3 deletions pkg/fleet/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,15 @@ func (i *installerImpl) Purge(ctx context.Context) {
// failing the uninstall.
// We can't workaround this by moving removePackage to the end of purge,
// as the daemon may be running and holding locks on files that need to be removed.
err = i.hooks.PreRemove(ctx, packageDatadogAgent, packages.PackageTypeOCI, false)
if err != nil {
log.Warnf("could not remove agent: %v", err)
//
// Note: If DD_NO_AGENT_UNINSTALL is set, then the agent will not be uninstalled.
// This is used to prevent the agent from being uninstalled when purge is
// called from within the MSI.
if _, ok := os.LookupEnv("DD_NO_AGENT_UNINSTALL"); !ok {
Comment thread
jack0x2 marked this conversation as resolved.
Outdated
err = i.hooks.PreRemove(ctx, packageDatadogAgent, packages.PackageTypeOCI, false)
if err != nil {
log.Warnf("could not remove agent: %v", err)
}
}
// TODO: wont need this when Linux packages are merged
if runtime.GOOS != "windows" {
Expand Down
11 changes: 11 additions & 0 deletions releasenotes/notes/msi-oci-install-3c6825e3aaec79b0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Each section from every release note are combined when the
# CHANGELOG.rst is rendered. So the text needs to be worded so that
# it does not depend on any information only available in another
# section. This may mean repeating some details, but each section
# must be readable independently of the other.
#
# Each section note must be formatted as reStructuredText.
---
enhancements:
- |
Windows: Adds a PURGE argument to the MSI to remove all OCI packages during uninstallation.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s *testDotnetLibraryInstallSuiteWithoutIIS) TestInstallDotnetLibraryPackag
}

func (s *testDotnetLibraryInstallSuiteWithoutIIS) TestMSIInstallDotnetLibraryFailsWithoutIIS() {
version := "3.19.0-pipeline.67351320.beta.sha-c05ddfb1-1"
version := "3.19.0-pipeline.67351320.beta.sha-c05ddfb1"
Comment thread
jack0x2 marked this conversation as resolved.
s.Require().NoError(s.Installer().Install(
installerwindows.WithMSIArg("DD_APM_INSTRUMENTATION_ENABLED=iis"),
// TODO: remove override once image is published in prod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *testAgentMSIInstallsDotnetLibrary) TestInstallFromMSI() {
installerwindows.WithMSIArg("DD_APM_INSTRUMENTATION_ENABLED=iis"),
// TODO: remove override once image is published in prod
installerwindows.WithMSIArg("DD_INSTALLER_REGISTRY_URL=install.datad0g.com.internal.dda-testing.com"),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", version.PackageVersion())),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", version.Version())),
installerwindows.WithMSILogFile("install.log"),
)
// Start the IIS app to load the library
Expand Down Expand Up @@ -89,7 +89,7 @@ func (s *testAgentMSIInstallsDotnetLibrary) TestMSIThenRemoteUpgrade() {
// TODO: remove override once image is published in prod
// TODO: support DD_INSTALLER_REGISTRY_URL
installerwindows.WithMSIArg("DD_INSTALLER_REGISTRY_URL=install.datad0g.com.internal.dda-testing.com"),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", oldVersion.PackageVersion())),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", oldVersion.Version())),
installerwindows.WithMSILogFile("install.log"),
)

Expand Down Expand Up @@ -138,6 +138,7 @@ func (s *testAgentMSIInstallsDotnetLibrary) TestUpgradeWithMSI() {
// TODO: remove override once image is published in prod
// TODO: support DD_INSTALLER_REGISTRY_URL
installerwindows.WithMSIArg("DD_INSTALLER_REGISTRY_URL=install.datad0g.com.internal.dda-testing.com"),
// TODO: update to use Version() when stable is updated
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", oldVersion.PackageVersion())),
installerwindows.WithMSILogFile("install.log"),
)
Expand All @@ -157,7 +158,7 @@ func (s *testAgentMSIInstallsDotnetLibrary) TestUpgradeWithMSI() {
// TODO: remove override once image is published in prod
// TODO: support DD_INSTALLER_REGISTRY_URL
installerwindows.WithMSIArg("DD_INSTALLER_REGISTRY_URL=install.datad0g.com.internal.dda-testing.com"),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", newVersion.PackageVersion())),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", newVersion.Version())),
installerwindows.WithMSILogFile("upgrade.log"),
)

Expand Down Expand Up @@ -189,7 +190,7 @@ func (s *testAgentMSIInstallsDotnetLibrary) TestMSIRollbackRemovesLibrary() {
// TODO: remove override once image is published in prod
// TODO: support DD_INSTALLER_REGISTRY_URL
installerwindows.WithMSIArg("DD_INSTALLER_REGISTRY_URL=install.datad0g.com.internal.dda-testing.com"),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", version.PackageVersion())),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", version.Version())),
installerwindows.WithMSILogFile("install-rollback.log"),
installerwindows.WithMSIArg("WIXFAILWHENDEFERRED=1"),
)
Expand All @@ -213,6 +214,7 @@ func (s *testAgentMSIInstallsDotnetLibrary) TestMSISkipRollbackIfInstalled() {
// TODO: remove override once image is published in prod
// TODO: support DD_INSTALLER_REGISTRY_URL
installerwindows.WithMSIArg("DD_INSTALLER_REGISTRY_URL=install.datad0g.com.internal.dda-testing.com"),
// TODO: update to use Version() when stable is updated
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", oldVersion.PackageVersion())),
installerwindows.WithMSILogFile("install.log"),
)
Expand All @@ -223,7 +225,7 @@ func (s *testAgentMSIInstallsDotnetLibrary) TestMSISkipRollbackIfInstalled() {
// TODO: remove override once image is published in prod
// TODO: support DD_INSTALLER_REGISTRY_URL
installerwindows.WithMSIArg("DD_INSTALLER_REGISTRY_URL=install.datad0g.com.internal.dda-testing.com"),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", newVersion.PackageVersion())),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", newVersion.Version())),
installerwindows.WithMSILogFile("install-rollback.log"),
installerwindows.WithMSIArg("WIXFAILWHENDEFERRED=1"),
)
Expand All @@ -245,7 +247,7 @@ func (s *testAgentMSIInstallsDotnetLibrary) TestUninstallKeepsLibrary() {
installerwindows.WithMSIArg("DD_APM_INSTRUMENTATION_ENABLED=iis"),
// TODO: remove override once image is published in prod
installerwindows.WithMSIArg("DD_INSTALLER_REGISTRY_URL=install.datad0g.com.internal.dda-testing.com"),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", version.PackageVersion())),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", version.Version())),
installerwindows.WithMSILogFile("install.log"),
)

Expand Down Expand Up @@ -274,7 +276,7 @@ func (s *testAgentMSIInstallsDotnetLibrary) TestUninstallScript() {
installerwindows.WithMSIArg("DD_APM_INSTRUMENTATION_ENABLED=iis"),
// TODO: remove override once image is published in prod
installerwindows.WithMSIArg("DD_INSTALLER_REGISTRY_URL=install.datad0g.com.internal.dda-testing.com"),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", version.PackageVersion())),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", version.Version())),
installerwindows.WithMSILogFile("install.log"),
)
// Start the IIS app to load the library
Expand All @@ -297,6 +299,44 @@ func (s *testAgentMSIInstallsDotnetLibrary) TestUninstallScript() {
s.Require().Empty(newLibraryPath)
}

// TestUninstallScript validates that instrumentation is disabled after we run the uninstall script
func (s *testAgentMSIInstallsDotnetLibrary) TestMSIPurge() {
// Arrange
version := s.currentDotnetLibraryVersion

// Act
s.installCurrentAgentVersion(
installerwindows.WithMSIArg("DD_APM_INSTRUMENTATION_ENABLED=iis"),
// TODO: remove override once image is published in prod
installerwindows.WithMSIArg("DD_INSTALLER_REGISTRY_URL=install.datad0g.com.internal.dda-testing.com"),
installerwindows.WithMSIArg(fmt.Sprintf("DD_APM_INSTRUMENTATION_LIBRARIES=dotnet:%s", version.Version())),
installerwindows.WithMSILogFile("install.log"),
)
// Start the IIS app to load the library
defer s.stopIISApp()
s.startIISApp(webConfigFile, aspxFile)

// Assert
s.assertSuccessfulPromoteExperiment(version.Version())
// Check that the expected version of the library is loaded
oldLibraryPath := s.getLibraryPathFromInstrumentedIIS()
s.Require().Contains(oldLibraryPath, version.Version())

// uninstall the MSI with PURGE=1
options := []installerwindows.MsiOption{
installerwindows.WithMSILogFile("uninstall.log"),
installerwindows.WithMSIArg("PURGE=1"),
}
s.Require().NoError(s.Installer().Uninstall(options...))

// verify it is uninstalled
s.stopIISApp()
defer s.stopIISApp()
s.startIISApp(webConfigFile, aspxFile)
newLibraryPath := s.getLibraryPathFromInstrumentedIIS()
s.Require().Empty(newLibraryPath)
}

func (s *testAgentMSIInstallsDotnetLibrary) installPreviousAgentVersion(opts ...installerwindows.MsiOption) {
agentVersion := s.StableAgentVersion().Version()
options := []installerwindows.MsiOption{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,11 @@ public static ActionResult RollbackOciPackages(Session session)
{
return Datadog.CustomActions.InstallOciPackages.RollbackActions(session);
}

[CustomAction]
public static ActionResult PurgeOciPackages(Session session)
{
return Datadog.CustomActions.InstallOciPackages.PurgePackages(session);
}
}
}
Loading
Loading