Commit Graph

78 Commits

Author SHA1 Message Date
Jan Safranek
9a9c216825 iscsi: don't write json medata file when the volume is already mounted.
iSCSI volume plugin persists volume metadata into global mount directory,
before it is mounted. Content of the directory is shadowed by the volume
mount. Therefore kubelet should not write metadata to the directory when a
second pod uses the same volume on the same node.

1. The metadata were already persisted before mounting the volume for the
first pod.
2. The global mount directory has the volume mounted, so any write there
would write to the volume, which is undesirable.
2020-06-17 20:09:54 +02:00
Kubernetes Prow Robot
2fa00e30ce
Merge pull request #90985 from mrobson/iscsi-nodescan-manual
Set session scanning to manual to avoid discovering all iSCSI devices…
2020-05-20 16:45:15 -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
mrobson
03892097fc Set session scanning to manual to avoid discovering all iSCSI devices during login
Move session scanning to before if !b.chapSession
2020-05-12 13:55:33 -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
Jan Safranek
f60a0c8660 Fix mount options in iSCSI volumes
Do not mount volumes in WaitForAttach(), mount them in MountDevice()
instead. They will get proper mount options this way.
2020-03-17 11:37:18 +01:00
Jan Safranek
2c1b743766 Promote block volume features to GA 2020-02-28 20:48:38 +01:00
Alena Prokharchyk
331cd94ccc Ineffassign fixes for pkg/volume
Along resolves errors whitelisted in hack/.staticcheck_failures
2020-01-31 10:14:45 -08:00
Ryan Roemmich
d44583d28a
Fix iscsi refcounter in the case of no Block iscsi volumes 2019-11-27 15:50:40 -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
Travis Rhoden
367f879131
Retire mount.Exec for k8s.io/utils/exec
This patch removes mount.Exec entirely and instead uses the common
utility from k8s.io/utils/exec.

The fake exec implementation found in k8s.io/utils/exec differs a bit
than mount.Exec, with the ability to pre-script expected calls to
Command.CombinedOutput(), so tests that previously relied on a callback
mechanism to produce specific output have been updated to use that
mechanism.
2019-11-13 14:09:57 -07:00
ZP-AlwaysWin
9ca7888acc remove the extra space added 2019-10-24 17:17:31 +08:00
Jan Safranek
894e6795cf Log all executed iscsiadm commands
We sometimes face issues with iSCSI PVs and it's hard to guess what's going
on without iscsiadm commands logged. Using level 5 (iscsiadm output can be
long sometimes) and explicitly avoiding logging of CHAP passwords.

In addition, log which path failed to appear after timeout, so the admin
can see which portals are not providing devices.
2019-09-10 14:31:28 +02:00
zouyee
b85516bb9a remove iSCSI volume storage cleartext secrets in logs 2019-08-09 15:37:02 +08:00
Jan Safranek
cdcd2e2821 Report error when iscsiadm fails during detach
Kubernetes should retry detaching iSCSI volumes on error. In addition, it
should not report an error when detaching a disk while the disk is already
detached.
2019-07-25 10:10:01 +02:00
Fabio Bertinatto
0007c2abd4 Add new refcounter for iSCSI volumes 2019-07-24 13:40:10 +02:00
Fabio Bertinatto
80652c8d37 Fix iSCSI storage plugin cleanup in block volumes 2019-07-16 15:41:11 +02:00
Humble Chirammal
d4ea88f3ce Increase device discovery timeout to 30seconds/equal to checker_timeout.
At present, iscsi plugin wait for 10seconds for a path to appear for a multipath
device, but at certain scenarios this may not be sufficient for device mapper
to get the path. The default multipath configuration has a configuation
called 'checker_timeout' which specify the timeout to user for path checkers
that issue scsi commands with an explicit timeout, in seconds;
default taken from /sys/block/sd*/device/timeout which is 30s.
This patch lift the timeout value from 10s to 30s.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
2019-05-30 21:46:06 +05:30
danielqsj
bdd5c15dee refer to constant to guarantee constant behavior 2019-05-05 11:17:42 +08: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
Fabio Bertinatto
d60d7e905f Don't fail if iface is being used by iSCSI session 2019-02-26 17:13:29 +01:00
danielqsj
8092904e3c Cleanup PathExists callers 2019-01-08 22:16:11 +08:00
jianglingxia
6159bab94a
Merge branch 'master' into jlx201811031619 2018-11-17 12:53:21 +08:00
jianglingxia
0094e05975 fix golint problem of volume cephfs/iscsi/nfs 2018-11-17 12:50:47 +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
Jan Safranek
362be3a58b Retry attaching multipath iSCSI volumes
Don't mount single path instead of multipath volumes and always wait until
at least 2 paths are available. Try up to 3 times to get all paths. Try 5
times to get at last 2 paths.
2018-10-08 13:00:24 +02:00
Masaki Kimura
3d808540df Fix descriptor lock release logic for block volume unmapDevice
Fixes: #69114
2018-10-03 14:40:54 +00:00
Jan Safranek
e5fbb3538f Unmount iSCSI device only if it's mounted. 2018-09-27 10:24:59 +02:00
Ben Swartzlander
39e52ddae5 Add wait loop for multipath devices to appear
It takes a variable amount of time for the multipath daemon
to create /dev/dm-XX in response to new LUNs being discovered.
The old iscsi_util code only discovered the multipath device
if it was created quickly enough, but in a significant number
of cases, kubelet would grab one of the individual paths and
put a filesystem it on before multipathd could construct a
multipath device.

This change waits for the multipath device to get created for
up to 10 seconds, but only if the PV actually had more than
one portal.
2018-08-08 00:44:45 -04:00
Ben Swartzlander
6d23d8edbb Avoid deleted iSCSI LUNs in the kernel
This change ensures that iSCSI block devices are deleted after
unmounting, and implements scanning of individual LUNs rather
than scanning the whole iSCSI bus.

In cases where an iSCSI bus is in use by more than one attachment,
detaching used to leave behind phantom block devices, which could
cause I/O errors, long timeouts, or even corruption in the case
when the underlying LUN number was recycled. This change makes
sure to flush references to the block devices after unmounting.

The original iSCSI code scanned the whole target every time a LUN
was attached. On storage controllers that export multiple LUNs on
the same target IQN, this led to a situation where nodes would
see SCSI disks that they weren't supposed to -- possibly dozens or
hundreds of extra SCSI disks. This caused 3 significant problems:

1) The large number of disks wasted resources on the node and
caused a minor drag on performance.
2) The scanning of all the devices caused a huge number of uevents
from the kernel, causing udev to bog down for multiple minutes in
some cases, triggering timeouts and other transient failures.
3) Because Kubernetes was not tracking all the "extra" LUNs that
got discovered, they would not get cleaned up until the last LUN
on a particular target was detached, causing a logout. This led
to significant complications:

In the time window between when a LUN was unintentially scanned,
and when it was removed due to a logout, if it was deleted on the
backend, a phantom reference remained on the node. In the best
case, the phantom LUN would cause I/O errors and timeouts in the
udev system. In the worst case, the backend could reuse the LUN
number for a new volume, and if that new volume were to be
scheduled to a pod with a phantom reference to the old LUN by the
same number, the initiator could get confused and possibly corrupt
data on that volume.

To avoid these problems, the new implementation only scans for
the specific LUN number it expects to see. It's worth noting that
the default behavior of iscsiadm is to automatically scan the
whole bus on login. That behavior can be disabled by setting
node.session.scan = manual
in iscsid.conf, and for the reasons mentioned above, it is
strongly recommended to set that option. This change still works
regardless of the setting in iscsid.conf, and while automatic
scanning will cause some problems, this change doesn't make the
problems any worse, and can make things better in some cases.
2018-07-24 23:58:19 -04:00
Russ Cox
2bd91dda64 kubernetes: fix printf format errors
These are all flagged by Go 1.11's
more accurate printf checking in go vet,
which runs as part of go test.

Lubomir I. Ivanov <neolit123@gmail.com>
applied ammend for:
  pkg/cloudprovider/provivers/vsphere/nodemanager.go
2018-07-11 00:10:15 +03:00
Jan Safranek
906fd7529e Fix iSCSI and RBD UnmountDevice with mount containers.
Google's configure-helper.sh script bind-mounts /var/lib/kubelet somewhere
into /home/kubernetes and thus every mount that Kubernetes does is visible
twice in /proc/mounts.

iSCSI and RBD should not rely on counting on entries in /proc/mounts and
unmount device when Kubernetes thinks it's unusued. Kubernetes tracks
the mounts by itself and most of other volume plugins rely on it safely.
2018-05-09 09:52:37 +02:00
wackxu
f737ad62ed update import 2018-02-27 20:23:35 +08:00
Di Xu
48388fec7e fix all the typos across the project 2018-02-11 11:04:14 +08:00
Serguei Bezverkhi
40e0c38988 Cleaning up loopback removal process 2018-02-02 10:33:25 -05:00
Mitsuhiro Tanino
6fa583381e Update comments for getting and removing loopback device at iSCSI,FC,RBD
This PR add comments for the background why plugin gets loopback
device and removes loopback device even if operation_generator has
same functionality.
2018-01-17 10:22:39 -05:00
Mitsuhiro Tanino
a6d979dd88 Block volumes Support: iSCSI plugin update
This patch adds block volume support to iSCSI volume plugin.
2018-01-10 11:38:36 -05:00
Sean McGinnis
9f97d61de4
Fixed space/tab indentation
Some lines had spaces for indentation instead of tabs.
2017-12-20 23:48:15 -06:00
Sean McGinnis
69a2deea9c iscsi: set node.startup to manual
If the default iSCSI node.startup is set to automatic, if there is a node failure,
any pods on that node will get rescheduled to another node. If the failed node is
later brought back up it will then try to log back in to any iSCSI sessions it had
prior to the failure, which may no longer exist or may be now in-use by the other
nodes.

It appears most platforms keep the open-iscsi default of node.startup-automatic.
But in case this system-wide setting has been changed, and just to be explicit, this
sets node.startup values for kubernetes controlled volumes to manual.

Closes issue #21305
2017-12-20 15:37:22 -06:00
Sergey Lanzman
3474747465 Move regexp.MustCompile to global variable 2017-11-16 22:03:12 +02:00
mtanino
629718ef0b Refactoring and improvements for iSCSI and FC
This PR makes following changes.

- Simplify volume tearDown path for iSCSI and FC using
  util.UnmountPath().
- Log lastErr during iscsi connection
  If iscsid fails to connect second portal, currently
  the error is ignored silently. The lastErr should be
  logged to find the root cause of problem.
- Remove iscsi plugin directory after iscsi connection
  is successfully closed.
2017-09-18 21:33:11 -04:00
Jan Safranek
540752d0a1 Fix iSCSI WaitForAttach not mounting a volume
WaitForAttach failed consistently with this error:
Heuristic determination of mount point failed:stat /var/lib/kubelet/plugins/kubernetes.io/iscsi/iface-default/10.128.0.3:3260-iqn.2003-01.org.linux-iscsi.f21.x8664:sn.4b0aae584f7c-lun-0: no such file or directory

We should ignore "no such file or directory" eror, the directory is created
just few lines below.
2017-08-30 15:34:49 +02:00
allencloud
c8c7139d21 refactor codes in volume iscsi to improve readability
Signed-off-by: allencloud <allen.sun@daocloud.io>
2017-08-27 12:05:21 +08:00
mtanino
e21b68b4ca Support iscsi volume attach and detach
Fixes #48953
2017-08-26 17:23:47 -04:00
Lars Lehtonen
47ee11437d
Fix swallowed error in iscsi package 2017-08-25 20:57:58 -07:00
Jan Safranek
bc6ad1ad9f iscsi: Use VolumeHost.GetExec() to execute stuff in volume plugins 2017-08-23 14:56:51 +02:00
Mitsuhiro Tanino
a6e523f2e7 iSCSI volume plugin: iSCSI initiatorname support
This PR adds iSCSI initiatorname parameter to ISCSIVolumeSource
to enable automatic configuration of initiator name per volume.
This would allow for more fine grained configuration, and remove
the need to configure the initiator name on the host by
administrator.

fixes: #47311
2017-08-21 11:26:56 -04:00
Mitsuhiro Tanino
285ac8935f iSCSi plugin: Remove redundant nil check 2017-06-15 18:00:29 -04:00
mtanino
b1f06aaed5 iSCSI plugin: Update devicepath with filepath.Glob result
If iscsiTransport is not tcp, iSCSI plugin tries to
find devicepath using filepath.Glob but never updates
devicepath with the filepath.Glob result.

This patch fixes the problem.

Fixes #47253
2017-06-09 22:54:25 -04:00
mtanino
82ce37d973 bkpPortal should be initialized beforehand
This patch is a follow up patch for the PR#46239.
The bkpPortal in DetachDisk() path should be initialized
before using it.
2017-06-05 10:22:57 -04:00