diff --git a/.github/workflows/vulncheck.yml b/.github/workflows/vulncheck.yml index fa65389997..36c61a24d4 100644 --- a/.github/workflows/vulncheck.yml +++ b/.github/workflows/vulncheck.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.21.4 + go-version: 1.21.5 check-latest: true - name: Get official govulncheck run: go install golang.org/x/vuln/cmd/govulncheck@latest diff --git a/cmd/admin-heal-result-item.go b/cmd/admin-heal-result-item.go index 239045372b..e5acc512f2 100644 --- a/cmd/admin-heal-result-item.go +++ b/cmd/admin-heal-result-item.go @@ -61,9 +61,18 @@ func (h hri) getReplicatedFileHCCChange() (b, a col, err error) { getColCode := func(numAvail int) (c col, err error) { // calculate color code for replicated object similar // to erasure coded objects - quorum := h.DiskCount/h.SetCount/2 + 1 - surplus := numAvail/h.SetCount - quorum - parity := h.DiskCount/h.SetCount - quorum + var quorum, surplus, parity int + if h.SetCount > 0 { + quorum = h.DiskCount/h.SetCount/2 + 1 + surplus = numAvail/h.SetCount - quorum + parity = h.DiskCount/h.SetCount - quorum + } else { + // in case of bucket healing, disk count is for the node + // also explicitly set count would be set to invalid value of -1 + quorum = h.DiskCount/2 + 1 + surplus = numAvail - quorum + parity = h.DiskCount - quorum + } c, err = getHColCode(surplus, parity) return } diff --git a/cmd/ready.go b/cmd/ready.go index c07550178d..62c3da1bf4 100644 --- a/cmd/ready.go +++ b/cmd/ready.go @@ -77,13 +77,19 @@ type readyMessage struct { MaintenanceMode bool `json:"maintenanceMode"` WriteQuorum int `json:"writeQuorum"` HealingDrives int `json:"healingDrives"` + + Err error `json:"error"` } func (r readyMessage) String() string { - if r.Healthy { + switch { + case r.Healthy: return color.GreenString("The cluster is ready") + case r.Err != nil: + return color.RedString("The cluster is unreachable: " + r.Err.Error()) + default: + return color.RedString("The cluster is not ready") } - return color.RedString("The cluster is not ready") } // JSON jsonified ready result @@ -116,38 +122,25 @@ func mainReady(cliCtx *cli.Context) error { Maintenance: maintenance, } - healthResult, hErr := anonClient.Healthy(ctx, healthOpts) - fatalIf(probe.NewError(hErr).Trace(aliasedURL), "Couldn't get the health status for `"+aliasedURL+"`.") - - if healthResult.Healthy { - printMsg(readyMessage{ - Healthy: healthResult.Healthy, - MaintenanceMode: healthResult.MaintenanceMode, - WriteQuorum: healthResult.WriteQuorum, - HealingDrives: healthResult.HealingDrives, - }) - return nil - } - - timer := time.NewTimer(healthCheckInterval) + timer := time.NewTimer(0) defer timer.Stop() + for { select { case <-ctx.Done(): return nil case <-timer.C: healthResult, hErr := anonClient.Healthy(ctx, healthOpts) - fatalIf(probe.NewError(hErr).Trace(aliasedURL), "Couldn't get the health status for `"+aliasedURL+"`.") printMsg(readyMessage{ Healthy: healthResult.Healthy, MaintenanceMode: healthResult.MaintenanceMode, WriteQuorum: healthResult.WriteQuorum, HealingDrives: healthResult.HealingDrives, + Err: hErr, }) if healthResult.Healthy { return nil } - timer.Reset(healthCheckInterval) } }