-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Labels
Team:Elastic-Agent-Data-PlaneLabel for the Agent Data Plane teamLabel for the Agent Data Plane teambug
Description
The LoadMeta
function has a race condition if more than one beat has the same paths defined.
beats/libbeat/cmd/instance/beat.go
Lines 979 to 1002 in 22a9a05
tempFile := metaPath + ".new" | |
f, err = os.OpenFile(tempFile, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600) | |
if err != nil { | |
return fmt.Errorf("failed to create Beat meta file: %w", err) | |
} | |
encodeErr := json.NewEncoder(f).Encode(meta{UUID: b.Info.ID, FirstStart: b.Info.FirstStart}) | |
err = f.Sync() | |
if err != nil { | |
return fmt.Errorf("Beat meta file failed to write: %w", err) | |
} | |
err = f.Close() | |
if err != nil { | |
return fmt.Errorf("Beat meta file failed to write: %w", err) | |
} | |
if encodeErr != nil { | |
return fmt.Errorf("Beat meta file failed to write: %w", encodeErr) | |
} | |
// move temporary file into final location | |
err = file.SafeFileRotate(metaPath, tempFile) | |
return err |
The os.OpenFile
should be replaced with os.CreateTemp
Metadata
Metadata
Assignees
Labels
Team:Elastic-Agent-Data-PlaneLabel for the Agent Data Plane teamLabel for the Agent Data Plane teambug