Commit Graph

126 Commits

Author SHA1 Message Date
Yibo Zhuang
380c7f248e scheduler volumebinding: leverage PreFilterResult
This change will leverage the new PreFilterResult
to reduce down the list of eligible nodes for pod
using Bound Local PVs during PreFilter stage so
that only the node(s) which local PV node affinity
matches will be cosnidered in subsequent scheduling
stages.

Today, the NodeAffinity check is done during Filter
which means all nodes will be considered even though
there may be a large number of nodes that are not
eligible due to not matching the pod's bound local
PV(s)' node affinity requirement. Here we can
reduce down the node list in PreFilter to ensure that
during Filter we are only considering the reduced
list and thus can provide a more clear message to
users when node(s) are not available for scheduling
since the list only contains relevant nodes.

If error is encountered (e.g. PV cache read error) or
if node list reduction cannot be done (e.g. pod uses
no local PVs), then we will still proceed to consider
all nodes for the rest of scheduling stages.

Signed-off-by: Yibo Zhuang <yibzhuang@gmail.com>
2022-11-17 21:37:24 -08:00
Matthew Cary
3993c23a74 Make mount ref search more robust
Change-Id: Id28c2d1c8e996c10e4ad19a993ebbe75b142c1af
2022-09-20 17:57:39 -07:00
Jan Safranek
48b0751269 Add SELinux context tracking to volume manager
Both ActualStateOfWorld and DesiredStateOfWorld must track SELinux context
of volume mounts.
2022-08-04 10:51:41 +02:00
Jan Safranek
4cfb277e8b Implement mounting with -o context= in iSCSI volume plugin 2022-08-04 10:51:31 +02: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
Konstantin Misyutin
1d7cefe9c4 Move volume helpers to "k8s.io/component-helpers/storage/volume".
This patch aims to simplify decoupling "pkg/scheduler/framework/plugins"
from internal "k8s.io/kubernetes" packages. More described in
issue #89930 and PR #102953.

Some helpers from "k8s.io/kubernetes/pkg/controller/volume/persistentvolume"
package moved to "k8s.io/component-helpers/storage/volume" package:

- IsDelayBindingMode
- GetBindVolumeToClaim
- IsVolumeBoundToClaim
- FindMatchingVolume
- CheckVolumeModeMismatches
- CheckAccessModes
- GetVolumeNodeAffinity

Also "CheckNodeAffinity" from "k8s.io/kubernetes/pkg/volume/util"
package moved to "k8s.io/component-helpers/storage/volume" package
to prevent diamond dependency conflict.

Signed-off-by: Konstantin Misyutin <konstantin.misyutin@huawei.com>
2022-03-16 15:43:09 +08:00
Clayton Coleman
3eadd1a9ea
Keep pod worker running until pod is truly complete
A number of race conditions exist when pods are terminated early in
their lifecycle because components in the kubelet need to know "no
running containers" or "containers can't be started from now on" but
were relying on outdated state.

Only the pod worker knows whether containers are being started for
a given pod, which is required to know when a pod is "terminated"
(no running containers, none coming). Move that responsibility and
podKiller function into the pod workers, and have everything that
was killing the pod go into the UpdatePod loop. Split syncPod into
three phases - setup, terminate containers, and cleanup pod - and
have transitions between those methods be visible to other
components. After this change, to kill a pod you tell the pod worker
to UpdatePod({UpdateType: SyncPodKill, Pod: pod}).

Several places in the kubelet were incorrect about whether they
were handling terminating (should stop running, might have
containers) or terminated (no running containers) pods. The pod worker
exposes methods that allow other loops to know when to set up or tear
down resources based on the state of the pod - these methods remove
the possibility of race conditions by ensuring a single component is
responsible for knowing each pod's allowed state and other components
simply delegate to checking whether they are in the window by UID.

Removing containers now no longer blocks final pod deletion in the
API server and are handled as background cleanup. Node shutdown
no longer marks pods as failed as they can be restarted in the
next step.

See https://docs.google.com/document/d/1Pic5TPntdJnYfIpBeZndDelM-AbS4FN9H2GTLFhoJ04/edit# for details
2021-07-06 15:55:22 -04:00
Chris Henzie
83e3ee780a Rename access mode contains helper method
So it is consistent with other methods performing the same check (one
for internal and external types)
2021-06-28 21:24:56 -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
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
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
Shintaro Murakami
fe7a862c2d Unify determination of whether a volume is ephemeral 2021-03-05 14:49:09 +09:00
Mike Dame
ba72411aa2 Move GetPersistentVolumeClaimClass to component-helpers
The goal of this move is related to issue 89930, to break the dependence
of scheduling plugins on internal helpers. This function can easily move to
component-helpers where it will be used by other components as well.
2021-02-01 10:48:38 -05:00
Mike Dame
b7ba77c25b Move MatchNodeSelectorTerms to k8s.io/component-helpers 2020-10-29 13:39:13 -04:00
Mike Dame
d9f334683e Change function signature for MatchNodeSelectorTerms
As part of externalizing this function to the k8s.io/component-helpers repo,
this commit simplifies the function signature and makes its 2 helpers private
(nodeSelectorRequirementsAsSelector and nodeSelectorRequirementsAsFieldSelector).
2020-10-27 12:52:06 -04:00
lala123912
7594702b22 modify static check
fix format
2020-09-23 19:27:24 +08:00
Srini Brahmaroutu
fbe5daed73 Change code to use staging/k8s.io/mount-utils 2020-09-16 21:51:24 -07:00
Jiawei Wang
a6d8e6c5c2 Detect change of volume attachability in the middle of attaching
- Add Unit tests for both volumemanager and attach/detach controller
- Add E2E test
2020-08-24 17:15:11 -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
Shihang Zhang
3db7275b54 set proper file permission for projected service account volume 2020-05-04 18:25:23 -07:00
Shihang Zhang
b56da85a77 sync api/v1/pod/util with api/pod/util and remove DefaultContainers 2020-03-24 16:42:32 -07:00
Kubernetes Prow Robot
ef672c1c2d
Merge pull request #88678 from verult/slow-rxm-attach
Parallelize attach operations across different nodes for volumes that allow multi-attach
2020-03-06 13:17:21 -08:00
Cheng Xing
ef3d66b98b Parallelize attach operations across different nodes for volumes that allow multi-attach 2020-03-05 22:22:05 -08:00
Jan Safranek
2c1b743766 Promote block volume features to GA 2020-02-28 20:48:38 +01:00
Mike Danese
3aa59f7f30 generated: run refactor 2020-02-07 18:16:47 -08:00
Jordan Liggitt
cd1059e3c4 Revert "Merge pull request #87258 from verult/slow-rxm-attach"
This reverts commit 15c3f1b119, reversing
changes made to 52d7614a8c.
2020-01-29 14:58:32 -05:00
Cheng Xing
c6a03fa5be Parallelize attach operations across different nodes for volumes that allow multi-attach 2020-01-27 15:02:25 -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
Masaki Kimura
8a159d7253 Move MapBlockVolume call to operation_generator and add UnmapBlockVolume 2019-11-14 15:58:26 +00:00
Masaki Kimura
2ecdc5e8d1 Change globalMapPath to bind mount from symlink
This change is needed to make descriptor lock per pod, in the next commit.
If losetup is called for symlink, path in the output for losetup is resolved,
as a result, we can't distinguish which path the lock is taken.
2019-11-14 15:58:26 +00: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
Jing Xu
1636b2b452 Flush data cache during unmount device for GCE-PD in Windows
This PR fixes the issue mentioned in #83590 for GCE-PD. It uses
WriteVolumeCache API to writes the file system cache to disk during
UnmountDevice in Windows. Linux does not need to explicitly flush cache
because unmount will automatically sync the disk which also flush the
cache.

Change-Id: Ife2745c92b8c0446e79a52e9f9ec7851d2f6b90d
2019-10-16 10:12:35 -07:00
Ted Yu
ba45f73c1f Remove unused func GetPersistentVolumeClaimVolumeMode 2019-09-22 08:54:01 -07:00
Kubernetes Prow Robot
f1453953b7
Merge pull request #81745 from codenrhoden/mv-hasmountrefs
mv HasMountRefs from mount pkg to vol/util
2019-08-23 00:52:13 -07:00
Travis Rhoden
a7830a2c6e
mv HasMountRefs from mount pkg to vol/util
HasMountRefs is only used internal to K8s and should not be moved out
with the mount package. move it to pkg/volume/util instead.
2019-08-21 14:53:34 -06:00
Michelle Au
fa822f3c51 Use VisitContainers instead of directly accessing pod container fields
Change-Id: I354513683e7b5bf4d1837f567ef0e84b17f6e174
2019-08-20 11:16:35 -07:00
Jan Safranek
8d580262f9 Refactor makeMountsMap into GetPodVolumeNames
The function will be handy in subsequent patches. Also change custom maps
into sets.String.
2019-08-15 10:48:38 +02:00
Robert Krawitz
f8661d6240 Use xfs_quota command to apply quotas 2019-05-29 15:12:28 -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
Travis Rhoden
12b7f1450c Move MountsInGlobalPDPath from mount pkg to volume
Since pkg/util/mount is going to move out of k/k, this exported constant
that is Kubernetes specific needed to move somewhere else. Made sense to
move it to pkg/volume/util.

Update GetDeviceNameFromMount in the mount interface to now take a
pluginMountDir argument, which is volume plugin dir with the global
mount path appended to it already.
2019-04-29 09:56:00 -06:00
Andrew Kim
a62ee8b0a9 clean up volume rounding functions and move to k8s.io/cloud-provider/volume 2019-02-09 01:16:55 -05:00
Andrew Kim
ca6a051b00 remove cloud provider dependencies to pkg/volume
Co-authored-by: Weibin Lin <linweibin1@huawei.com>
2019-02-09 01:16:55 -05:00
Davanum Srinivas
cf44bfa556
Move LabelMultiZoneDelimiter to pkg/volume/util
Change-Id: I098b210e44ac3bb1901e029ff7cd33aa0afbdc74
2019-02-05 13:39:07 -05:00
Davanum Srinivas
b975573385
move pkg/kubelet/apis/well_known_labels.go to staging/src/k8s.io/api/core/v1/
Co-Authored-By: Weibin Lin <linweibin1@huawei.com>

Change-Id: I163b2f2833e6b8767f72e2c815dcacd0f4e504ea
2019-02-05 13:39:07 -05:00
danielqsj
657a1a1a34 change import alias of utils/strings 2019-01-30 10:44:09 +08:00
danielqsj
093328e57f migrate to k8s.io/utils/strings 2019-01-30 10:24:00 +08:00
danielqsj
2426f0ee4e Cleanup IsCorruptedMnt callers 2019-01-08 22:16:11 +08:00
danielqsj
8092904e3c Cleanup PathExists callers 2019-01-08 22:16:11 +08:00
danielqsj
d94cd822b7 Cleanup UnmountPath/UnmountMountPoint callers 2019-01-08 22:13:50 +08:00
Michelle Au
7a4f906f25 Rename UnmountMountPoint to CleanupMountPoint 2019-01-03 16:35:54 -08:00