Repository navigation
fix: handle dangling symlink in config-manager updateSymlink - #1982
Conversation
|
For context: we hit this in production. After a ConfigMap update, the Retrying never recovers because the dangling symlink itself persists across restarts, so the pod needs manual intervention (delete the symlink or recreate the pod). |
|
Thanks @yoonhyunwoo for fixing this. LGTM. Can we also add a regression test covering the dangling-symlink case? |
|
/ok to test f2f059f |
|
@yoonhyunwoo Thanks for adding the tests. Can you please rebase the branch on the latest |
Signed-off-by: yoonhyunwoo <yjs88zerg@gmail.com>
f2f059f to
1a69452
Compare
Done! |
|
/ok to test 1a69452 |
| return false, nil | ||
| } | ||
| } else if !os.IsNotExist(err) && !errors.Is(err, syscall.EINVAL) { | ||
| return false, fmt.Errorf("error reading symlink '%s': %v", f.ConfigFileDst, err) |
There was a problem hiding this comment.
If you want to quote strings it's better to use %q instead of %s. In this case however, it's better to just unquote the string as the logs are emitted in JSON format.
| return false, fmt.Errorf("error reading symlink '%s': %v", f.ConfigFileDst, err) | |
| return false, fmt.Errorf("error reading symlink %s: %w", f.ConfigFileDst, err) |
| } | ||
| err = os.Remove(f.ConfigFileDst) | ||
| if err != nil && !os.IsNotExist(err) { | ||
| return false, fmt.Errorf("error removing existing config: %v", err) |
There was a problem hiding this comment.
| return false, fmt.Errorf("error removing existing config: %v", err) | |
| return false, fmt.Errorf("error removing existing config: %w", err) |
| return false, fmt.Errorf("error removing existing config: %v", err) | ||
| } | ||
| err = os.Remove(f.ConfigFileDst) | ||
| if err != nil && !os.IsNotExist(err) { |
There was a problem hiding this comment.
Isn't this redundant?
!os.IsNotExist(err)
We already check for an IsNotExist error earlier.
| config: "missing-config", | ||
| wantChanged: true, | ||
| }, | ||
| { |
There was a problem hiding this comment.
This test is not clear to me. It seems like it depends on the previous test. If this is indeed the case, then it's an antipattern. The unit test should be independent of any other unit tests and it should pass when run in isolation.
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [longhorn](https://github.com/longhorn/longhorn) ([source](https://github.com/longhorn/charts)) | minor | `1.12.1` → `1.13.0` | | [nvidia-device-plugin](https://github.com/NVIDIA/k8s-device-plugin) | patch | `0.20.0` → `0.20.1` | --- >⚠️ **Warning** > > Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/6) for more information. --- ### Release Notes <details> <summary>longhorn/charts (longhorn)</summary> ### [`v1.13.0`](https://github.com/longhorn/charts/releases/tag/longhorn-1.13.0) [Compare Source](longhorn/charts@longhorn-1.12.1...longhorn-1.13.0) Longhorn is a distributed block storage system for Kubernetes. </details> <details> <summary>NVIDIA/k8s-device-plugin (nvidia-device-plugin)</summary> ### [`v0.20.1`](https://github.com/NVIDIA/k8s-device-plugin/blob/HEAD/CHANGELOG.md#v0201) [Compare Source](NVIDIA/k8s-device-plugin@v0.20.0...v0.20.1) - Add NodeFeature CR delete privileges ([#​2049](NVIDIA/k8s-device-plugin#2049)) - Include component-specific DaemonSet selector labels to avoid selector overlap ([#​1716](NVIDIA/k8s-device-plugin#1716)) - Validate vGPU capability record lengths ([#​1994](NVIDIA/k8s-device-plugin#1994)) - Go Modernize changes ([#​1996](NVIDIA/k8s-device-plugin#1996)) - Replace per-iteration sort in greedyAlloc with a min-heap ([#​1826](NVIDIA/k8s-device-plugin#1826)) - Handle dangling symlink in config-manager updateSymlink ([#​1982](NVIDIA/k8s-device-plugin#1982)) - Bump nvidia-container-toolkit to v1.20.1 ([#​2046](NVIDIA/k8s-device-plugin#2046)) - Bump go-nvml to v0.13.4-0 ([#​2013](NVIDIA/k8s-device-plugin#2013)) - Bump nvidia/distroless/go to v4.1.4 ([#​2029](NVIDIA/k8s-device-plugin#2029)) - Guard GFD PCI vendor capability parsing against bad lengths ([#​2027](NVIDIA/k8s-device-plugin#2027)) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNC4xMiIsInVwZGF0ZWRJblZlciI6IjQ0LjE0LjEyIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Reviewed-on: https://forge.superkooka.com/Superkooka/infra-gitops/pulls/35
Fixes #364
Follow-up to #365
dangling symlink is misjudged as "missing" and recreation fails.
os.Readlink checks the symlink itself, so it works correctly even when dangling.