Avoid ListBuckets() call instead rely on simple HTTP GET (#8475)

This is to avoid making calls to backend and requiring
gateways to allow permissions for ListBuckets() operation
just for Liveness checks, we can avoid this and make
our liveness checks to be more performant.
This commit is contained in:
Harshavardhana
2019-11-01 16:58:11 -07:00
committed by kannappanr
parent d28bcb4f84
commit 07a556a10b
10 changed files with 80 additions and 24 deletions

View File

@@ -123,7 +123,10 @@ func (g *B2) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error)
return &b2Objects{
creds: creds,
b2Client: client,
ctx: ctx,
httpClient: &http.Client{
Transport: minio.NewCustomHTTPTransport(),
},
ctx: ctx,
}, nil
}
@@ -135,10 +138,11 @@ func (g *B2) Production() bool {
// b2Object implements gateway for MinIO and BackBlaze B2 compatible object storage servers.
type b2Objects struct {
minio.GatewayUnsupported
mu sync.Mutex
creds auth.Credentials
b2Client *b2.B2
ctx context.Context
mu sync.Mutex
creds auth.Credentials
b2Client *b2.B2
httpClient *http.Client
ctx context.Context
}
// Convert B2 errors to minio object layer errors.
@@ -225,12 +229,13 @@ func b2MsgCodeToObjectError(code int, msgCode string, msg string, params ...stri
// Shutdown saves any gateway metadata to disk
// if necessary and reload upon next restart.
func (l *b2Objects) Shutdown(ctx context.Context) error {
// TODO
return nil
}
// StorageInfo is not relevant to B2 backend.
func (l *b2Objects) StorageInfo(ctx context.Context) (si minio.StorageInfo) {
si.Backend.Type = minio.BackendGateway
si.Backend.GatewayOnline = minio.IsBackendOnline(ctx, l.httpClient, "https://api.backblazeb2.com/b2api/v1")
return si
}