-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add reboot queue backoff reset command
Signed-off-by: YZ775 <[email protected]>
- Loading branch information
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/cybozu-go/cke" | ||
"github.com/cybozu-go/well" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rebootQueueResetBackoffCmd = &cobra.Command{ | ||
Use: "reset-backoff", | ||
Short: "Reset drain backoff of the entries in reboot queue", | ||
Long: `Reset drain_backoff_count and drain_backoff_expire of the entries in reboot queue`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
well.Go(func(ctx context.Context) error { | ||
entries, err := storage.GetRebootsEntries(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
for _, entry := range entries { | ||
entry.DrainBackOffCount = 0 | ||
entry.DrainBackOffExpire = time.Time{} | ||
err := storage.UpdateRebootsEntry(ctx, entry) | ||
if err == cke.ErrNotFound { | ||
// The entry has just finished | ||
continue | ||
} | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
}) | ||
well.Stop() | ||
return well.Wait() | ||
}, | ||
} | ||
|
||
func init() { | ||
rebootQueueCmd.AddCommand(rebootQueueResetBackoffCmd) | ||
} |