Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Remove the dashboard marker on every uninstall, and roll it back

Claude068e367d5fe1
diff --git a/cli/beacon/internal/endpoint/lifecycle/dashboard_test.go b/cli/beacon/internal/endpoint/lifecycle/dashboard_test.go
index df5d6244..8fb322af 100644
--- a/cli/beacon/internal/endpoint/lifecycle/dashboard_test.go
+++ b/cli/beacon/internal/endpoint/lifecycle/dashboard_test.go
@@ -2,6 +2,8 @@ package lifecycle
import (
"errors"
+ "os"
+ "path/filepath"
"strings"
"testing"
@@ -116,3 +118,36 @@ func TestStatusReportsTheDashboardSwitch(t *testing.T) {
}
}
}
+
+// The dashboard marker goes wherever config.json goes. A normal uninstall removes config.json
+// through the manifest; a marker left behind would bring a later clean install back disabled.
+// Repair keeps both.
+func TestUninstallRemovesTheDashboardMarkerWithTheConfig(t *testing.T) {
+ for _, withManifest := range []bool{false, true} {
+ for _, repair := range []bool{false, true} {
+ testenv.SetHome(t, t.TempDir())
+ cfg := endpointconfig.Default(true, filepath.Join(t.TempDir(), "runtime.jsonl"))
+ configPath, err := endpointconfig.Save(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ marker := endpointconfig.DashboardMarkerPath(configPath)
+ if err := os.WriteFile(marker, []byte("disabled\n"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ if withManifest {
+ if _, err := writeManifest(true, Manifest{Files: []string{configPath}}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ _ = Uninstall(UninstallOptions{UserMode: true, KeepManagedIngest: repair})
+ _, err = os.Stat(marker)
+ if repair && err != nil {
+ t.Errorf("manifest=%v: repair removed the dashboard marker: %v", withManifest, err)
+ }
+ if !repair && !os.IsNotExist(err) {
+ t.Errorf("manifest=%v: uninstall left the dashboard marker behind: %v", withManifest, err)
+ }
+ }
+ }
+}
diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
index 42372d7d..f97b50c0 100644
--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go
@@ -724,6 +724,9 @@ func Install(opts InstallOptions) (InstallResult, error) {
manifest.Files = append(manifest.Files, configPath)
forwardSecretsPath := endpointconfig.OTLPForwardSecretsPath(cfg.UserMode)
tx.Track(forwardSecretsPath)
+ // Save writes or removes the dashboard marker beside the system config; a failed install puts it
+ // back as it was, so it keeps matching the config the rollback restores.
+ tx.Track(endpointconfig.DashboardMarkerPath(configPath))
if _, err := saveEndpointConfig(cfg); err != nil {
tx.Rollback(manifest)
return InstallResult{}, err
@@ -991,9 +994,6 @@ func Uninstall(opts UninstallOptions) error {
fail("remove "+cfg.Collector.ConfigPath, os.Remove(cfg.Collector.ConfigPath))
if !opts.KeepManagedIngest {
fail("remove endpoint config", os.Remove(endpointConfigPath))
- // The marker records the config's dashboard switch; left behind, a later install's
- // buildConfig would read it as the switch of a config that no longer exists.
- fail("remove the dashboard switch marker", os.Remove(endpointconfig.DashboardMarkerPath(endpointConfigPath)))
}
}
// The forward's header values are a credential, so they go with config.json whether or not the
@@ -1001,6 +1001,10 @@ func Uninstall(opts UninstallOptions) error {
// would otherwise leave the backend's token behind.
if !opts.KeepManagedIngest {
fail("remove the OTLP forward headers", os.Remove(forwardSecretsPath))
+ // The dashboard marker records config.json's switch, so it goes whenever config.json does,
+ // however that was removed: left behind, a later install's buildConfig would read it as
+ // the switch of a config that no longer exists and come back disabled.
+ fail("remove the dashboard switch marker", os.Remove(endpointconfig.DashboardMarkerPath(endpointConfigPath)))
}
if !opts.KeepLogs {
for _, path := range runtimeLogFiles(cfg.LogPath) {