k3s/pkg
luojiyin f42523c55f Fix atomic write in WriteSubnetFile
- 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>
2026-01-08 11:37:41 -08:00
..
agent Fix atomic write in WriteSubnetFile 2026-01-08 11:37:41 -08:00
authenticator lint: unnecessary-format,use-errors-new 2025-12-18 11:20:07 -08:00
bootstrap lint: use-any 2025-12-18 11:20:07 -08:00
certmonitor lint: empty-lines 2025-12-18 11:20:07 -08:00
cgroups lint: unnecessary-stmt 2025-12-18 11:20:07 -08:00
cli Allow k3s secrets-encrypt enable on existing clusters 2025-12-30 10:34:23 -08:00
clientaccess lint: unhandled-error 2025-12-18 11:20:07 -08:00
cloudprovider lint: unnecessary-format,use-errors-new 2025-12-18 11:20:07 -08:00
cluster Fix etcd reconcile with empty TLS dirs 2026-01-05 09:59:29 -08:00
configfilearg lint: bare-return 2025-12-18 11:20:07 -08:00
containerd lint: redundant-build-tag 2025-12-18 11:20:07 -08:00
ctr Upgrade containerd to v2.0.2 2025-02-07 12:03:48 -08:00
daemons Allow k3s secrets-encrypt enable on existing clusters 2025-12-30 10:34:23 -08:00
data refactor: replace go-bindata with native embed package 2025-07-31 11:53:06 -07:00
datadir Avoid use of github.com/pkg/errors functions that capture stack 2025-03-05 00:41:38 -08:00
dataverify Add file verification for data directory 2020-10-06 10:29:27 -07:00
deploy lint: redefines-builtin-id 2025-12-18 11:20:07 -08:00
etcd Replace temporary etcd server with raw mvcc store access 2026-01-05 09:59:29 -08:00
executor/embed lint: nested-structs 2025-12-18 11:20:07 -08:00
flock lint: redundant-build-tag 2025-12-18 11:20:07 -08:00
kubeadm lint: empty-lines 2025-12-18 11:20:07 -08:00
kubectl Drop calls to rand.Seed 2025-10-02 09:47:25 -07:00
metrics Move etcd metrics to separate package 2025-12-08 12:53:10 -08:00
node Move node password secrets into dedicated controller 2025-10-27 15:06:45 -07:00
nodeconfig Use patch helper for node labels and annotations 2025-12-08 12:53:10 -08:00
nodepassword lint: unnecessary-format,use-errors-new 2025-12-18 11:20:07 -08:00
passwd VPN PoC 2023-06-09 12:39:33 +02:00
proctitle lint: redundant-build-tag 2025-12-18 11:20:07 -08:00
profile Refactor supervisor listener startup and add metrics 2024-05-28 16:24:57 -07:00
rootless lint: deep-exit 2025-12-18 11:20:07 -08:00
rootlessports lint: superfluous-else 2025-12-18 11:20:07 -08:00
secretsencrypt Allow k3s secrets-encrypt enable on existing clusters 2025-12-30 10:34:23 -08:00
server Allow k3s secrets-encrypt enable on existing clusters 2025-12-30 10:34:23 -08:00
signals lint: deep-exit 2025-12-18 11:20:07 -08:00
spegel Use patch helper for spegel annotations and labels 2025-12-08 12:53:10 -08:00
static lint: redundant-build-tag 2025-12-18 11:20:07 -08:00
untar Bump wharfie to v0.5.1 and use shared decompression code 2021-12-07 12:50:57 -08:00
util lint: unnecessary-format,use-errors-new 2025-12-18 11:20:07 -08:00
version Add runtime checking of golang version 2024-01-04 17:22:46 -08:00
vpn lint: exported 2025-12-18 11:20:07 -08:00