k3s/pkg/kubelet
Kubernetes Submit Queue 009858f18d Merge pull request #48555 from redbaron/hostPath-and-subPath-symlink
Automatic merge from submit-queue

Fix subPath existence check to not follow symlink

**What this PR does / why we need it**:
Volume mounting logic introduced in #43775 and #45623 checks
for subPath existence before attempting to create a directory,
should subPath not be present.

This breaks if subPath is a dangling symlink, os.Stat returns
"do not exist" status, yet `os.MkdirAll` can't create directory
as symlink is present at the given path.

This patch makes existence check to use os.Lstat which works for
normal files/directories as well as doesn't not attempt to follow
symlink, therefore it's "do not exist" status is more reliable when
making a decision whether to create directory or not.

subPath symlinks can be dangling in situations where kubelet is
running in a container itself with access to docker socket, such
as CoreOS's kubelet-wrapper script

**Release note**:
```release-note
Fix pods failing to start when subPath is a dangling symlink from kubelet point of view, which can happen if it is running inside a container
```
2017-07-12 23:43:12 -07:00
..
apis
cadvisor
certificate
client
cm
config
configmap
container
custommetrics
dockershim
envvars
events
eviction
gpu
images
kuberuntime
leaky
lifecycle
metrics
network
pleg
pod
preemption
prober
qos
remote
rkt
rktshim
secret
server
status
sysctl
types
util
volumemanager
BUILD
OWNERS
active_deadline.go
active_deadline_test.go
disk_manager.go
disk_manager_test.go
doc.go
kubelet.go
kubelet_cadvisor.go
kubelet_cadvisor_test.go
kubelet_getters.go
kubelet_getters_test.go
kubelet_network.go
kubelet_network_test.go
kubelet_node_status.go
kubelet_node_status_test.go
kubelet_pods.go
kubelet_pods_test.go
kubelet_pods_windows_test.go
kubelet_resources.go
kubelet_resources_test.go
kubelet_test.go
kubelet_volumes.go
kubelet_volumes_test.go
networks.go
networks_test.go
oom_watcher.go
oom_watcher_test.go
pod_container_deletor.go
pod_container_deletor_test.go
pod_workers.go
pod_workers_test.go
reason_cache.go
reason_cache_test.go
runonce.go
runonce_test.go
runtime.go
util.go
volume_host.go