Commit Graph

200 Commits

Author SHA1 Message Date
Jan Safranek
e575e60ea4 Reconstruct SELinux mount option
When reconstructing volumes from disk after kubelet restart, reconstruct
also context=XYZ mount option and add it to the ActualStateOfWorld.
2022-11-08 11:17:38 +01:00
Jan Safranek
fc245b339b Refactor ConstructVolumeSpec
Return a struct from ConstructVolumeSpec to be able to add more fields to
it later.
2022-11-03 16:55:13 +01:00
Jan Safranek
63ab1c86e7 Add SELinux mount support to all volume plugins
.. that are not migrated to CSI in 1.26 *and* are based on a block device.
NFS and CephFS may use the same volume as several PVs and then mounting
with -o context won't work.
2022-10-31 13:02:51 +01:00
Humble Chirammal
f22a74aa6a various corrections in pkg/volume
Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
2022-09-16 16:42:06 +05:30
Jan Safranek
cdb3ead5a9 Add SupportsSELinuxContextMount
Add a new call to VolumePlugin interface and change all its
implementations.

Kubelet's VolumeManager will be interested whether a volume supports
mounting with -o conext=XYZ or not to hanle SetUp() / MountDevice()
accordingly.
2022-08-04 10:51:28 +02:00
Claudiu Belu
38092cb458 unittests: Fixes unit tests for Windows (part 2)
Currently, there are some unit tests that are failing on Windows due to
various reasons:

- volume mounting is a bit different on Windows: Mount will create the
  parent dirs and mklink at the volume path later (otherwise mklink will
  raise an error).
- os.Chmod is not working as intended on Windows.
- path.Dir() will always return "." on Windows, and filepath.Dir()
  should be used instead (which works correctly).
- on Windows, you can't typically run binaries without extensions. If
  the file C:\\foo.bat exists, we can still run C:\\foo because Windows
  will append one of the supported file extensions ($env:PATHEXT) to it
  and run it.
- Windows file permissions do not work the same way as the Linux ones.
- /tmp directory being used, which might not exist on Windows. Instead,
  the OS-specific Temp directory should be used.

Fixes a few other issues:

- rbd.go: Return error in a case in which an error is encountered. This
  will prevent "rbd: failed to setup" and "rbd: successfully setup" log
  messages to be logged at the same time.
2022-08-01 18:56:32 +03:00
Davanum Srinivas
a9593d634c
Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2022-07-26 13:14:05 -04:00
xakdwch
ddcc448070 volume/fc: fix FibreChannel volume plugin matching wrong disks
Before:
  findDisk()
    fcPathExp := "^(pci-.*-fc|fc)-0x" + wwn + "-lun-" + lun
After:
  findDisk()
    fcPathExp := "^(pci-.*-fc|fc)-0x" + wwn + "-lun-" + lun + "$"

fc path may have the same wwns but different luns.for example:
pci-0000:41:00.0-fc-0x500a0981891b8dc5-lun-1
pci-0000:41:00.0-fc-0x500a0981891b8dc5-lun-12

Function findDisk() may mismatch the fc path, return the wrong device and wrong associated devicemapper parent.
This may cause a disater that pods attach wrong disks. Accutally it happended in my testing environment before.
2022-06-23 16:36:01 +08:00
Kubernetes Prow Robot
06e107081e
Merge pull request #104732 from mengjiao-liu/remove-flag-experimental-check-node-capabilities-before-mount
kubelet: Remove the deprecated flag `--experimental-check-node-capabilities-before-mount`
2022-02-24 07:56:30 -08:00
Jan Safranek
525b8e5cd6 Rename SupportsSELinux to SELinuxRelabel
The field in fact says that the container runtime should relabel a volume
when running a container with it, it does not say that the volume supports
SELinux. For example, NFS can support SELinux, but we don't want NFS
volumes relabeled, because they can be shared among several Pods.
2022-02-16 10:54:08 +01:00
Nikhil Sharma
4eaa533777 added devicePath check for fcDisk 2022-01-07 20:10:03 +05:30
Mengjiao Liu
beda4cafb6 kubelet: Remove the deprecated flag --experimental-check-node-capabilities-before-mount 2022-01-06 11:47:11 +08:00
Davanum Srinivas
497e9c1971
Cleanup OWNERS files (No Activity in the last year)
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-12-15 10:34:02 -05:00
Davanum Srinivas
9405e9b55e
Check in OWNERS modified by update-yamlfmt.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2021-12-09 21:31:26 -05:00
Cheng Xing
0e315355df Pass FsGroup to MountDevice 2021-07-03 16:29:42 -07:00
Kubernetes Prow Robot
38783bfeb7
Merge pull request #102059 from jsafrane/fix-consistentread
Retry reading /proc/mounts when unable to get a consistent read
2021-06-03 21:59:37 -07:00
Jan Safranek
f9a04f3bc4 Move error reporting to volume plugins
Move reporting of GetReliableMountRefs error to the volume plugins that
have more context about severity of the error.
2021-05-27 18:30:17 +02:00
Kubernetes Prow Robot
81e159f0b0
Merge pull request #101862 from jsafrane/fix-fc-detach-retry
Retry detaching FibreChannel volume few times
2021-05-27 07:14:23 -07:00
Kubernetes Prow Robot
f7e62dc5bb
Merge pull request #100746 from mengjiao-liu/fix-nil-call
Fixed a possible nil pointer dereference caused by variable `plug`
2021-05-26 14:49:38 -07:00
Jan Safranek
a95842095e Retry reading /proc/mounts indifinetly in FC and iSCSI volume reconstruction
iSCSI and FC volume plugins do not implement real 3rd party attach/detach.
If reconstruction fails with an error on a FC or iSCSI volume, it will not
be unmounted from the volume global dir and at the same time it will be
marked as unused, to be available to be mounted on another node.

The volume can then be mounted on several nodes, resulting in volume
corruption.

The other block based volume plugins implement attach/detach that either
makes the volume stuck (can't be detached) or will be force-detached from a
node before attaching it somewhere else.
2021-05-26 23:08:19 +02:00
Jan Safranek
64e8396e30 Retry detaching FibreChannel volume few times
When UnmountDevice() of a FibreChannel volume fails after unmounting the
device and before the device is fully cleaned up, subsequent
UnmountDevice() retry won't find the device mounted and return without
retrying the device cleanup.

Therefore implement its own retry inside UnmountDevice() to make sure that
the volume devices are either fully cleaned or the error is serius enough
that even 1 minute of trying does not help.
2021-05-26 23:05:06 +02:00
mengjiao.liu
c24b87b133 Fixed a possible nil pointer dereference caused by variable plug 2021-05-21 10:17:04 +08:00
Niels de Vos
e7dedc5cd1 Support Capacity metric for block PVCs for in-tree drivers
PR #97972 added support for gathering metrics for Block PVCs provided by
CSI drivers. The in-tree drivers can support at leas the most basic
metric; Capacity.
2021-05-20 16:37:12 +02:00
wangyx1992
7fe934a72d cleanup: fix log capitalization in volume package
Signed-off-by: wangyx1992 <wang.yixiang@zte.com.cn>
2021-04-14 21:58:56 +08:00
Benjamin Elder
56e092e382 hack/update-bazel.sh 2021-02-28 15:17:29 -08:00
Kubernetes Prow Robot
8b24d1f2f9
Merge pull request #96806 from CKchen0726/master
remove input parameter that is invalid before
2021-01-05 13:27:53 -08:00
Jan Safranek
8f186f9172 Flush FibreChannel devices before deleting
If a FibreChannel device is used as a block volume, we should flush its I/O
before deleting its device. It is not strictly necessary when it's used as
a filesystem (mount), but it won't hurt either.
2020-12-03 09:54:22 +01:00
Jan Safranek
6f8bdb7cc1 Fix FibreChannel volume plugin corrupting filesystem on detach
FibreChannel volume plugin misses one important step when removing a
device: "multipath -f". It flushes all multipath buffers to its individual
paths. Without it, a filesystem on the device may get corrupted.
2020-12-02 14:39:00 +01:00
CKchen0726
a3fdab491a use input parameter that is invalid before 2020-11-26 17:04:55 +08:00
Shihang Zhang
d2859cd89b plumb service account token down to csi driver 2020-11-12 09:26:43 -08:00
jornshen
db53ca01da change plugin name in fsgroupapplymetrics of csi and flexvolume to
distinguish different driver
2020-11-04 16:28:28 +08:00
jornshen
4ed7709774 Report a metric for time taken to perform recursive permission change 2020-10-26 21:04:30 +08:00
Kubernetes Prow Robot
d970c18ab8
Merge pull request #95451 from mkumatag/fix_fc
Fix fcpath
2020-10-15 07:10:39 -07:00
Manjunath A Kumatagi
4a75c7ef1e Fix fcpath 2020-10-14 21:15:22 +05:30
tashen
27cb5cf4f0 add systemd mount options interface to support the no-systemd mount 2020-10-13 13:46:57 +08:00
Kubernetes Prow Robot
796f9d89ba
Merge pull request #94781 from ejweber/fc-attacher-empty-devname
Don't attempt to detach an FC device if we don't know its name
2020-09-22 18:34:22 -07:00
Srini Brahmaroutu
fbe5daed73 Change code to use staging/k8s.io/mount-utils 2020-09-16 21:51:24 -07:00
Eric Weber
5cd63097ba Don't attempt to detach an FC device if we don't know its name 2020-09-14 14:32:00 -05:00
Davanum Srinivas
07d88617e5
Run hack/update-vendor.sh
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:33 -04:00
Davanum Srinivas
442a69c3bd
switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2020-05-16 07:54:27 -04:00
Jan Safranek
58129fd12c Fix mount options in FibreChannel volumes
Do not mount volumes in WaitForAttach(), mount them in MountDevice()
instead. They will get proper mount options this way.
2020-03-26 18:01:19 +01:00
Hemant Kumar
c52d4bf32f Implement changes into volume plugins for skipping chown
Add a separate function for walking directories
2020-03-04 21:23:31 -05:00
Jan Safranek
3af671011a Generated API 2020-03-02 22:21:42 +01:00
Jan Safranek
2c1b743766 Promote block volume features to GA 2020-02-28 20:48:38 +01:00
Kubernetes Prow Robot
6d4e2d722e
Merge pull request #87381 from yuxiaobo96/k8s-staticcheck3
staticcheck: pkg/volume/fc, pkg/volume/portworx and pkg/volume/vspher…
2020-02-07 18:32:58 -08:00
Eric Weber
adcdb2fd72 Enable FC mount options 2020-02-03 16:13:58 -06:00
yuxiaobo
72f34b817e staticcheck: pkg/volume/fc, pkg/volume/portworx and pkg/volume/vsphere_volume
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
2020-01-20 16:47:54 +08:00
David Zhu
21f7060c8f Plumb test state through to fake volume host creation for error handling 2019-11-18 14:45:01 -08:00
Travis Rhoden
0c5c3d8bb9
Remove pkg/util/mount (moved out of tree)
This patch removes pkg/util/mount completely, and replaces it with the
mount package now located at k8s.io/utils/mount. The code found at
k8s.io/utils/mount was moved there from pkg/util/mount, so the code is
identical, just no longer in-tree to k/k.
2019-11-15 08:29:12 -07:00
Kubernetes Prow Robot
372ebd24f5
Merge pull request #83098 from ddebroy/disable-intree
CSI Migration phase 2: disable probing of in-tree plugins
2019-11-14 20:51:42 -08:00