Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCS: Adds HTTP Config similar to S3 #86

Merged
merged 4 commits into from
Feb 5, 2024

Conversation

JoaoBraveCoding
Copy link
Collaborator

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Adds HTTP Config to GCS. This would be required to allow us to support hedging while using this project as a storage backend. HTTP Config allows us to configure a Transport which would enable the utilization of https://github.com/cristalhq/hedgedhttp when using the GCS provider

Related with: grafana/loki#11132

Verification

Signed-off-by: Joao Marcal <[email protected]>
Signed-off-by: Joao Marcal <[email protected]>
Copy link
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good to me overall!
Maybe @fpetkovski can take a look as well, as he's familiar with GCS.

@@ -11,6 +11,16 @@ import (
"github.com/prometheus/common/model"
)

var DefaultHTTPConfig = HTTPConfig{
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might lead to an unexpected breaking change with every other provider except S3. Do we know what the defaults for GCS currently are?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IIUC nowadays how objstorage works then it will eventually call defaultBaseTransport on the google-api-go-client in transport/http/dial.go which actually uses http.DefaultTransport src/net/http/transport.go, they only overwrite MaxIdleConnsPerHost to 100 (same value we use).

So looking at the differences if we were to move forward with my change we would be setting:

  • MaxConnsPerHost Since this is not set on the DefaultTransport struct I believe it will just use default int value of 0 which would match our value
  • ResponseHeaderTimeout Again IIUC here the default here would be 0 which would differ from our "default" of 2 minutes.
  • DialContext.DualStack This apparently has been deprecated so we can even remove it from our "default" since it's enabled by default

And we would not be setting ForceAttemptHTTP2 which http.DefaultTransport sets. This is where we could break some things.

With all this being said I don't have much experience with all this so I'm happy to play it safe and change the PR to make GCS use http.DefaultTransport

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the detailed explanation 👍 Let's try this out and see if it has any significant impact.

@JoaoBraveCoding
Copy link
Collaborator Author

@saswatamcode @fpetkovski anything else I could do to move this forward?

Copy link
Contributor

@fpetkovski fpetkovski left a comment

Choose a reason for hiding this comment

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

LGTM

@JoaoBraveCoding
Copy link
Collaborator Author

@saswatamcode @fpetkovski I've updated the PR is there anything else we can do to move this forward? Soon this might become a blocker for Loki adoption of thanos.io/objstore

Copy link
Member

@saswatamcode saswatamcode left a comment

Choose a reason for hiding this comment

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

Let's merge and try it out.

@saswatamcode saswatamcode merged commit cd121fe into thanos-io:main Feb 5, 2024
7 checks passed
@saswatamcode saswatamcode mentioned this pull request Feb 12, 2024
2 tasks
Comment on lines +97 to +98
} else {
opts = append(opts, option.WithoutAuthentication())

Choose a reason for hiding this comment

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

This change is described as "Fix tests"; it stops the GCS client from using config from environment variables.

Choose a reason for hiding this comment

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

+1, From what I understand, this would break GCP workload identity from working

Context: https://cloud-native.slack.com/archives/CK5RSSC10/p1633961188039700

Choose a reason for hiding this comment

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

Literally came to this repo to report this bug; this just hit me in a pre-prod environment and came to report it here :)

Copy link
Contributor

Choose a reason for hiding this comment

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

@JoaoBraveCoding would you have time to look into this?

Copy link
Member

Choose a reason for hiding this comment

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

I think the test fails as we call htransport.NewTransport later which errors out. Trying to fix here: #106

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Had plans to fix it this morning but @saswatamcode beat me to it (thank you!) Apologies for having broken GCS authentication with env vars!

JoaoBraveCoding added a commit to JoaoBraveCoding/objstore that referenced this pull request Mar 4, 2024
JoaoBraveCoding added a commit to JoaoBraveCoding/objstore that referenced this pull request Mar 4, 2024
saswatamcode pushed a commit that referenced this pull request Mar 9, 2024
GCS: adds scope to fix bug introduced in #86
Issue was reported in #106 (comment)

Signed-off-by: Joao Marcal <[email protected]>
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.

6 participants