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
This commit is contained in:
@@ -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
|
||||
|
||||
+11
-18
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user