From aff236e20ed86492777c341061841e65541b26b9 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 27 Jul 2022 16:46:34 -0700 Subject: [PATCH] fix: cluster healthcheck for single drive setups (#15415) single drive setups must return '200 OK' if drive is accessible, current master returns '503' --- cmd/erasure-single-drive.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/cmd/erasure-single-drive.go b/cmd/erasure-single-drive.go index 1c1b6256f..ae96686e5 100644 --- a/cmd/erasure-single-drive.go +++ b/cmd/erasure-single-drive.go @@ -3092,6 +3092,33 @@ func (es *erasureSingle) Walk(ctx context.Context, bucket, prefix string, result return nil } +// Health - returns current status of the object layer health, for single drive +// its as simple as returning healthy as long as drive is accessible. +func (es *erasureSingle) Health(ctx context.Context, opts HealthOptions) HealthResult { + _, err := es.disk.DiskInfo(ctx) + if err != nil { + return HealthResult{} + } + if opts.Maintenance { + // Single drive cannot be put under maintenance. + return HealthResult{ + Healthy: false, + WriteQuorum: 1, + } + } + return HealthResult{ + Healthy: true, + WriteQuorum: 1, + } +} + +// ReadHealth - returns current status of the object layer health for reads, +// for single drive its as simple as returning healthy as long as drive is accessible. +func (es *erasureSingle) ReadHealth(ctx context.Context) bool { + res := es.Health(ctx, HealthOptions{}) + return res.Healthy +} + // nsScanner will start scanning buckets and send updated totals as they are traversed. // Updates are sent on a regular basis and the caller *must* consume them. func (es *erasureSingle) nsScanner(ctx context.Context, buckets []BucketInfo, bf *bloomFilter, wantCycle uint32, updates chan<- dataUsageCache, healScanMode madmin.HealScanMode) error {