Skip to content

fix(minio): add SkipConnectionValidation option for restricted environments#59

Open
sounak98 wants to merge 1 commit intomainfrom
fix/replace-listbuckets-with-headbucket-for-validation
Open

fix(minio): add SkipConnectionValidation option for restricted environments#59
sounak98 wants to merge 1 commit intomainfrom
fix/replace-listbuckets-with-headbucket-for-validation

Conversation

@sounak98
Copy link
Contributor

@sounak98 sounak98 commented Feb 24, 2026

Summary

  • Adds SkipConnectionValidation bool to ConnectionConfig (defaults to false)
  • When true, skips the ListBuckets calls in startup validation, health monitoring, and reconnection
  • All existing behavior is preserved by default

Context

BA migrated a Pharia environment from v1 to v2. The std minio client calls ListBuckets (requires s3:ListAllMyBuckets) for connection validation, which fails in their restricted environment.

What changed

When SkipConnectionValidation = true:

  • NewClient skips startup validation
  • monitorConnection health checks become no-ops
  • retryConnection skips validation before swapping client pointers

When SkipConnectionValidation = false (default): no behavior change.

Test plan

  • go build ./v1/minio/... passes
  • go vet passes (pre-existing warnings in integration test only)
  • Verify with BA environment after pharia-data-api sets SkipConnectionValidation: true

Fixes: SPHER-3435

if m.cfg.Connection.ValidationBucket != "" {
_, err = newClient.BucketExists(ctxReconnect, m.cfg.Connection.ValidationBucket)
} else {
_, err = newClient.ListBuckets(ctxReconnect)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we do this at all in reconnect loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Removed it entirely. The updated PR drops validateConnection and all ListBuckets calls from startup, health monitoring, and reconnection. Connection issues are surfaced by the operations themselves.

@sounak98 sounak98 force-pushed the fix/replace-listbuckets-with-headbucket-for-validation branch from 5d62e98 to 41560a3 Compare February 25, 2026 07:54
@sounak98 sounak98 changed the title fix(minio): use HeadBucket instead of ListBuckets for connection validation fix(minio): remove ListBuckets-based connection validation Feb 25, 2026
@sounak98 sounak98 force-pushed the fix/replace-listbuckets-with-headbucket-for-validation branch from 41560a3 to d72831b Compare February 25, 2026 08:14
@sounak98 sounak98 changed the title fix(minio): remove ListBuckets-based connection validation fix(minio): support HeadBucket for connection validation in restricted environments Feb 25, 2026
@sounak98 sounak98 force-pushed the fix/replace-listbuckets-with-headbucket-for-validation branch from d72831b to f6608f2 Compare February 25, 2026 08:19
@sounak98 sounak98 changed the title fix(minio): support HeadBucket for connection validation in restricted environments fix(minio): add SkipConnectionValidation option for restricted environments Feb 25, 2026
continue reconnectLoop
}
} else {
cancel()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this purpose of the cancel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The cancel() was there to avoid leaking the ctxReconnect context created at the top of the block. Moved the context creation inside the validation branch so it only exists when actually needed. The else { cancel() } is gone now.

…nments

Add SkipConnectionValidation bool to ConnectionConfig. When true, the
client skips the ListBuckets calls used for connection validation on
startup, periodic health checks, and reconnection. This allows the
client to work in environments where s3:ListAllMyBuckets is not granted.

Defaults to false, preserving existing behavior.

Fixes: SPHER-3435
@sounak98 sounak98 force-pushed the fix/replace-listbuckets-with-headbucket-for-validation branch from f6608f2 to f7e238a Compare February 25, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants