From 1e2c5cec0a4d2b6c6b152e45f2cf413eb1871afb Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Thu, 7 Dec 2023 14:13:04 -0800 Subject: [PATCH 1/2] ready: Do not quit when the target server is offline or any other error (#4783) Ready makes sense to not quit in any case, until the target server is fully initialized --- .github/workflows/vulncheck.yml | 2 +- cmd/ready.go | 29 +++++++++++------------------ 2 files changed, 12 insertions(+), 19 deletions(-) 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/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) } } From 1ba9435365a772d6b4cab225458306a70dfb2309 Mon Sep 17 00:00:00 2001 From: Shubhendu Date: Fri, 8 Dec 2023 03:43:17 +0530 Subject: [PATCH 2/2] Fix a panic for bucket heal (#4781) Signed-off-by: Shubhendu Ram Tripathi --- cmd/admin-heal-result-item.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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 }