mirror of
https://github.com/k3s-io/k3s.git
synced 2026-02-03 20:39:49 -05:00
- Use os.CreateTemp to avoid race conditions with fixed temp filename - Add f.Sync() before close to ensure data durability - Check all fmt.Fprintf errors instead of ignoring them - Preserve original file permissions when overwriting - Handle dir== edge case from filepath.Split - Check os.MkdirAll error - Proper cleanup on all error paths Signed-off-by: luojiyin <luojiyin@hotmail.com> Add documentation comments to WriteSubnetFile Clarify the design choices for atomic file writing: - Explain why CreateTemp is used (defense-in-depth, avoids pre-existing file issues) - Document the single-instance assumption - Note the permission preservation logic Signed-off-by: luojiyin <luojiyin@hotmail.com> Update WriteSubnetFile comment to clarify CreateTemp rationale Remove misleading reference to concurrent writes (K3s is single-instance). Focus on the actual benefits: avoiding stale temp files from crashes, handling unexpected permissions/ownership, and O_EXCL guarantees. Signed-off-by: luojiyin <luojiyin@hotmail.com> Refactor cleanup to use merr.NewErrors for better error aggregation Address review feedback from @brandond to improve error handling: - Change cleanup function to accept error parameter - Use merr.NewErrors to aggregate original error with Close/Remove errors - Simplify error handling with consistent return cleanup(err) pattern Signed-off-by: luojiyin <luojiyin@hotmail.com> Fix Close error handling to preserve original error Add cleanupNoClose helper to avoid double Close and preserve the original Close error when file close fails. Signed-off-by: luojiyin <luojiyin@hotmail.com> |
||
|---|---|---|
| .. | ||
| config | ||
| containerd | ||
| cri | ||
| cridockerd | ||
| flannel | ||
| https | ||
| loadbalancer | ||
| netpol | ||
| proxy | ||
| syssetup | ||
| templates | ||
| tunnel | ||
| util | ||
| run.go | ||
| run_linux.go | ||
| run_test.go | ||
| run_windows.go | ||