Commit Graph

79 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
5071c4f57e
Merge pull request #111982 from cvvz/kubelet-del-unnecessary-code
cleanup: delete useless code from kubelet volumemanager
2023-02-14 10:31:31 -08:00
weizhi
575616cc72
fix: kubelet event about unattached volumes is incorrect (#112719)
* fix kubelet event

* add ut

* fix ut
2023-01-04 01:51:59 -08:00
Jordan Liggitt
78cb3862f1
Fix indentation/spacing in comments to render correctly in godoc 2022-12-17 23:27:38 -05:00
weizhichen
f2e7211ab8 delete stale code in kubelet volumemanager 2022-08-23 23:36:09 +00:00
Jan Safranek
17d850ee0e Add interface for SELinuxOptionsToFileLabel
github.com/opencontainers/selinux/go-selinux needs OS that supports SELinux
and SELinux enabled in it to return useful data, therefore add an interface
in front of it, so we can mock its behavior in unit tests.
2022-08-04 10:51:51 +02: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
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
Abirdcfly
984ed7ab94
typo in comments pkg/kubelet/volumemanager/volume_manager.go
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-06-20 09:59:01 +08:00
Mengjiao Liu
beda4cafb6 kubelet: Remove the deprecated flag --experimental-check-node-capabilities-before-mount 2022-01-06 11:47:11 +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
Jan Safranek
ca934b8f5c Add GetPossiblyMountedVolumesForPod to let kubelet know all volumes were unmounted
podVolumesExist() should consider also uncertain volumes (where kubelet
does not know if a volume was fully unmounted) when checking for pod's
volumes. Added GetPossiblyMountedVolumesForPod for that.

Adding uncertain mounts to GetMountedVolumesForPod would potentially break
other callers (e.g. `verifyVolumesMountedFunc`).
2021-06-16 18:39:12 +02:00
Kubernetes Prow Robot
b5c6434f6b
Merge pull request #98850 from yangjunmyfm192085/run-test14
Structured Logging migration: modify volume and container part logs o…
2021-03-17 11:45:19 -07:00
JunYang
01a4e4face Structured Logging migration: modify volume and container part logs of kubelet.
Signed-off-by: JunYang <yang.jun22@zte.com.cn>
2021-03-17 08:59:03 +08:00
Jan Safranek
219cbc818a Refactor CSI migration plugin manager to get featureGates as a parameter
This allows caller to provide fake ones for testing of various corner cases
(migration on A/D controller disabled while enabled on kubelet).
2021-03-08 13:50:01 +01:00
Shihang Zhang
d2859cd89b plumb service account token down to csi driver 2020-11-12 09:26:43 -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
Hemant Kumar
a795f3de88 Add code for introducing uncertain state of mounts
Add a comment about volumestate
2019-12-02 11:57:40 -05: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
Deep Debroy
129f15328b Disable in-tree plugins migrated to CSI
Signed-off-by: Deep Debroy <ddebroy@docker.com>
2019-11-14 17:28:21 -08:00
Travis Rhoden
935c23f2ad
Move HostUtil to pkg/volume/util/hostutil
This patch moves the HostUtil functionality from the util/mount package
to the volume/util/hostutil package.

All `*NewHostUtil*` calls are changed to return concrete types instead
of interfaces.

All callers are changed to use the `*NewHostUtil*` methods instead of
directly instantiating the concrete types.
2019-08-30 10:14:42 -06:00
Jan Safranek
5b69362ff0 Skip unused volumes in VolumeManager
DesiredStateOfWorldPopulator should skip a volume that is not used in any
pod. "Used" means either mounted (via volumeMounts) or used as raw block
device (via volumeDevices).

Especially when block feature is disabled, a block volume must not get into
DesiredStateOfWorld, because it would be formatted and mounted there.
2019-08-15 10:48:38 +02:00
Jan Safranek
af0c2fe572 Fix some error messages 2019-07-22 10:54:33 +02:00
Jan Safranek
17be780651 Add events to dswp 2019-07-19 17:46:21 +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
Xing Yang
000ab86788 Move CSIDriver Lister to the controller 2019-04-05 12:20:11 -07:00
caiweidong
92aee22646 Remove the unused variabe: syncDuration in volumemanager 2019-03-15 10:04:41 +08:00
Hemant Kumar
d2b6e30143 Fix bug with volume getting marked as not in-use with pending op
Add test for verifying volume detach
2018-11-20 11:58:47 -05: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
knight
5ed6da9d9e
remove unnecessary time type
remove unnecessary time type, improve volume_manager.go
2018-10-11 21:06:46 +08:00
Fabio Bertinatto
376a94e039 Add more metrics for Volume Manager
Specifically:

* Number of volumes in ActualStateofWorld and DesiredStateofWorld
* Number of times ReconstructVolume Spec on kubelet failed
2018-08-13 17:36:36 +02:00
Seth Jennings
0413850d14 kubelet: volumemanager: poll immediate when waiting for volume attachment 2018-08-02 16:41:15 -05:00
Michelle Au
91c557f504 Use inner volume name instead of outer volume name for subpath directory 2018-03-21 17:13:38 -07:00
Kubernetes Submit Queue
907329e2eb
Merge pull request #55584 from zhangxiaoyu-zidif/move-check-pod-forward
Automatic merge from submit-queue (batch tested with PRs 60376, 55584, 60358, 54631, 60291). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

move pod-check forward

**What this PR does / why we need it**:

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2018-02-28 03:37:25 -08:00
wackxu
f737ad62ed update import 2018-02-27 20:23:35 +08:00
Jan Safranek
c232a0165a Fix DownwardAPI refresh race.
WaitForAttachAndMount should mark only pod in DesiredStateOfWorldPopulator (DSWP)
and DSWP should mark the volume to be remounted only when the new pod has been
processed.

Otherwise DSWP and reconciler race who gets the new pod first. If it's reconciler,
then DownwardAPI and Projected volumes of the pod are not refreshed with new
content and they are updated after the next periodic sync (60-90 seconds).
2018-02-14 16:54:25 +01:00
Cao Shufeng
4e7398b67b remove duplicated import 2018-01-17 09:34:59 +08:00
David Zhu
fffd152e0d Fixed kubelet error message to be more descriptive. Added Attach success event for help in debugging. 2017-12-15 15:36:59 -08:00
mtanino
8903e8cd85 BlockVolumesSupport: CRI, VolumeManager and OperationExecutor changes
This patch contains following changes.
- container runtime changes for adding block devices
- volumemanager changes
- operationexecutor changes
2017-11-20 14:10:26 -05:00
zhangxiaoyu-zidif
6e50240ce1 move pod-check forward 2017-11-13 15:46:23 +08:00
Di Xu
ef2403f80e send volumesInUse sorted in node status updates 2017-07-30 21:57:18 +08:00
Jacob Simpson
29c1b81d4c Scripted migration from clientset_generated to client-go. 2017-07-17 15:05:37 -07:00
Kubernetes Submit Queue
dd126ae19c Merge pull request #38431 from NickrenREN/newVolumeMgr-return
Automatic merge from submit-queue

Modify NewVolumeManager() function return value
2017-06-22 16:43:29 -07:00
Chao Xu
60604f8818 run hack/update-all 2017-06-22 11:31:03 -07:00
Chao Xu
f4989a45a5 run root-rewrite-v1-..., compile 2017-06-22 10:25:57 -07:00
NickrenREN
312cd1bbe6 Modify NewVolumeManager() function return value
Since function NewVolumeManager() will always return vm and nil, we do not need the second return value, it will always be nil.
2017-06-17 23:33:12 +08:00
Di Xu
bc93e7bcde remove redundant carriage return for readable 2017-05-27 14:49:16 +08:00
Kubernetes Submit Queue
aacc9729f1 Merge pull request #44781 from wongma7/outervolumespec
Automatic merge from submit-queue (batch tested with PRs 45382, 45384, 44781, 45333, 45543)

Ensure desired state of world populator runs before volume reconstructor

If the kubelet's volumemanager reconstructor for actual state of world runs before the desired state of world has been populated, the pods in the actual state of world will have some incorrect volume information: namely outerVolumeSpecName, which if incorrect leads to part of the issue here https://github.com/kubernetes/kubernetes/issues/43515, because WaitForVolumeAttachAndMount searches the actual state of world with the correct outerVolumeSpecName and won't find it so reports 'timeout waiting....', etc. forever for existing pods. The comments acknowledge that this is a known issue

The all sources ready check doesn't work because the sources being ready doesn't necessarily mean the desired state of world populator added pods from the sources. So instead let's put the all sources ready check in the *populator*, and when the sources are ready, it will be able to populate the desired state of world and make "HasAddedPods()" return true. THEN, the reconstructor may run.

@jingxu97 PTAL, you wrote all of the reconstruction stuff

```release-note
NONE
```
2017-05-10 17:47:43 -07:00
Matthew Wong
bbe82a2688 Ensure desired state of world populator runs before volume reconstructor 2017-05-09 18:25:59 -04:00