heal: Add verbose flag to heal command (#3927)

For deployments which has many disks, it is annoying to list all disks
by default. Add --verbose flag to only show the status of all disks.
This commit is contained in:
Anis Elleuch
2022-01-21 08:51:18 -08:00
committed by GitHub
parent 2f9bcdf344
commit fd70dd59c6
3 changed files with 28 additions and 22 deletions
+25 -19
View File
@@ -69,6 +69,10 @@ var adminHealFlags = []cli.Flag{
Name: "storage-class",
Usage: "show server/disks failure tolerance with the given storage class",
},
cli.BoolFlag{
Name: "verbose, v",
Usage: "show verbose information",
},
}
var adminHealCmd = cli.Command{
@@ -91,11 +95,6 @@ FLAGS:
EXAMPLES:
1. Monitor healing status on a running server at alias 'myminio':
{{.Prompt}} {{.HelpName}} myminio/
...
...
Summary:
=======
No ongoing active healing.
`,
}
@@ -131,15 +130,6 @@ func (s stopHealMessage) JSON() string {
return string(stopHealJSONBytes)
}
// verboseBackgroundHealStatusMessage is container for stop heal success and failure messages.
type verboseBackgroundHealStatusMessage struct {
Status string `json:"status"`
HealInfo madmin.BgHealState
// Specify storage class to show servers/disks tolerance
ToleranceForSC string `json:"-"`
}
type setIndex struct {
pool, set int
}
@@ -345,6 +335,15 @@ func getOfflineNodes(endpoints []string) map[string]struct{} {
return offlineNodes
}
// verboseBackgroundHealStatusMessage is container for stop heal success and failure messages.
type verboseBackgroundHealStatusMessage struct {
Status string `json:"status"`
HealInfo madmin.BgHealState
// Specify storage class to show servers/disks tolerance
ToleranceForSC string `json:"-"`
}
// String colorized to show background heal status message.
func (s verboseBackgroundHealStatusMessage) String() string {
var msg strings.Builder
@@ -628,11 +627,18 @@ func mainAdminHeal(ctx *cli.Context) error {
if bucket == "" && !ctx.Bool("recursive") {
bgHealStatus, berr := adminClnt.BackgroundHealStatus(globalContext)
fatalIf(probe.NewError(berr), "Failed to get the status of the background heal.")
printMsg(verboseBackgroundHealStatusMessage{
Status: "success",
HealInfo: bgHealStatus,
ToleranceForSC: strings.ToUpper(ctx.String("storage-class")),
})
if ctx.Bool("verbose") {
printMsg(verboseBackgroundHealStatusMessage{
Status: "success",
HealInfo: bgHealStatus,
ToleranceForSC: strings.ToUpper(ctx.String("storage-class")),
})
} else {
printMsg(shortBackgroundHealStatusMessage{
Status: "success",
HealInfo: bgHealStatus,
})
}
return nil
}
+1 -1
View File
@@ -18,7 +18,7 @@ require (
github.com/minio/cli v1.22.0
github.com/minio/colorjson v1.0.1
github.com/minio/filepath v1.0.0
github.com/minio/madmin-go v1.2.4
github.com/minio/madmin-go v1.2.6
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/minio-go/v7 v7.0.20
github.com/minio/pkg v1.1.14
+2 -2
View File
@@ -340,8 +340,8 @@ github.com/minio/colorjson v1.0.1/go.mod h1:oPM3zQQY8Gz9NGtgvuBEjQ+gPZLKAGc7T+kj
github.com/minio/filepath v1.0.0 h1:fvkJu1+6X+ECRA6G3+JJETj4QeAYO9sV43I79H8ubDY=
github.com/minio/filepath v1.0.0/go.mod h1:/nRZA2ldl5z6jT9/KQuvZcQlxZIMQoFFQPvEXx9T/Bw=
github.com/minio/madmin-go v1.1.23/go.mod h1:wv8zCroSCnpjjQdmgsdJEkFH2oD4w9J40OZqbhxjiJ4=
github.com/minio/madmin-go v1.2.4 h1:o+0X6ENO/AtkRxCbD4FXT6YCRIH7HgDGb+WzfJFDzMQ=
github.com/minio/madmin-go v1.2.4/go.mod h1:/rOfQv4ohkXJ+7EaSnhg9IJEX7cobX08zkSLfh8G3Ks=
github.com/minio/madmin-go v1.2.6 h1:k4q5I+6nV/r7QBFZtvlPWMJh8uOo5AbEMx/39VXP7kg=
github.com/minio/madmin-go v1.2.6/go.mod h1:/rOfQv4ohkXJ+7EaSnhg9IJEX7cobX08zkSLfh8G3Ks=
github.com/minio/md5-simd v1.1.0/go.mod h1:XpBqgZULrMYD3R+M28PcmP0CkI7PEMzB3U77ZrKZ0Gw=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=