Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hostPath volumes used with subPath volume mounts don't support reconstruction #61446

Open
msau42 opened this issue Mar 21, 2018 · 17 comments
Open
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. sig/storage Categorizes an issue or PR as relevant to SIG Storage.

Comments

@msau42
Copy link
Member

msau42 commented Mar 21, 2018

Is this a BUG REPORT or FEATURE REQUEST?:
@kubernetes/sig-storage-bugs

What happened:
Normally this isn't a problem, but if you use subpath with hostpath volumes, then that means the subpath mounts will not get cleaned up during the reconstruction window (a pod is force deleted while kubelet is down)

@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. kind/bug Categorizes issue or PR as related to a bug. labels Mar 21, 2018
@msau42
Copy link
Member Author

msau42 commented Mar 21, 2018

Noticed this issue while working on #61373

@liggitt
Copy link
Member

liggitt commented Mar 21, 2018

How is this different than #61372?

@msau42
Copy link
Member Author

msau42 commented Mar 21, 2018

#61372 affects reconstruction for PVCs

@liggitt liggitt changed the title Hostpath doesn't support reconstruction hostPath volumes used with subPath volume mounts don't support reconstruction Mar 22, 2018
nickchase pushed a commit to nickchase/sig-release that referenced this issue Mar 26, 2018
* Use of subPath module with hostPath volumes can cause issues during reconstruction ([#61446](kubernetes/kubernetes#61446)) and with containerized kubelets ([#61456](kubernetes/kubernetes#61456)). The workaround for this issue is to specify the complete path in the hostPath volume.
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 6, 2018
@msau42
Copy link
Member Author

msau42 commented Aug 6, 2018

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 6, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 4, 2018
@msau42
Copy link
Member Author

msau42 commented Nov 6, 2018

/remove-lifecycle stale

We intend to address this by redesigning the volume reconstruction feature to use kubelet checkpointing.

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 6, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 4, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Mar 6, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions 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/test-infra repository.

@msau42
Copy link
Member Author

msau42 commented Dec 12, 2019

/reopen
/lifecycle frozen

@k8s-ci-robot k8s-ci-robot reopened this Dec 12, 2019
@k8s-ci-robot
Copy link
Contributor

@msau42: Reopened this issue.

In response to this:

/reopen
/lifecycle frozen

Instructions 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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Dec 12, 2019
@neujie
Copy link

neujie commented Dec 20, 2019

Better practice:

  • kill or delete pod
  • clear the pod's all subpath
    otherwise a lot of useless dir will be left

@dobsonj
Copy link
Member

dobsonj commented Mar 25, 2022

/assign

@dobsonj
Copy link
Member

dobsonj commented Mar 29, 2022

The in-tree hostPath driver makes no attempt to unmount:

// TearDown does nothing.
func (c *hostPathUnmounter) TearDown() error {
return nil
}
// TearDownAt does not make sense for host paths - probably programmer error.
func (c *hostPathUnmounter) TearDownAt(dir string) error {
return fmt.Errorf("TearDownAt() does not make sense for host paths")
}

Once that is fixed, these skips need to be removed:
if strings.HasPrefix(driverName, "hostPath") {
// TODO: This skip should be removed once #61446 is fixed
e2eskipper.Skipf("Driver %s does not support reconstruction, skipping", driverName)
}

if strings.HasPrefix(driverName, "hostPath") {
// TODO: This skip should be removed once #61446 is fixed
e2eskipper.Skipf("Driver %s does not support reconstruction, skipping", driverName)
}

@dobsonj
Copy link
Member

dobsonj commented Mar 30, 2022

The in-tree hostPath driver makes no attempt to unmount

So it's not really the TearDown code I quoted above, the subpaths would normally be cleaned up here:

// Remove all bind-mounts for subPaths
podDir := filepath.Join(podsDir, string(volumeToUnmount.PodUID))
if err := subpather.CleanSubPaths(podDir, volumeToUnmount.InnerVolumeSpecName); err != nil {
eventErr, detailedErr := volumeToUnmount.GenerateError("error cleaning subPath mounts", err)
return volumetypes.NewOperationContext(eventErr, detailedErr, migrated)
}

But we never make any attempt to call UnmountVolume in this scenario.

klog.V(5).InfoS(mountedVolume.GenerateMsgDetailed("Starting operationExecutor.UnmountVolume", ""))
err := rc.operationExecutor.UnmountVolume(
mountedVolume.MountedVolume, rc.actualStateOfWorld, rc.kubeletPodsDir)

unmountVolumes loops over rc.actualStateOfWorld.GetAllMountedVolumes(), but if we're just using a hostPath (type = Directory), there won't be a mount point, and it won't be listed as a mounted volume. But the subpaths still use bind mounts, and those never get unmounted.

For future reference it can be reproduced manually with:

kind: Pod
apiVersion: v1
metadata:
  name: my-intree-inline-app
spec:
  containers:
    - name: my-frontend
      image: busybox
      volumeMounts:
      - mountPath: "/data"
        name: my-inline-vol
      - mountPath: "/data/subpath1"
        name: my-inline-vol
        subPath: subpath1
      - mountPath: "/data/subpath2"
        name: my-inline-vol
        subPath: subpath2
      command: [ "sleep", "1000000" ]
  volumes:
    - name: my-inline-vol
      hostPath:
        path: /tmp/dir1
        type: Directory
  1. create pod with spec above, check mountpoints
  2. kill kubelet
  3. force delete pod
  4. start kubelet again
  5. check mount points and kubelet.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. sig/storage Categorizes an issue or PR as relevant to SIG Storage.
Projects
None yet
Development

No branches or pull requests

6 participants