Skip to content

Commit

Permalink
add reboot queue backoff reset command
Browse files Browse the repository at this point in the history
Signed-off-by: YZ775 <[email protected]>
  • Loading branch information
YZ775 committed Oct 20, 2023
1 parent 2a0ecb9 commit 28bd282
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions pkg/ckecli/cmd/reboot_queue_backoff_reset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cmd

import (
"context"
"time"

"github.com/cybozu-go/cke"
"github.com/cybozu-go/well"
"github.com/spf13/cobra"
)

var rebootQueueBackoffResetCmd = &cobra.Command{
Use: "reset-backoff",
Short: "reset backoff",
Long: `reset backoff`,
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(rebootQueueBackoffResetCmd)
}

0 comments on commit 28bd282

Please sign in to comment.