Skip to content

Commit

Permalink
fix[datadog-installer]: Handle 'file not found' error in removeUnit f…
Browse files Browse the repository at this point in the history
…unction (#32066)

Co-authored-by: arbll <[email protected]>
  • Loading branch information
efloss and arbll authored Dec 12, 2024
1 parent 8a55e93 commit 8822a1c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/fleet/installer/packages/systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ func removeUnit(ctx context.Context, unit string) (err error) {
span, _ := tracer.StartSpanFromContext(ctx, "remove_unit")
defer func() { span.Finish(tracer.WithError(err)) }()
span.SetTag("unit", unit)
return os.Remove(path.Join(systemdPath, unit))
err = os.Remove(path.Join(systemdPath, unit))
if err != nil && !os.IsNotExist(err) {
return err
}
return nil
}

func systemdReload(ctx context.Context) (err error) {
Expand Down

0 comments on commit 8822a1c

Please sign in to comment.