From 9950ed53f477a28ccd2135dbe461592bff99df0a Mon Sep 17 00:00:00 2001 From: michel-laterman Date: Wed, 20 Nov 2024 17:17:43 -0300 Subject: [PATCH] move notification attempt --- internal/pkg/agent/install/uninstall.go | 13 +++++++------ testing/integration/install_test.go | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/internal/pkg/agent/install/uninstall.go b/internal/pkg/agent/install/uninstall.go index 2eb16df4936..3ca6cc652e0 100644 --- a/internal/pkg/agent/install/uninstall.go +++ b/internal/pkg/agent/install/uninstall.go @@ -90,12 +90,6 @@ func Uninstall(ctx context.Context, cfgFile, topPath, uninstallToken string, log } } - // Skip on Windows because of https://github.com/elastic/elastic-agent/issues/5952 - // Once the root-cause is identified then this can be re-enabled on Windows. - // Notify fleet-server while it is still running if it's running locally - if notifyFleet && localFleet && runtime.GOOS != "windows" { - notifyFleetAuditUninstall(ctx, log, pt, cfg, ai) //nolint:errcheck // ignore the error as we can't act on it - } // ensure service is stopped status, err := EnsureStoppedService(topPath, pt) if err != nil { @@ -103,6 +97,13 @@ func Uninstall(ctx context.Context, cfgFile, topPath, uninstallToken string, log return err } + // Skip on Windows because of https://github.com/elastic/elastic-agent/issues/5952 + // Once the root-cause is identified then this can be re-enabled on Windows. + // Notify fleet-server while it is still running if it's running locally + if notifyFleet && localFleet && runtime.GOOS != "windows" { + notifyFleetAuditUninstall(ctx, log, pt, cfg, ai) //nolint:errcheck // ignore the error as we can't act on it + } + // kill any running watcher if err := killWatcher(pt); err != nil { return fmt.Errorf("failed trying to kill any running watcher: %w", err) diff --git a/testing/integration/install_test.go b/testing/integration/install_test.go index 147811b1a73..64812a980de 100644 --- a/testing/integration/install_test.go +++ b/testing/integration/install_test.go @@ -351,8 +351,8 @@ func testUninstallAuditUnenroll(ctx context.Context, fixture *atesting.Fixture, require.NotEmpty(t, agentID, "agent ID empty") out, err := fixture.Uninstall(ctx, &atesting.UninstallOpts{Force: true}) + t.Logf("uninstall output: %s", out) if err != nil { - t.Logf("uninstall output: %s", out) require.NoError(t, err) } @@ -371,7 +371,7 @@ func testUninstallAuditUnenroll(ctx context.Context, fixture *atesting.Fixture, } err = json.Unmarshal(p, &res) require.NoError(t, err) - require.Equalf(t, "uninstall", res.Source.AuditUnenrolledReason, "Agent doc: %s\nUninstall output: %s", p, out) + require.Equal(t, "uninstall", res.Source.AuditUnenrolledReason) } }