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

Repair partition #633

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
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
41 changes: 36 additions & 5 deletions cmd/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ var blobberUpdateCmd = &cobra.Command{
if !ia {
ia = false
}
updateBlobber.IsRestricted = &ia
updateBlobber.IsRestricted = new(bool)
*updateBlobber.IsRestricted = false
}

if termsChanged {
Expand All @@ -290,10 +291,10 @@ var blobberUpdateCmd = &cobra.Command{
}

var resetBlobberStatsCmd = &cobra.Command{
Use: "reset-blobber-stats",
Short: "Reset blobber stats",
Long: `Reset blobber stats`,
Args: cobra.MinimumNArgs(0),
Use: "reset-blobber-stats",
Short: "Reset blobber stats",
Long: `Reset blobber stats`,
Args: cobra.MinimumNArgs(0),
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
var (
Expand Down Expand Up @@ -359,12 +360,39 @@ var resetBlobberStatsCmd = &cobra.Command{
},
}

var repairPartitions = &cobra.Command{
Use: "repair-partitions",
Short: "Repair partitions",
Long: `Repair partitions`,
Args: cobra.MinimumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
var partitionName string

flags := cmd.Flags()
if !flags.Changed("partition") {
log.Fatal("missing required 'partition' flag")
} else {
var err error
partitionName, err = flags.GetString("partition")
if err != nil {
log.Fatal("error in 'partition' flag: ", err)
}
}

if _, _, err := sdk.RepairPartitions(partitionName); err != nil {
log.Fatal(err)
}
fmt.Println("repair validator partitions successfully")
},
}

func init() {
rootCmd.AddCommand(scConfig)
rootCmd.AddCommand(lsBlobers)
rootCmd.AddCommand(blobberInfoCmd)
rootCmd.AddCommand(blobberUpdateCmd)
rootCmd.AddCommand(resetBlobberStatsCmd)
rootCmd.AddCommand(repairPartitions)

scConfig.Flags().Bool("json", false, "(default false) pass this option to print response as json data")
lsBlobers.Flags().Bool("json", false, "(default false) pass this option to print response as json data")
Expand Down Expand Up @@ -401,4 +429,7 @@ func init() {
resetBlobberStatsCmd.MarkFlagRequired("prev_saved_data")
resetBlobberStatsCmd.MarkFlagRequired("new_allocated")
resetBlobberStatsCmd.MarkFlagRequired("new_saved_data")

repairPartitions.Flags().String("partition", "", "partition ID")
repairPartitions.MarkFlagRequired("partition")
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.16.0
github.com/0chain/gosdk v1.16.4-0.20240729184854-d91d793e5f8f
github.com/icza/bitio v1.1.0
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs
github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.16.0 h1:3CKuU9i9d+X2/htJOIyxNwviKG5H/lp+q8ogzCgnoQI=
github.com/0chain/gosdk v1.16.0/go.mod h1:y7Ucdmv40VltqulZnncMNjNQ4piX5Dta5ujNmPmXnxg=
github.com/0chain/gosdk v1.16.4-0.20240729184854-d91d793e5f8f h1:ryjGg+MMHozCyMSNosD0N1L7ptNuSy/G84Zv+YEVXrY=
github.com/0chain/gosdk v1.16.4-0.20240729184854-d91d793e5f8f/go.mod h1:y7Ucdmv40VltqulZnncMNjNQ4piX5Dta5ujNmPmXnxg=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw=
Expand Down
Loading