1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 06:40:31 +00:00

Add config validation when reboot & shutdown

This commit is contained in:
Jason-ZW
2019-03-14 18:37:40 +08:00
committed by niusmallnan
parent eb762f903f
commit 788e9dc39a
2 changed files with 62 additions and 1 deletions

View File

@@ -131,8 +131,23 @@ func reboot(name string, force bool, code uint) {
log.Fatalf("%s: Need to be root", os.Args[0])
}
// Add shutdown timeout
cfg := config.LoadConfig()
// Validate config
if !force {
_, validationErrors, err := config.LoadConfigWithError()
if err != nil {
log.Fatal(err)
}
if validationErrors != nil && !validationErrors.Valid() {
for _, validationError := range validationErrors.Errors() {
log.Error(validationError)
}
return
}
}
// Add shutdown timeout
timeoutValue := cfg.Rancher.ShutdownTimeout
if timeoutValue == 0 {
timeoutValue = 60