fix: treat empty existing mount as stale in ensureMountPoint - #2025
fix: treat empty existing mount as stale in ensureMountPoint#2025OS-gustavosalvador wants to merge 4 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: OS-gustavosalvador The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
This issue is currently awaiting triage. If secrets-store-csi-driver contributors determine this is a relevant issue, they will accept it by applying the The DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Welcome @OS-gustavosalvador! |
|
|
|
Hi @OS-gustavosalvador. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
8ef87d1 to
de8cc58
Compare
stlaz
left a comment
There was a problem hiding this comment.
Pre-review: please reduce the cognitive load of the PR for maintainers by hand-rewriting all of What this PR does / why we need it: and Special notes for your reviewer: and the code comments and the commit message.
Remove issue links from the code comments.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: OS-gustavosalvador The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
On Linux, when the target is already mounted, check whether the directory is empty and unmount it if so, so the caller performs a fresh mount. Matches the contract the Windows branch already enforces and prevents the retry from reporting success on a stale empty tmpfs left by an interrupted NodePublishVolume. Signed-off-by: Gustavo Salvador <gustavo.salvador@outsystems.com>
de8cc58 to
8c5af2b
Compare
|
thanks @stlaz, adjusted as suggested 👍 |
|
/ok-to-test |
Signal mount state to the caller instead of unmounting; the caller reuses the existing tmpfs and re-calls the provider. Signed-off-by: Gustavo Salvador <gustavo.salvador@outsystems.com>
|
/retest |
Signed-off-by: OS-gustavosalvador <gustavo.salvador@outsystems.com>
|
/retest |
| // If it is mounted, it means this is not the first time mount request for this path. | ||
| isRemountRequest = mounted | ||
| // An empty existing mount is a previous interrupted call, not a remount. | ||
| isRemountRequest = mounted && hasContent |
There was a problem hiding this comment.
it's only remount request if it's mounted, original was more accurate.
There was a problem hiding this comment.
also looking at how the var is used elsewhere, adding "hasContent" might be wrong I think?
| if !rotationEnabled && isRemountRequest { | ||
| klog.InfoS("target path is already mounted", "targetPath", targetPath, "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName}) | ||
| skipped = true |
There was a problem hiding this comment.
| if !rotationEnabled && isRemountRequest { | |
| klog.InfoS("target path is already mounted", "targetPath", targetPath, "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName}) | |
| skipped = true | |
| if !rotationEnabled && mounted && hasContent { | |
| klog.InfoS("target path is already mounted and populated", "targetPath", targetPath, "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName}) | |
| skipped = true |
There was a problem hiding this comment.
@aramase is there any possibility that no content is the actual desired state?
| return !notMnt, nil | ||
| entries, readErr := os.ReadDir(target) | ||
| if readErr == nil { | ||
| return true, len(entries) > 0, nil |
There was a problem hiding this comment.
let's maybe keep the original log line but move it to V(4)
| // instead check if the dir exists for windows and if it's not empty | ||
| // If there are contents in the dir, then objects are already mounted | ||
| f, err := os.ReadDir(target) | ||
| // IsLikelyNotMountPoint always returns notMnt=true on Windows; |
| // ensureMountPoint ensures mount point is valid | ||
| func (ns *nodeServer) ensureMountPoint(target string) (bool, error) { | ||
| // ensureMountPoint reports whether the target is mounted and whether | ||
| // it has any content. The caller decides whether to mount, populate, |
There was a problem hiding this comment.
don't make assumptions on what the caller wants to do with the return vals in the docs here
Signed-off-by: OS-gustavosalvador <gustavo.salvador@outsystems.com>
|
thanks again @stlaz, updated the code👍 |
|
/retest |
|
@OS-gustavosalvador: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
On Linux,
ensureMountPointreturnedmounted=truefor any existing mount whose directory could be read; no content check.If
NodePublishVolumewas interrupted between mounting the tmpfs and writing the provider's files (driver pod killed, context cancelled), the empty tmpfs persisted. The retry short-circuited on "already mounted" and the pod started with an empty secrets directory. Readiness never recovered without manual intervention.The fix: if the existing mount is empty, unmount it and return
mounted=falseso the caller performs a fresh mount. The Windows branch below already enforces the same contract via a different mechanism.Reproduced in a local k3d cluster by killing the driver pod mid-Mount. Same branch with
utils.goreverted to its parent: 0/3 runs recover. With the fix: 5/5 runs Ready within seconds of the next retry, zero restarts.Which issue(s) this PR fixes:
Fixes #1051
TODOs: