Skip to content

Commit

Permalink
move notification attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-laterman committed Nov 20, 2024
1 parent 1bcf7f7 commit 9950ed5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions internal/pkg/agent/install/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,20 @@ 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 {
// context for the error already provided in the EnsureStoppedService function
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)
Expand Down
4 changes: 2 additions & 2 deletions testing/integration/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
}
}

Expand Down

0 comments on commit 9950ed5

Please sign in to comment.