Skip to content

Commit

Permalink
Fix failures when using npipe monitoring endpoints (#1371) (#1372)
Browse files Browse the repository at this point in the history
(cherry picked from commit e184051)

Co-authored-by: Michal Pristas <[email protected]>
  • Loading branch information
mergify[bot] and michalpristas authored Sep 29, 2022
1 parent 2c0523e commit cd40b06
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/pkg/core/monitoring/beats/sidecar_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ func (b *SidecarMonitor) EnrichArgs(spec program.Spec, pipelineID string, args [
func (b *SidecarMonitor) Cleanup(spec program.Spec, pipelineID string) error {
endpoint := MonitoringEndpoint(spec, b.operatingSystem, pipelineID, true)
drop := monitoringDrop(endpoint)
if drop == "" {
// not exposed using sockets
return nil
}

return os.RemoveAll(drop)
}
Expand All @@ -104,6 +108,11 @@ func (b *SidecarMonitor) Prepare(spec program.Spec, pipelineID string, uid, gid
endpoint := MonitoringEndpoint(spec, b.operatingSystem, pipelineID, true)
drop := monitoringDrop(endpoint)

if drop == "" {
// not exposed using sockets
return nil
}

if err := os.MkdirAll(drop, 0775); err != nil {
return errors.New(err, fmt.Sprintf("failed to create a directory %q", drop))
}
Expand Down

0 comments on commit cd40b06

Please sign in to comment.