Commit Graph

65 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
Fabio Bertinatto
b19172c58f Promote DelegateFSGroupToCSIDriver feature to GA 2022-11-04 07:26:17 -03:00
Kubernetes Prow Robot
7d9c0e0a78
Merge pull request #113411 from jsafrane/fix-selinux-context-mount
Fix SELinux context mount with unknown context
2022-10-31 17:00:44 -07:00
Jan Safranek
8dd3510032 Fix SELinux context mount with unknown context
Don't mount with SELinux mount option if kubelet does not know the SELinux
context, i.e. MounterArgs.SELinuxLabel is ""
2022-10-31 19:11:48 +01:00
Kubernetes Prow Robot
a74e16fc81
Merge pull request #113306 from jsafrane/csidriver-setup
Move CSIDriver checks from NewMounter to SetUpAt
2022-10-26 17:08:43 -07:00
Jan Safranek
483fd45e8e Move fsGroupPolicy from NewMounter to SetUpAt
getFSGroupPolicy needs to get CSIDriver from the API server, which may not
be available during volume reconstruction at kubelet startup.
2022-10-25 11:10:11 +02:00
Jan Safranek
04183005e4 Move lifecycle checks from NewMounter to SetUpAt
The checks need to get CSIDriver from the API server and the API server may
not be the case when NewMounter is called during volume reconstruction.
2022-10-24 17:30:51 +02:00
Jan Safranek
f76efd0400 Move CSI json file saving to SetUpAt()
When saving a json state file in NewMounter, we risk the json file will not
be cleaned when SetUpAt() fails. Move it to SetUpAt() instead.
2022-10-18 14:19:06 +02:00
Hemant Kumar
8d1e2e0faa Do not return err if CSIdriver is not found
while checking for selinux support
2022-09-16 15:53:03 -04:00
Jonathan Dobson
5f774832a5 Move CSIInlineVolume feature to GA 2022-08-04 13:06:30 -06:00
Jan Safranek
5c90474f38 Add SELinux mount support to CSI driver
With some minor refactoring to use common getCSIDriver function.
2022-08-04 10:51:45 +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
Abirdcfly
00b9ead02c cleanup: remove duplicate import
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-07-14 11:25:19 +08:00
Jonathan Dobson
88a1962e56 CSI inline volumes should support fsGroup 2022-03-11 16:14:06 -07:00
Jonathan Dobson
082cb15648 Move CSIVolumeFSGroupPolicy feature to GA 2021-11-02 15:22:33 -06: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
1eb8060dd6 Add test for CSI mounter 2021-06-08 18:42:31 +08:00
卢振兴10069964
b3fea118dc code cleanup for pkg volume csi 2021-04-12 08:36:53 +08:00
Shihang Zhang
d2859cd89b plumb service account token down to csi driver 2020-11-12 09:26:43 -08:00
Christian Huffman
58bd3e5230 Include CSIDriver SupportsFsGroup 2020-07-11 23:29:24 -04: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
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
Mike Danese
25651408ae generated: run refactor 2020-02-08 12:30:21 -05:00
Mike Danese
3aa59f7f30 generated: run refactor 2020-02-07 18:16:47 -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
cdbd3ba5c2 Change interface of SetUp function 2019-12-02 12:09:38 -05:00
Hemant Kumar
0c52b6606e Refactor NodeStage function
Timeout operations should result in
Fix unit tests for uncertainDeviceGlobalMounts
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
David Zhu
1a47bf54e2 De-race some CSI unit tests that were initializing the plugin manager…ger (and plugins) twice. Set some const variables earlier to support node info manager initialization and wait for initialization to complete before finishing plugin setup. 2019-11-15 11:23:32 -08:00
Patrick Ohly
599a9faf8d storage: make tests independent of CSIInlineVolume default
Some tests assumed instead of ensuring that the CSIInlineVolume
feature is disabled.
2019-08-28 05:32:44 +02: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
4ce69dd32e
Merge pull request #80848 from cwdsuzhou/Aug/fix_ut
Fix some unreasonable places int csi ut
2019-08-01 03:30:14 -07:00
caiweidong
7b5dac03ce Fix some unreasonable places int csi ut 2019-08-01 14:19:11 +08: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
Robert Krawitz
5b97b2860d Change fsGroup to mounterArgs in volume.SetUp() to allow for future extension. 2019-05-29 15:12:28 -04:00
Andrew Kim
c919139245 update import of generic featuregate code from k8s.io/apiserver/pkg/util/feature -> k8s.io/component-base/featuregate 2019-05-08 10:01:50 -04:00
Travis Rhoden
78d109e201 Always use filepath.Join instead of path.Join
This patch cleans up pkg/util/mount/* and pkg/util/volume/* to always
use filepath.Join instead of path.Join. filepath.Join is preferred
because path.Join can have issues on Windows.
2019-04-29 09:56:05 -06:00
Vladimir Vivien
b138e6d1e2 CSI - Surfaces klog flags; common tests aggregation 2019-04-12 15:38:06 -04:00
Xing Yang
000ab86788 Move CSIDriver Lister to the controller 2019-04-05 12:20:11 -07:00
Vladimir Vivien
923ad369c8 CSI Inline Volume - Kubelet/Driver code impl 2019-03-08 12:40:09 -05:00
Xing Yang
6265f4f78c CSINodeInfo/CSIDriver controller changes
This is the 2nd PR to move CSINodeInfo/CSIDriver APIs to
v1beta1 core storage APIs. It includes controller side changes.
It depends on the PR with API changes:
https://github.com/kubernetes/kubernetes/pull/73883
2019-03-04 16:41:58 -08:00
Andrew Kim
01933b02a3 replace usage of v1beta1 VolumeAttachments with v1 2019-02-27 15:42:12 -05:00
David Zhu
5dde1df1cd Migration shim logic for Persistent Volumes for Attach/Detach 2019-02-14 17:04:23 -08:00
saad-ali
aa8244beb5 Modify CSI to handle both 0.3 and 1.0
Modify the CSI volume plugin to handle CSI version 0.x as well as 1.x
2018-11-21 18:37:31 -08:00
saad-ali
09d3dce38a Update CSI client to pick up CSI v1.0.0 changes 2018-11-15 16:39:59 -08:00
Davanum Srinivas
954996e231
Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog
- klog as explicit InitFlags() so we add them as necessary
- we update the other repositories that we vendor that made a similar
change from glog to klog
  * github.com/kubernetes/repo-infra
  * k8s.io/gengo/
  * k8s.io/kube-openapi/
  * github.com/google/cadvisor
- Entirely remove all references to glog
- Fix some tests by explicit InitFlags in their init() methods

Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135
2018-11-10 07:50:31 -05:00
Ben Swartzlander
85b224856d Add unit tests for CSI mount options 2018-10-12 12:16:20 -04:00
Vladimir Vivien
e3bc731143 CSI fix for proper fsgroup application to volume 2018-09-14 14:58:18 -04:00