Commit Graph

142 Commits (56dc8f9a6ab09debeddf5349ee26730d3e9107f8)

Author SHA1 Message Date
Kubernetes Submit Queue 6369a10004
Merge pull request #58284 from mfojtik/findmnt-out
Automatic merge from submit-queue (batch tested with PRs 57868, 58284, 56370, 58400, 58439). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Show findmnt command output in case of error

**What this PR does / why we need it**:

We don't print the error output from the `findmnt` command, which makes it pretty hard to debug. 

The current implementation just print:

`
I0115 11:59:36.078285   18230 nsenter_mount.go:168] Failed findmnt command for path /var/lib/origin/openshift.local.volumes/pods/8d723ec8-f9e9-11e7-bc52-025000000001/volumes/kubernetes.io~secret/pvinstaller-token-bxh42: exit status 1
`

With this patch, we can actually see the error:

`
I0115 12:04:30.908164   23301 nsenter_mount.go:168] Failed findmnt command for path /var/lib/origin/openshift.local.volumes/pods/8ff8bb98-f9e9-11e7-bc52-025000000001/volumes/kubernetes.io~secret/deployer-token-g4sg9: nsenter: failed to execute /findmnt: No such file or directory
 exit status 1
`

**Release note**:
```release-note
NONE
```
2018-01-18 13:11:30 -08:00
Kubernetes Submit Queue 74f2305c4f
Merge pull request #57967 from jsafrane/fix-nfs-root-squash
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Fixed TearDown of NFS with root squash.

NFS plugin should not use `IsLikelyNotMountPoint()`, as it uses `lstat()` / `stat()` to determine if the NFS volume is still mounted - NFS server may use root_squash and kubelet may not be allowed to do `lstat()` / `stat()` there.

It must use slower `IsNotMountPoint()` instead, including in `TearDown()` function.

**Release note**:

```release-note
NONE
```

/assign @gnufied @rootfs
2018-01-17 13:32:03 -08:00
Michal Fojtik fd520aef61
Show findmt command output in case of error 2018-01-15 13:02:31 +01:00
Jan Safranek da1eec2853 Add jsafrane as util/mount approver. 2018-01-08 14:19:22 +01:00
Jan Safranek 45d21ee36b Fixed TearDown of NFS with root squash.
NFS plugin should not use IsLikelyNotMountPoint(), as it uses lstat() / stat()
to determine if the NFS volume is still mounted - NFS server may use
root_squash and kubelet may not be allowed to do lstat() / stat() there.

It must use slower IsNotMountPoint() instead, including TearDown() function.
2018-01-08 14:01:33 +01:00
Jeff Grafton efee0704c6 Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
Hemant Kumar 2f2a643684 Implement file system resizing support on kubelet start
Update bazel files
Fix operation executor tests
2017-11-22 16:06:10 -05:00
Jan Safranek 790f513d23 Fix cross-compliation of mount_exec.go
Add dummy implementation for non-linux platforms
2017-11-14 16:30:00 +01:00
Jan Safranek 1dd32ce7eb Add ExecMounter 2017-11-10 13:14:40 +01:00
Clayton Coleman b844ac44f5
Tmpdir can be a symlink, also fake mount needs to call nested mounter 2017-11-03 22:21:29 -04:00
Kubernetes Submit Queue 618b705a4b
Merge pull request #53629 from andyzhangx/azurefile-improve
Automatic merge from submit-queue (batch tested with PRs 46341, 53629). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

fix azure file mount limit issue on windows due to using drive letter

**What this PR does / why we need it**:
It's not necessary to use drive letter in azure file mount, correct usage for New-SmbGlobalMapping is like following:
```
New-SmbGlobalMapping -RemotePath $AzureFilePath -Credential $Credential
mklink /D $mountPath $AzureFilePath 
```
I removed the `LocalPath` parameter in New-SmbGlobalMapping

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #54668
Without this PR, there is a limit(25) for azure file mount number on each node because only 25 drive letters could be used on each windows node, With this PR, there would be no such limit.

**Special notes for your reviewer**:
@PatrickLang 

**Release note**:

```
fix azure file mount limit issue on windows due to using drive letter
```
/sig azure
/sig windows
2017-11-01 04:38:12 -07:00
Kubernetes Submit Queue f34a24e98e
Merge pull request #52401 from andyzhangx/azuredisk-getdevfunc
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

fix warning messages due to GetMountRefs func not implemented in windows

**What this PR does / why we need it**:
This PR completes the windows implementation of GetMountRefs in mount.go. In linux, the GetMountRefs implementaion is: read `/proc/mounts` and find all mount points, while in Windows, there is no such `/proc/mounts` place which shows all mounting points. 
There is another way in windows, **we could walk through(by `getAllParentLinks` func) the mount path(symbolic link) and get all symlinks until we got the final device, which is actually a drive**.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #54670
This PR fixed the warnning issue mentioned in https://github.com/kubernetes/kubernetes/pull/51252

**Special notes for your reviewer**:
Some values in the code would be like follwoing:
```
GetMountRefs: mountPath ("\\var\\lib\\kubelet\\pods/4c74b128-92ca-11e7-b86b-000d3a36d70c/volumes/kubernetes.io~azure-disk/pvc-1cc91c70-92ca-11e7-b86b-000d3a36d70c")
getAllParentLinks: refs (["" "" "c:\\var\\lib\\kubelet\\plugins\\kubernetes.io\\azure-disk\\mounts\\b1246717734" "G:\\"])
basemountPath c:\var\lib\kubelet\plugins\kubernetes.io\azure-disk\mounts
got volumeID b1246717734
```

**Release note**:

```
fix warning messages due to GetMountRefs func not implemented in windows
```
2017-10-27 20:28:36 -07:00
Yecheng Fu a768092f9a RBD Plugin: Prepare to implement Attacher/Detacher interfaces.
1) Fix FakeMounter.IsLikelyNotMountPoint to return ErrNotExist if the
   directory does not exist. Mounter.IsLikelyNotMountPoint interface
   requires this, and RBD plugin depends on it.
2017-10-25 17:07:27 +08:00
andyzhangx 286d8ae287 add windows implementation of GetMountRefs
add unit test and fix according to comments

fix unit test issue

add const in getAllParentLinks func
2017-10-17 07:35:18 +00:00
Jeff Grafton aee5f457db update BUILD files 2017-10-15 18:18:13 -07:00
andyzhangx c9070ffa8c remove getAvailableDriveLetter func and test 2017-10-10 04:50:52 +00:00
andyzhangx 5275598d35 not necessary to use disk letter in azure file mount 2017-10-10 03:30:26 +00:00
Di Xu 542bd17e36 auto-gen 2017-09-26 09:57:13 +08:00
Di Xu 57ead4898b use GetFileType per mount.Interface to check hostpath type 2017-09-26 09:57:06 +08:00
Di Xu 46b0b3491f refactor nsenter to new pkg/util 2017-09-26 09:56:44 +08:00
Kubernetes Submit Queue 17ba22aa85 Merge pull request #52469 from andyzhangx/azurefile-mount-windows
Automatic merge from submit-queue (batch tested with PRs 52469, 52574, 52330, 52689, 52829). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>..

add feature: azurefile mount on windows node

**What this PR does / why we need it**:
feature: azurefile mount on windows node. I created this new PR, close the original one(https://github.com/kubernetes/kubernetes/pull/50233) as there is a big rebase change.
Currently only SMB(a nfs protocol) is supported for windows container in the new Windows 2016 RS3 image, and windows container in RS3 could only use New-SmbGlobalMapping cmdlet for volume mapping, "net use" command does not work for windows container.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:
As there is a known blocking issue in Windows 2016 server when mounting a SMB(a NFS protocol in Windows) share on a container host and then bind that share to a container ( Azure file on Windows is using SMB protocol), this PR still could not mount an azure file on current windows 2016 server node, it depends on 2016 RS3 release, and it will still succeed (as a workaround) if customer want to mount an azure file on current windows node.


Main code logic is similar to what it does in Linux node:

1. create target directory in Windows host
2. Use New-SmbGlobalMapping powershell cmdlet to mount SMB azure file to a drive in Windows host
3. Use mklink command to link target directory to the mounted drive

K8s would bind target directory to the container directory
source in mount function would be like:
`\\[accountname].file.core.windows.net\test`

target in mount function would be like:
`c:\var\lib\kubelet\pods\5f679f75-7ce3-11e7-b718-000d3a31dac4\volumes\kubernetes.io~azure-file`

sample azure file config file:
```
apiVersion: v1
kind: Pod
metadata:
 name: iis
spec:
 containers:
  - image: microsoft/iis
    name: iis
    volumeMounts:
      - name: azure
        mountPath: "d:"
 nodeSelector:
   beta.kubernetes.io/os: windows
 volumes:
      - name: azure
        azureFile:
          secretName: azure-secret
          shareName: k8stest
          readOnly: false
```

**Release note**:

```release-note
```
2017-09-23 21:52:46 -07:00
Kubernetes Submit Queue 7d9eb60837 Merge pull request #51518 from jianglingxia/jlx8291910
Automatic merge from submit-queue (batch tested with PRs 43016, 50503, 51281, 51518, 51582). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>..

double const in mount_linux.go

**What this PR does / why we need it**:
fix some typo and double const
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-09-22 23:35:59 -07:00
Kubernetes Submit Queue 980a8e6367 Merge pull request #50503 from karataliu/mount_clean
Automatic merge from submit-queue (batch tested with PRs 43016, 50503, 51281, 51518, 51582). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>..

Clean up diskLooksUnformatted literal

**What this PR does / why we need it**:
#16948 moved the `formatAndMount` function to mount_linux.go, but `diskLooksUnformatted` does not necessarily need to appear in mount_unsupported.go
#31515 Renames `diskLooksUnformatted` to `getDiskFormat`, but did not update the comment

This is to do the small cleanup.

**Which issue this PR fixes**

**Special notes for your reviewer**:

**Release note**:
2017-09-22 23:35:54 -07:00
andyzhangx 98487a0cde only allow cifs mount on windows node 2017-09-20 14:14:54 +00:00
andyzhangx faffe82df7 add feature: azurefile mount on windows node
fix according to review comments

add comments for SMB mount support on Windows
2017-09-20 07:15:25 +00:00
xiazhang 82c909cc99 enable azure disk mount on windows node
add initial work for mount azure file on windows

fix review comments

full implementation for attach azure file on windows node

working azure file mount

remove useless functions

add a workable implementation about mounting azure file on windows node

fix review comments and make the pod creating successful even azure file mount failed

fix according to review comments

add mount_windows_test

add implementation for IsLikelyNotMountPoint func

remove mount_windows_test.go temporaly

add back unit test for mount_windows.go

add normalizeWindowsPath func

fix normalizeWindowsPath func issue

implment azure disk on windows

update bazel BUILD

revert validation.go change as it's another PR

fix merge issue and compiling issue

fix windows compiling issue

fix according to review comments

fix according to review comments

fix cross-build failure

fix according to review comments

fix test build failure temporalily

fix darwin build failure

fix azure windows test failure

add empty implementation of MakeRShared on windows

fix gofmt errors
2017-09-12 01:52:48 +00:00
jianglingxia 4629c8a54e squash the commits into one 2017-09-04 09:44:53 +08:00
Jan Safranek d9500105d8 Share /var/lib/kubernetes on startup
Kubelet makes sure that /var/lib/kubelet is rshared when it starts.
If not, it bind-mounts it with rshared propagation to containers
that mount volumes to /var/lib/kubelet can benefit from mount propagation.
2017-08-30 16:45:04 +02:00
Serguei Bezverkhi 1be99dd78e Adding fsGroup check before mounting a volume
fsGroup check will be enforcing that if a volume has already been
mounted by one pod and another pod wants to mount it but has a different
fsGroup value, this mount operation will not be allowed.
2017-08-24 17:33:51 -04:00
Kubernetes Submit Queue 198e83588b Merge pull request #46458 from jsafrane/mount-prep
Automatic merge from submit-queue (batch tested with PRs 46458, 50934, 50766, 50970, 47698)

Prepare VolumeHost for running mount tools in containers

This is the first part of implementation of https://github.com/kubernetes/features/issues/278 - running mount utilities in containers.

It updates `VolumeHost` interface:

*  `GetMounter()` now requires volume plugin name, as it is going to return different mounter to different volume plugings, because mount utilities for these plugins can be on different places.
* New `GetExec()` method that should volume plugins use to execute any utilities. This new `Exec` interface will execute them on proper place.
* `SafeFormatAndMount` is updated to the new `Exec` interface.

This is just a preparation, `GetExec` right now leads to simple `os.Exec` and mount utilities are executed on the same place as before. Also, the volume plugins will be updated in subsequent PRs (split into separate PRs, some plugins required lot of changes).

```release-note
NONE
```

@kubernetes/sig-storage-pr-reviews 
@rootfs @gnufied
2017-08-21 18:11:16 -07:00
Kubernetes Submit Queue 990395d5ea Merge pull request #47506 from zhangxiaoyu-zidif/replace-sliceequal-by-deepequal
Automatic merge from submit-queue (batch tested with PRs 50693, 50831, 47506, 49119, 50871)

Use reflect.DeepEqual to replace slicesEqual

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes https://github.com/kubernetes/kubernetes/issues/50952

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-08-21 14:30:00 -07:00
Jan Safranek 0e547bae22 SafeFormatAndMount should use volume.Exec provided by VolumeHost
We need to execute mkfs / fsck where the utilities are.
2017-08-14 12:16:27 +02:00
Jan Safranek 282404cbc9 Add Exec interface to VolumeHost
This exec should be used by volume plugins to execute mount utilities.
It will eventually execute things in mount containers.
2017-08-14 12:16:25 +02:00
Jeff Grafton a7f49c906d Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
Jeff Grafton 33276f06be Use buildozer to remove deprecated automanaged tags 2017-08-11 09:31:50 -07:00
Jeff Grafton cf55f9ed45 Autogenerate BUILD files 2017-08-11 09:30:23 -07:00
Dong Liu a6ff000ea5 Clean up diskLooksUnformatted literal 2017-08-11 16:11:39 +08:00
Kubernetes Submit Queue 68ac78ae45 Merge pull request #49640 from jsafrane/systemd-mount-service
Automatic merge from submit-queue

Run mount in its own systemd scope.

Kubelet needs to run /bin/mount in its own cgroup.

- When kubelet runs as a systemd service, "systemctl restart kubelet" may kill all processes in the same cgroup and thus terminate fuse daemons that are needed for gluster and cephfs mounts.

- When kubelet runs in a docker container, restart of the container kills all fuse daemons started in the container.

Killing fuse daemons is bad, it basically unmounts volumes from running pods.

This patch runs mount via "systemd-run --scope /bin/mount ...", which makes sure that any fuse daemons are forked in its own systemd scope (= cgroup) and they will survive restart of kubelet's systemd service or docker container.

This helps with #34965

As a downside, each new fuse daemon will run in its own transient systemd service and systemctl output may be cluttered.

@kubernetes/sig-storage-pr-reviews 
@kubernetes/sig-node-pr-reviews 

```release-note
fuse daemons for GlusterFS and CephFS are now run in their own systemd scope when Kubernetes runs on a system with systemd.
```
2017-08-09 12:05:01 -07:00
Jan Safranek dd03384747 Detect systemd on mounter startup 2017-08-08 15:40:27 +02:00
Kubernetes Submit Queue 5d24a2c199 Merge pull request #49300 from tklauser/syscall-to-x-sys-unix
Automatic merge from submit-queue

Switch from package syscall to golang.org/x/sys/unix

**What this PR does / why we need it**:

The syscall package is locked down and the comment in https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24 advises to switch code to use the corresponding package from golang.org/x/sys. This PR does so and replaces usage of package syscall with package golang.org/x/sys/unix where applicable. This will also allow to get updates and fixes
without having to use a new go version.

In order to get the latest functionality, golang.org/x/sys/ is re-vendored. This also allows to use Eventfd() from this package instead of calling the eventfd() C function.

**Special notes for your reviewer**:

This follows previous works in other Go projects, see e.g. moby/moby#33399, cilium/cilium#588

**Release note**:

```release-note
NONE
```
2017-08-03 04:02:12 -07:00
Jan Safranek 5a8a6110a2 Run mount in its own systemd scope.
Kubelet needs to run /bin/mount in its own cgroup.

- When kubelet runs as a systemd service, "systemctl restart kubelet" may kill
  all processes in the same cgroup and thus terminate fuse daemons that are
  needed for gluster and cephfs mounts.

- When kubelet runs in a docker container, restart of the container kills all
  fuse daemons started in the container.

Killing fuse daemons is bad, it basically unmounts volumes from running pods.

This patch runs mount via "systemd-run --scope /bin/mount ...", which makes
sure that any fuse daemons are forked in its own systemd scope (= cgroup) and
they will survive restart of kubelet's systemd service or docker container.

As a downside, each new fuse daemon will run in its own transient systemd
service and systemctl output may be cluttered.
2017-07-26 16:14:39 +02:00
Tobias Klauser 4a69005fa1 switch from package syscall to x/sys/unix
The syscall package is locked down and the comment in [1] advises to
switch code to use the corresponding package from golang.org/x/sys. Do
so and replace usage of package syscall with package
golang.org/x/sys/unix where applicable.

  [1] https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24

This will also allow to get updates and fixes for syscall wrappers
without having to use a new go version.

Errno, Signal and SysProcAttr aren't changed as they haven't been
implemented in /x/sys/. Stat_t from syscall is used if standard library
packages (e.g. os) require it. syscall.SIGTERM is used for
cross-platform files.
2017-07-21 12:14:42 +02:00
Kubernetes Submit Queue feed4aa12a Merge pull request #49234 from mengqiy/master
Automatic merge from submit-queue (batch tested with PRs 49107, 47177, 49234, 49224, 49227)

Move util/exec to vendor

Move util/exec to vendor.
Update import paths.
Update godep

Part of #48209

Associate PR against `k8s.io/utils` repo: https://github.com/kubernetes/utils/pull/5

```release-note
NONE
```

/assign @apelisse
2017-07-20 15:08:22 -07:00
ymqytw 9b393a83d4 update godep 2017-07-20 11:03:49 -07:00
ymqytw 3dfc8bf7f3 update import 2017-07-20 11:03:49 -07:00
Jan Safranek 87551071a1 Fix findmnt parsing in containerized kubelet
NsEnterMounter should not stop parsing findmnt output on the first space but
on the last one, just in case the mount point name itself contains a space.
2017-07-18 13:35:44 +02:00
Ian Chakeres 2b18d3b6f7 Fixes bind-mount teardown failure with non-mount point Local volumes
Added IsNotMountPoint method to mount utils (pkg/util/mount/mount.go)
Added UnmountMountPoint method to volume utils (pkg/volume/util/util.go)
Call UnmountMountPoint method from local storage (pkg/volume/local/local.go)
IsLikelyNotMountPoint behavior was not modified, so the logic/behavior for UnmountPath is not modified
2017-07-11 17:19:58 -04:00
zhangxiaoyu-zidif f528bce5c6 Use reflect.DeepEqual to replace sliceEqual 2017-06-14 16:25:43 +08:00
Mike Danese a05c3c0efd autogenerated 2017-04-14 10:40:57 -07:00
Jan Safranek 4cf36b8b39 Do not reformat devices with partitions
lsblk reports FSTYPE of devices with partition tables as empty string "",
which is indistinguishable from empty devices. We must look for dependent
devices (i.e. partitions) to see that the device is really empty and report
error otherwise.

I checked that LVM, LUKS and MD RAID have their own FSTYPE in lsblk output,
so it should be only a partition table that has empty FSTYPE.

The main point of this patch is to run lsblk without "-n", i.e. print all
dependent devices and check if they're there.
2017-03-20 13:08:13 +01:00