Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #23537 to 7.11: [Elastic Agent] Set status Failed if configuration applying fails #23601

Merged
merged 1 commit into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- Fixed fetching DBus service PID {pull}23496[23496]
- Fix issue of missing log messages from filebeat monitor {pull}23514[23514]
- Increase checkin grace period to 30 seconds {pull}23568[23568]
- Fix libbeat from reporting back degraded on config update {pull}23537[23537]

==== New features

Expand Down
13 changes: 8 additions & 5 deletions x-pack/elastic-agent/pkg/core/monitoring/beats/beats_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ func (b *Monitor) Cleanup(spec program.Spec, pipelineID string) error {

// Prepare executes steps in order for monitoring to work correctly
func (b *Monitor) Prepare(spec program.Spec, pipelineID string, uid, gid int) error {
takeOwnership := b.ownLoggingPath(spec)
if !b.ownLoggingPath(spec) {
// spec file passes a log path; so its up to the application to ensure the
// path exists and the write permissions are set so Elastic Agent can read it
return nil
}

drops := []string{b.generateLoggingPath(spec, pipelineID)}
if drop := b.monitoringDrop(spec, pipelineID); drop != "" {
drops = append(drops, drop)
Expand All @@ -167,10 +172,8 @@ func (b *Monitor) Prepare(spec program.Spec, pipelineID string, uid, gid int) er
}
}

if takeOwnership {
if err := changeOwner(drop, uid, gid); err != nil {
return err
}
if err := changeOwner(drop, uid, gid); err != nil {
return err
}
}

Expand Down
3 changes: 0 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 @@ -35,9 +35,6 @@ func (a *Application) OnStatusChange(s *server.ApplicationState, status proto.St
return
}

// it was a crash, cleanup anything required
go a.cleanUp()

// kill the process
if a.state.ProcessInfo != nil {
_ = a.state.ProcessInfo.Process.Kill()
Expand Down
2 changes: 1 addition & 1 deletion x-pack/libbeat/management/fleet/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (cm *Manager) OnConfig(s string) {

if errs := cm.apply(blocks); !errs.IsEmpty() {
// `cm.apply` already logs the errors; currently allow beat to run degraded
cm.UpdateStatus(management.Degraded, errs.Error())
cm.UpdateStatus(management.Failed, errs.Error())
return
}

Expand Down