diff --git a/x-pack/elastic-agent/CHANGELOG.asciidoc b/x-pack/elastic-agent/CHANGELOG.asciidoc index 015a78c985d9..9fab4206053e 100644 --- a/x-pack/elastic-agent/CHANGELOG.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.asciidoc @@ -37,6 +37,7 @@ - Fix jq: command not found {pull}18408[18408] - Avoid Chown on windows {pull}18512[18512] - Remove fleet admin from setup script {pull}18611[18611] +- Clean action store after enrolling to new configuration {pull}18656[18656] ==== New features diff --git a/x-pack/elastic-agent/pkg/agent/application/enroll_cmd.go b/x-pack/elastic-agent/pkg/agent/application/enroll_cmd.go index 8a8624b16754..4c9b06651fc6 100644 --- a/x-pack/elastic-agent/pkg/agent/application/enroll_cmd.go +++ b/x-pack/elastic-agent/pkg/agent/application/enroll_cmd.go @@ -10,6 +10,7 @@ import ( "io" "net/http" "net/url" + "os" "gopkg.in/yaml.v2" @@ -179,6 +180,12 @@ func (c *EnrollCmd) Execute() error { return err } + // clear action store + // fail only if file exists and there was a failure + if err := os.Remove(info.AgentActionStoreFile()); !os.IsNotExist(err) { + return err + } + return nil }