Skip to content

Commit

Permalink
Don't cleanup paths on crash, as it will be restart. Fix ownership.
Browse files Browse the repository at this point in the history
  • Loading branch information
blakerouse committed Jan 19, 2021
1 parent 7e0d2fc commit ccd8bea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
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

0 comments on commit ccd8bea

Please sign in to comment.