Skip to content

Commit

Permalink
Merge branch 'master' into bucket-throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
shtripat authored Dec 11, 2023
2 parents dbcb7b4 + 1ba9435 commit f7d157d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/vulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 12 additions & 3 deletions cmd/admin-heal-result-item.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
29 changes: 11 additions & 18 deletions cmd/ready.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit f7d157d

Please sign in to comment.