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

@@ -208,6 +208,9 @@ func (g *GCS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error)
gcs := &gcsGateway{
client: client,
projectID: g.projectID,
httpClient: &http.Client{
Transport: minio.NewCustomHTTPTransport(),
},
}
// Start background process to cleanup old files in minio.sys.tmp
@@ -346,8 +349,9 @@ func isValidGCSProjectIDFormat(projectID string) bool {
// gcsGateway - Implements gateway for MinIO and GCS compatible object storage servers.
type gcsGateway struct {
minio.GatewayUnsupported
client *storage.Client
projectID string
client *storage.Client
httpClient *http.Client
projectID string
}
// Returns projectID from the GOOGLE_APPLICATION_CREDENTIALS file.
@@ -412,8 +416,10 @@ func (l *gcsGateway) Shutdown(ctx context.Context) error {
}
// StorageInfo - Not relevant to GCS backend.
func (l *gcsGateway) StorageInfo(ctx context.Context) minio.StorageInfo {
return minio.StorageInfo{}
func (l *gcsGateway) StorageInfo(ctx context.Context) (si minio.StorageInfo) {
si.Backend.Type = minio.BackendGateway
si.Backend.GatewayOnline = minio.IsBackendOnline(ctx, l.httpClient, "https://storage.googleapis.com")
return si
}
// MakeBucketWithLocation - Create a new container on GCS backend.