Skip to content

Commit bbc1c24

Browse files
committed
OCPBUGS-60273: Ensure revision.json persists on ungraceful shutdown
Add os.O_SYNC flag to OpenFile call in trySaveRevision to force synchronous writes to disk. This prevents the revision.json file from being empty if the process terminates unexpectedly before buffered data is flushed.
1 parent 0357803 commit bbc1c24

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/cmd/rev/rev.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func trySaveRevision(ctx context.Context, endpoints []string, outputFile string,
189189
}
190190

191191
tmpPath := fmt.Sprintf("%s.tmp", outputFile)
192-
file, err := os.OpenFile(tmpPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
192+
file, err := os.OpenFile(tmpPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC|os.O_SYNC, 0644)
193193
if err != nil {
194194
klog.Errorf("error opening file: %v", err)
195195
return

0 commit comments

Comments
 (0)