Skip to content

Commit

Permalink
[Elastic Agent] Do not apply config if newer is available during rest…
Browse files Browse the repository at this point in the history
…art (#25701)

[Elastic Agent] Do not apply config if newer is available during restart (#25701)
  • Loading branch information
michalpristas authored May 13, 2021
1 parent 68d8948 commit 144058a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions x-pack/elastic-agent/pkg/agent/operation/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ func TestConfigurableRun(t *testing.T) {
}

func TestConfigurableFailed(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("this test is sometimes flaky on the last part, investigating @michal")
}
p := getProgram("configurable", "1.0")

operator := getTestOperator(t, downloadPath, installPath, p)
Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/pkg/core/plugin/process/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (a *Application) start(ctx context.Context, t app.Taggable, cfg map[string]
if srvState != nil {
a.setState(state.Starting, "Starting", nil)
srvState.SetStatus(proto.StateObserved_STARTING, a.state.Message, a.state.Payload)
srvState.UpdateConfig(string(cfgStr))
srvState.UpdateConfig(srvState.Config())
} else {
a.srvState, err = a.srv.Register(a, string(cfgStr))
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions x-pack/elastic-agent/pkg/core/plugin/process/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (a *Application) startFailedTimer(cfg map[string]interface{}) {
case <-ctx.Done():
return
case <-t.C:
a.restart(a.restartConfig)
a.restart()
}
}()
}
Expand All @@ -91,7 +91,7 @@ func (a *Application) stopFailedTimer() {
}

// restart restarts the application
func (a *Application) restart(cfg map[string]interface{}) {
func (a *Application) restart() {
a.appLock.Lock()
defer a.appLock.Unlock()

Expand All @@ -103,7 +103,7 @@ func (a *Application) restart(cfg map[string]interface{}) {
ctx := a.startContext
tag := a.tag

err := a.start(ctx, tag, cfg)
err := a.start(ctx, tag, a.restartConfig)
if err != nil {
a.setState(state.Crashed, fmt.Sprintf("failed to restart: %s", err), nil)
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/pkg/core/plugin/service/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (a *Application) Start(ctx context.Context, _ app.Taggable, cfg map[string]
if a.srvState != nil {
a.setState(state.Starting, "Starting", nil)
a.srvState.SetStatus(proto.StateObserved_STARTING, a.state.Message, a.state.Payload)
a.srvState.UpdateConfig(string(cfgStr))
a.srvState.UpdateConfig(a.srvState.Config())
} else {
a.setState(state.Starting, "Starting", nil)
a.srvState, err = a.srv.Register(a, string(cfgStr))
Expand Down

0 comments on commit 144058a

Please sign in to comment.