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:
@@ -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
|
||||
|
Reference in New Issue
Block a user