mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
validate cadvisor rootpath
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -105,6 +106,14 @@ func New(address string, port uint, runtime string, rootPath string) (Interface,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := os.Stat(rootPath); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil, fmt.Errorf("rootDirectory %q does not exist", rootPath)
|
||||
} else {
|
||||
return nil, fmt.Errorf("failed to Stat %q: %v", rootPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
cadvisorClient := &cadvisorClient{
|
||||
runtime: runtime,
|
||||
rootPath: rootPath,
|
||||
|
||||
Reference in New Issue
Block a user