Change:
<!-- This form is for bug reports and feature requests ONLY! If you're looking for help check and the . --Is this a BUG REPORT or FEATURE REQUEST?: What happened: When running on a new VM, I get the following error: error: failed to run Kubelet: rootDirectory "/var/lib/kubelet" does not exist What you expected to happen: Previously, if this root directory did not exist, kubelet would automatically create it with the appropriate permissions. How to reproduce it (as minimally and precisely as possible): $ git clone $ cd kubernetes $ git checkout $ make WHAT=cmd/kubelet $ sudo ./output/dockerized/bin/linux/amd64/kubelet --fail-swap-on=false This invocation exits immediately with the above error about not existing. Anything else we need to know?: I believe this recently-merged PR is the cause: If I revert this PR's commit locally, and repeat the above steps, then gets automatically created when I start up kubelet: $ git revert $ make WHAT=cmd/kubelet $ sudo ./output/dockerized/bin/linux/amd64/kubelet --fail-swap-on=false This invocation stays running, and if I check in another window, has automatically been created. This discrepancy is currently breaking our . If the correct answer is that autocreation of the root directory was never supposed to be a supported feature and just happened to work, then we can update that expectation elsewhere to explicitly create the root directory first, but this does seem like a regression. Environment: Kubernetes version (use ): upstream/master HEAD (at ) Cloud provider or hardware configuration**: The same happens on my local desktop and a GCE VM with Ubuntu OS (e.g. from /etc/os-release): Ubuntu 14.04 on my desktop, 16.04 on GCE Kernel (e.g. ): 4.4.0-83-generic on my desktop, 4.4.0-21-generic on GCE Install tools: building/running directly from the source code using the above steps Others:
There are no sig labels on this issue. Please by: a sig: e.g., to notify the contributor experience sig, OR the label manually: e.g., to apply the label Note: Method 1 will trigger an email to the group. You can find the group list and label list . The in the method 1 has to be replaced with one of these: bugs, feature-requests, pr-reviews, test-failures, proposals
/sig node
cc
/kind bug /area kubelet
/cc for
I am sure about the sequence of this? When cadvisor checks the directory, should this directory already exist?
figured out where exactly we create the directories. please see the PR
For default , we may create it if needed. But what if a customized value?
The behavior looks to be the same. There is a default root directory, but it can be overridden with a CLI flag. The code for directory creation is here, and uses the after CLI args have been resolved:
Thanks for the clarification. Actually . So we may remove the duplicated in . WDYT?
i am not comfortable with the duplicate from setupDataDirs as someone can use Kubelet directly without using the code under (and without using cadvisor). So we should let it be
SGTM. Thanks.

Discussion:
"net" "net/http" "os" <ins> "path" </ins> "strconv" "time"

if _, err := os.Stat(rootPath); err != nil { if os.IsNotExist(err) { <del> return nil, fmt.Errorf("rootDirectory %q does not exist", rootPath) </del> <ins> if err := os.MkdirAll(path.Clean(rootPath), 0750); err != nil { return nil, fmt.Errorf("error creating root directory %q: %v", rootPath, err) } </ins> } else { return nil, fmt.Errorf("failed to Stat %q: %v", rootPath, err) }