mirror of https://github.com/k3s-io/k3s
Create the directory for cadvisor if needed
In 6c7245d464
, code was added to
bail out if the directory that cadvisor monitored did not exist.
However, this breaks the earlier assumption that kubelet created
directories when needed in pkg/kubelet/kubelet.go's setupDataDirs()
method. setupDataDirs() happens much later, so basically kubelet
exits now.
So since cadvisor really needs this directory, let us just create
it
Fixes #50709
pull/6/head
parent
4d409a4d9e
commit
ca2d5178aa
|
@ -24,6 +24,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -108,7 +109,9 @@ func New(address string, port uint, runtime string, rootPath string) (Interface,
|
||||||
|
|
||||||
if _, err := os.Stat(rootPath); err != nil {
|
if _, err := os.Stat(rootPath); err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil, fmt.Errorf("rootDirectory %q does not exist", rootPath)
|
if err := os.MkdirAll(path.Clean(rootPath), 0750); err != nil {
|
||||||
|
return nil, fmt.Errorf("error creating root directory %q: %v", rootPath, err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("failed to Stat %q: %v", rootPath, err)
|
return nil, fmt.Errorf("failed to Stat %q: %v", rootPath, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue