Commit Graph

94 Commits

Author SHA1 Message Date
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
Kubernetes Prow Robot
7b9f4f18fe
Merge pull request #105135 from astraw99/fix-nil-mergeMap
Fix nil check in map merge
2021-11-12 02:26:27 -08:00
astraw99
9fe2c30609 fix nil merge map 2021-11-11 10:56:55 +08:00
Jan Safranek
186810eb47 Don't guess SELinux support on error
When GetSELinuxSupport() fails, don't assume a mounted filesystem does not
support SELinux at all. Try again instead in the next SetUp retry.

This may hurt performance a bit, since kubelet will call NodePublishVolume
again, but it's better than providing wrong information to the container
runtime that will then skip relabeling of the volume.
2021-10-27 12:00:07 +02:00
astraw99
5e789f157c fix CSI mount log 2021-10-14 10:27:50 +08:00
Cheng Xing
c50b3074fe Moved VOLUME_MOUNT_GROUP capability check from NodeStageVolume to MountDevice; added log message in SetupAt to indicate FSGroup is delegated to driver 2021-07-03 16:29:42 -07:00
Cheng Xing
ae5668edef Pass FsGroup to NodePublishVolume 2021-07-03 16:29:42 -07:00
Shihang Zhang
8231a3e921 CSIServiceAccountToken ga 2021-06-21 11:35:24 -07:00
Shiming Zhang
c065d7c7b3 Fix NPE for CSI mounter 2021-06-08 10:29:46 +08:00
Jonathan Dobson
260426bf44 clarify deprecation comment 2021-04-27 17:52:40 -06:00
Jonathan Dobson
75a7966414 move deprecation comment to TearDownAt function 2021-04-27 11:40:12 -06:00
Jonathan Dobson
e92dc8d9be Deprecate removal of CSI nodepublish path by kubelet (#101332) 2021-04-27 08:41:47 -06:00
phantooom
82c2266f25 chore: make csi getPodInfoAttrs func private 2021-04-15 20:51:51 +08:00
phantooom
31aa15284f kubelet: fix raw block mode CSI NodePublishVolume stage miss pod info 2021-02-21 23:46:50 +08:00
Jiawei Wang
43bc6fa806 Add csi_operations_seconds metrics on kubelet 2021-02-17 13:38:27 -08:00
Shihang Zhang
d2859cd89b plumb service account token down to csi driver 2020-11-12 09:26:43 -08:00
Kubernetes Prow Robot
2b4be7bb5f
Merge pull request #88759 from andyzhangx/csi-dir-fix
feat: ignore mount dir check in csi node stage/publish
2020-11-09 16:08:40 -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
Srini Brahmaroutu
fbe5daed73 Change code to use staging/k8s.io/mount-utils 2020-09-16 21:51:24 -07:00
Hemant Kumar
ade2f83685 Simplify the code 2020-07-11 23:29:24 -04:00
Christian Huffman
58bd3e5230 Include CSIDriver SupportsFsGroup 2020-07-11 23:29:24 -04:00
Kubernetes Prow Robot
14c69640d0
Merge pull request #87166 from jingxu97/Jan/mountcheckfix
Fix issue in kubelet getMountedVolumePathListFromDisk
2020-06-25 09:45:39 -07:00
Jing Xu
7012994a61 Fix issue in kubelet getMountedVolumePathListFromDisk
This PR fixes issue #74650. It adds the extra check for /mount dir under
pod volume dir. It also adds the unit test for this function
2020-06-22 10:00:43 -07: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
andyzhangx
8d5c65b8cd fix: comments(only create parent dir) 2020-04-21 07:15:02 +00:00
Mark Janssen
2c61627f8c Fix staticcheck failures for pkg/volume/...
Errors from staticcheck:
pkg/volume/azure_dd/azure_common.go:68:2: var winDiskNumFormat is unused (U1000)
pkg/volume/csi/csi_block.go:97:2: field volumeInfo is unused (U1000)
pkg/volume/csi/csi_block_test.go:56:6: func prepareBlockUnmapperTest is unused (U1000)
pkg/volume/csi/csi_client.go:108:2: const initialDuration is unused (U1000)
pkg/volume/csi/csi_client.go:109:2: const factor is unused (U1000)
pkg/volume/csi/csi_client.go:110:2: const steps is unused (U1000)
pkg/volume/csi/csi_client_test.go:83:8: this value of err is never used (SA4006)
pkg/volume/csi/csi_mounter.go:76:2: field options is unused (U1000)
pkg/volume/csi/csi_mounter_test.go:454:13: this value of err is never used (SA4006)
pkg/volume/csi/csi_plugin_test.go:766:16: this value of err is never used (SA4006)
pkg/volume/csi/csi_plugin_test.go:861:13: this value of err is never used (SA4006)
pkg/volume/csi/csi_plugin_test.go:1186:13: this value of err is never used (SA4006)
pkg/volume/csi/csi_plugin_test.go:1249:13: this value of err is never used (SA4006)
pkg/volume/csi/csi_test.go:305:5: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002)
pkg/volume/flexvolume/probe_test.go:67:10: this value of err is never used (SA4006)
pkg/volume/iscsi/iscsi_test.go:95:2: field attachCalled is unused (U1000)
pkg/volume/iscsi/iscsi_test.go:96:2: field detachCalled is unused (U1000)
pkg/volume/iscsi/iscsi_test.go:501:24: this value of err is never used (SA4006)
pkg/volume/iscsi/iscsi_util_test.go:159:2: this value of exist is never used (SA4006)
pkg/volume/local/local.go:351:57: argument devicePath is overwritten before first use (SA4009)
pkg/volume/plugins_test.go:119:2: this value of plug is never used (SA4006)
pkg/volume/plugins_test.go:125:2: this value of plug is never used (SA4006)
pkg/volume/quobyte/quobyte.go:474:23: this result of append is never used, except maybe in other appends (SA4010)
pkg/volume/quobyte/quobyte.go:477:23: this result of append is never used, except maybe in other appends (SA4010)
pkg/volume/quobyte/quobyte.go:480:23: this result of append is never used, except maybe in other appends (SA4010)
pkg/volume/rbd/rbd.go:886:2: field adminSecret is unused (U1000)
pkg/volume/rbd/rbd.go:887:2: field adminID is unused (U1000)
pkg/volume/rbd/rbd.go:888:2: field imageFormat is unused (U1000)
pkg/volume/rbd/rbd.go:889:2: field imageFeatures is unused (U1000)
pkg/volume/storageos/storageos.go:302:2: field secretName is unused (U1000)
pkg/volume/storageos/storageos_util_test.go:43:2: field apiAddr is unused (U1000)
pkg/volume/storageos/storageos_util_test.go:44:2: field apiUser is unused (U1000)
pkg/volume/storageos/storageos_util_test.go:45:2: field apiPass is unused (U1000)
pkg/volume/storageos/storageos_util_test.go:46:2: field apiVersion is unused (U1000)
pkg/volume/util/atomic_writer_test.go:756:49: argument err is overwritten before first use (SA4009)
pkg/volume/util/fsquota/common/quota_linux_common.go:37:2: const acct is unused (U1000)
pkg/volume/util/fsquota/common/quota_linux_common.go:38:2: const enforcing is unused (U1000)
pkg/volume/util/fsquota/project.go:168:31: identical expressions on the left and right side of the '==' operator (SA4000)
pkg/volume/util/fsquota/quota_linux.go:306:50: argument poduid is overwritten before first use (SA4009)
pkg/volume/util/fsquota/quota_linux_test.go:558:16: this value of err is never used (SA4006)
pkg/volume/util/subpath/subpath_linux.go:232:81: argument err is overwritten before first use (SA4009)
pkg/volume/util/subpath/subpath_linux_test.go:579:73: argument err is overwritten before first use (SA4009)
2020-04-09 22:08:07 +02:00
Christian Huffman
c6fd25d100 Updated CSIDriver references 2020-03-06 08:21:26 -05: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
andyzhangx
b3a27c44bf fix comments 2020-03-04 11:33:06 +00:00
andyzhangx
0c81a2f6b0 fix: ignore dir check in csi node stage/publish 2020-03-03 11:55:48 +00:00
andyzhangx
5a6435ad76 fix: corrupted mount point in csi driver
add test

fix build failure and bazel

fix golint
2020-02-26 09:43:51 +00:00
Krishnakumar R(KK)
72fe307b35 Move 'path' package usage to 'path/filepath'.
In case of windows, the path package functions such as 'Dir' returns faulty directory path.
For eg: 'path.Dir' on 'c:\var\lib\kubelet\pods' returns '.', where as the result should
have been 'c:\var\lib\kubelet'. The filepath package returns the right values.
2020-01-30 15:53:18 -08:00
danielqsj
5bc0e26c19 unify alias of api errors under pkg and staging 2019-12-26 16:42:28 +08:00
Hemant Kumar
4b8e552a88 Use typed errors for special casing volume progress
Use typed errors rather than operation status for
indicating operation progress
2019-12-04 14:48:30 -05:00
Hemant Kumar
309c6f863a Handle the case of remounts correctly 2019-12-02 12:09:38 -05:00
Hemant Kumar
5feea93163 Rename MarkVolumeMountedOpts to MarkVolumeOpts
Also remove VolumeNotMounted state
2019-12-02 12:09:38 -05:00
Hemant Kumar
cdbd3ba5c2 Change interface of SetUp function 2019-12-02 12:09:38 -05:00
Hemant Kumar
57019e0628 Add tests for verifying in-progress state 2019-12-02 12:09:38 -05:00
Hemant Kumar
321e99367a Add code to handle Setup With Status tracking 2019-12-02 12:09:38 -05:00
Hemant Kumar
34a6007dfe Add code to mark volume as uncertain
Update bazel files
Add tests for volume mounts in uncertain state
2019-12-02 12:01:40 -05:00
John Strunk
55881f2fc4
Improve efficiency of csiMountMgr.GetAttributes
GetAttributes is called repeatedly while setting the fsGroup of a
volume. Previously, it recalculated whether SELinux was supported during
each call. This resulted in volume.SetVolumeOwnership taking a long
time, delaying pod startup for high file count volumes.

This change checks the SELinux status once, right after node publish,
allowing GetAttributes to simply build and return a struct.

Signed-off-by: John Strunk <jstrunk@redhat.com>
2019-10-10 13:51:50 -04:00
Patrick Ohly
7bbc06fcd4 storage: check CSIDriver.Spec.VolumeLifecycleModes
Using a "normal" CSI driver for an inline ephemeral volume may have
unexpected and potentially harmful effects when the driver gets a
NodePublishVolume call that it isn't expecting. To prevent that mistake,
driver deployments for a driver that supports such volumes must:
- deploy a CSIDriver object for the driver
- set CSIDriver.Spec.VolumeLifecycleModes such that it contains "ephemeral"

The default for that field is "persistent", so existing deployments
continue to work and are automatically protected against incorrect
usage.

For the E2E tests we need a way to specify the driver mode. The
existing cluster-driver-registrar doesn't support that and also was
deprecated, so we stop using it altogether and instead deploy and
patch a CSIDriver object.
2019-08-13 23:12:52 +02:00
Kubernetes Prow Robot
3a4cda9def
Merge pull request #80522 from ethan-daocloud/patch-3
cleanup: remove duplicated logging error message in csi_mounter.go, also some typos.
2019-07-31 22:36:39 -07:00
ethan
ec2c5dff43 fix some log typos in csi_mounter.go
cleanup: remove logging duplicated error message
fix error msg, include err in new returned errors.
Signed-off-by: ethan <guangming.wang@daocloud.io>
2019-08-01 02:39:32 +00:00
Patrick Ohly
555ff7ef10 CSI: allow drivers that can handle persistent and ephemeral volumes
The conceptual change is that the mode in which a volume gets handled
is derived from it's spec, not from the ability of the driver. In
practice, that is already how the code worked because it didn't
actually look at CSIDriver.Spec.Mode at all.

Therefore the code change itself is mostly just renaming "driver mode"
to "volume mode". In some places (CanDeviceMount, CanAttach) the
feature check that was used elsewhere seemed to be missing. Now their
code path for ephemeral volumes are also only entered if that feature
is enabled.

The sanity check whether a CSI driver is being used correctly still
needs to be implemented.

Related-to: https://github.com/kubernetes/kubernetes/issues/79624
2019-07-25 16:45:46 +02:00
Travis Rhoden
be7da5052f Refactor pkg/util/mount to be more reusable
This patch refactors pkg/util/mount to be more usable outside of
Kubernetes. This is done by refactoring mount.Interface to only contain
methods that are not K8s specific. Methods that are not relevant to
basic mount activities but still have OS-specific implementations are
now found in a mount.HostUtils interface.
2019-06-14 09:35:18 -06:00
Robert Krawitz
5b97b2860d Change fsGroup to mounterArgs in volume.SetUp() to allow for future extension. 2019-05-29 15:12:28 -04:00
Kubernetes Prow Robot
fad34e404e
Merge pull request #76188 from humblec/csi-in-m
csi: Implement NodeServiceCapability_RPC_GET_VOLUME_STATS rpc call
2019-05-17 20:26:09 -07:00
Humble Chirammal
c511c90b59 csi: Implement NodeServiceCapability_RPC_GET_VOLUME_STATS rpc call
and implement Metrics Provider for CSI driver

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
2019-05-17 17:10:53 +05:30