File tree Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ func WithSystemctl(b bool) OpOption {
45
45
46
46
var ErrNotRoot = errors .New ("must be run as sudo/root" )
47
47
48
- // Reboots the system.
48
+ // Reboot reboots the system.
49
49
func Reboot (ctx context.Context , opts ... OpOption ) error {
50
50
options := & Op {}
51
51
if err := options .applyOpts (opts ); err != nil {
Original file line number Diff line number Diff line change @@ -74,21 +74,19 @@ func (s *Session) serve() {
74
74
}
75
75
76
76
ctx , cancel := context .WithTimeout (context .Background (), time .Minute )
77
- if payload .Method == "reboot" {
78
- rerr := pkghost .Reboot (ctx , pkghost .WithDelaySeconds (0 ))
79
-
80
- if rerr != nil {
81
- log .Logger .Errorf ("failed to trigger reboot machine: %v" , rerr )
82
- }
83
-
84
- cancel ()
85
- continue
86
- }
87
77
88
78
needExit := - 1
89
79
response := & Response {}
90
80
91
81
switch payload .Method {
82
+ case "reboot" :
83
+ // To inform the control plane that the reboot request has been processed, reboot after 10 seconds.
84
+ err := pkghost .Reboot (s .ctx , pkghost .WithDelaySeconds (10 ))
85
+ if err != nil {
86
+ log .Logger .Errorf ("failed to trigger reboot machine: %v" , err )
87
+ response .Error = err .Error ()
88
+ }
89
+
92
90
case "metrics" :
93
91
metrics , err := s .getMetrics (ctx , payload )
94
92
if err != nil {
You can’t perform that action at this time.
0 commit comments