Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reboot queue backoff reset command #667

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/ckecli.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ $ ckecli [--config FILE] <subcommand> args...
- [`ckecli reboot-queue list`](#ckecli-reboot-queue-list)
- [`ckecli reboot-queue cancel INDEX`](#ckecli-reboot-queue-cancel-index)
- [`ckecli reboot-queue cancel-all`](#ckecli-reboot-queue-cancel-all)
- [`ckecli reboot-queue reset-backoff`](#ckecli-reboot-queue-reset-backoff)
- [`ckecli sabakan`](#ckecli-sabakan)
- [`ckecli sabakan enable|disable`](#ckecli-sabakan-enabledisable)
- [`ckecli sabakan is-enabled`](#ckecli-sabakan-is-enabled)
Expand Down Expand Up @@ -299,6 +300,11 @@ Cancel the specified reboot queue entry.

Cancel all the reboot queue entries.

### `ckecli reboot-queue reset-backoff`

Reset `drain_backoff_count` and `drain_backoff_expire` of the entries in reboot queue.
Resetting these values makes CKE try to reboot nodes again immediately.

## `ckecli sabakan`

Control [sabakan integration feature](sabakan-integration.md).
Expand Down
9 changes: 9 additions & 0 deletions mtest/reboot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ func testRebootOperations() {
Expect(re).Should(HaveLen(1))
Expect(re[0].Status).Should(Equal(cke.RebootStatusQueued))
Expect(re[0].DrainBackOffExpire).ShouldNot(Equal(time.Time{}))
Expect(re[0].DrainBackOffCount).Should(Not(BeZero()))

By("Checking reset-backoff command resets drain backoff")
ckecliSafe("reboot-queue", "reset-backoff")
re, err = getRebootEntries()
Expect(err).ShouldNot(HaveOccurred())
Expect(re).Should(HaveLen(1))
Expect(re[0].DrainBackOffExpire).Should(Equal(time.Time{}))
Expect(re[0].DrainBackOffCount).Should(BeZero())

By("Waiting for reboot completion")
waitRebootCompletion(cluster)
Expand Down
43 changes: 43 additions & 0 deletions pkg/ckecli/cmd/reboot_queue_reset_backoff.go
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)
}