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

[querier] s3: add getObject retry #4453

Merged
merged 13 commits into from
Oct 25, 2021
Merged

[querier] s3: add getObject retry #4453

merged 13 commits into from
Oct 25, 2021

Conversation

liguozhong
Copy link
Contributor

@liguozhong liguozhong commented Oct 11, 2021

fix #4452
this pr fix issues/4452
image

@liguozhong liguozhong requested a review from a team as a code owner October 11, 2021 09:22
@liguozhong
Copy link
Contributor Author

doing

@liguozhong liguozhong closed this Oct 11, 2021
@liguozhong liguozhong reopened this Oct 11, 2021
@pull-request-size pull-request-size bot added size/M and removed size/S labels Oct 11, 2021
@liguozhong
Copy link
Contributor Author

@cyriltovena review pr pls

@@ -115,6 +117,10 @@ func (cfg *S3Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
f.BoolVar(&cfg.HTTPConfig.InsecureSkipVerify, prefix+"s3.http.insecure-skip-verify", false, "Set to true to skip verifying the certificate chain and hostname.")
f.StringVar(&cfg.HTTPConfig.CAFile, prefix+"s3.http.ca-file", "", "Path to the trusted CA file that signed the SSL certificate of the S3 endpoint.")
f.StringVar(&cfg.SignatureVersion, prefix+"s3.signature-version", SignatureVersionV4, fmt.Sprintf("The signature version to use for authenticating against S3. Supported values are: %s.", strings.Join(supportedSignatureVersions, ", ")))
f.DurationVar(&cfg.BackoffConfig.MinBackoff, "s3.min-backoff", 100*time.Millisecond, "Minimum backoff time")
f.DurationVar(&cfg.BackoffConfig.MaxBackoff, "s3.max-backoff", 50*time.Second, "Maximum backoff time")
f.IntVar(&cfg.BackoffConfig.MaxRetries, "s3.max-retries", 20, "Maximum number of times to retry an operation")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f.IntVar(&cfg.BackoffConfig.MaxRetries, "s3.max-retries", 20, "Maximum number of times to retry an operation")
f.IntVar(&cfg.BackoffConfig.MaxRetries, "s3.max-retries", 5, "Maximum number of times to retry an operation")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -115,6 +117,10 @@ func (cfg *S3Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
f.BoolVar(&cfg.HTTPConfig.InsecureSkipVerify, prefix+"s3.http.insecure-skip-verify", false, "Set to true to skip verifying the certificate chain and hostname.")
f.StringVar(&cfg.HTTPConfig.CAFile, prefix+"s3.http.ca-file", "", "Path to the trusted CA file that signed the SSL certificate of the S3 endpoint.")
f.StringVar(&cfg.SignatureVersion, prefix+"s3.signature-version", SignatureVersionV4, fmt.Sprintf("The signature version to use for authenticating against S3. Supported values are: %s.", strings.Join(supportedSignatureVersions, ", ")))
f.DurationVar(&cfg.BackoffConfig.MinBackoff, "s3.min-backoff", 100*time.Millisecond, "Minimum backoff time")
f.DurationVar(&cfg.BackoffConfig.MaxBackoff, "s3.max-backoff", 50*time.Second, "Maximum backoff time")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f.DurationVar(&cfg.BackoffConfig.MaxBackoff, "s3.max-backoff", 50*time.Second, "Maximum backoff time")
f.DurationVar(&cfg.BackoffConfig.MaxBackoff, "s3.max-backoff", 3*time.Second, "Maximum backoff time")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

Looking good can you add more meat to the flag documentation, e.g related to s3 get operation.

@liguozhong
Copy link
Contributor Author

Looking good can you add more meat to the flag documentation, e.g related to s3 get operation.

done

@liguozhong
Copy link
Contributor Author

@cyriltovena review pr pls

pkg/storage/chunk/aws/s3_storage_client.go Outdated Show resolved Hide resolved
pkg/storage/chunk/aws/s3_storage_client.go Show resolved Hide resolved
pkg/storage/chunk/aws/s3_storage_client.go Outdated Show resolved Hide resolved
pkg/storage/chunk/aws/s3_storage_client.go Outdated Show resolved Hide resolved
@DylanGuedes
Copy link
Contributor

DylanGuedes commented Oct 14, 2021

Btw, you forgot to write the changes on the CHANGELOG and to document the new parameters in the docs located at docs/sources/configuration/_index.md.

Suggestion:

* [4453](https://github.com/grafana/loki/pull/4453) **liguozhong**: Loki: Implement retry to s3 chunk storage

@liguozhong
Copy link
Contributor Author

Btw, you forgot to write the changes on the CHANGELOG and to document the new parameters in the docs located at docs/sources/configuration/_index.md.

Suggestion:

* [4453](https://github.com/grafana/loki/pull/4453) **liguozhong**: Loki: Implement retry to s3 chunk storage

thanks,done

docs/sources/configuration/_index.md Outdated Show resolved Hide resolved
docs/sources/configuration/_index.md Outdated Show resolved Hide resolved
Copy link
Contributor

@KMiller-Grafana KMiller-Grafana left a comment

Choose a reason for hiding this comment

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

Docs change to correct spelling.

Comment on lines 1219 to 1229
# Configures backoff when s3 get Object.
backoff_config:
# Minimum delay when backing off.
# CLI flag: -s3.backoff-min-period
[min_period: <duration> | default = 100ms]

# The maximum delay when backing off.
# CLI flag: -s3.backoff-max-period
[max_period: <duration> | default = 3s]

# Number of times to backoff and retry before failing.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Configures backoff when s3 get Object.
backoff_config:
# Minimum delay when backing off.
# CLI flag: -s3.backoff-min-period
[min_period: <duration> | default = 100ms]
# The maximum delay when backing off.
# CLI flag: -s3.backoff-max-period
[max_period: <duration> | default = 3s]
# Number of times to backoff and retry before failing.
# Configures back off when s3 get Object.
backoff_config:
# Minimum duration to back off.
# CLI flag: -s3.backoff-min-period
[min_period: <duration> | default = 100ms]
# The maximum duration to back off.
# CLI flag: -s3.backoff-max-period
[max_period: <duration> | default = 3s]
# Number of times to back off and retry before failing.

@liguozhong
Copy link
Contributor Author

Docs change to correct spelling.

done ,thanks

Copy link
Contributor

@KMiller-Grafana KMiller-Grafana left a comment

Choose a reason for hiding this comment

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

Docs portion of this PR looks good to me now. Next time @liguozhong , you can just hit the 'commit suggestion' box to accept suggested changes. That would make it trivial for me to re-review.

@liguozhong
Copy link
Contributor Author

Docs portion of this PR looks good to me now. Next time @liguozhong , you can just hit the 'commit suggestion' box to accept suggested changes. That would make it trivial for me to re-review.

👍 thanks

@liguozhong
Copy link
Contributor Author

@DylanGuedes review pr pls

@DylanGuedes
Copy link
Contributor

DylanGuedes commented Oct 19, 2021

@DylanGuedes review pr pls

Do you mind having a look at this suggestion? I think that the check starting at line 344 is unnecessary after the latest changes.

Besides that, this looks solid, good job. Not sure if the maintainers would like to see some tests (although I checked the test files and looks like that function wasn't being tested so maybe they won't block you for that).

@liguozhong
Copy link
Contributor Author

liguozhong commented Oct 19, 2021

@DylanGuedes review pr pls

Do you mind having a look at this suggestion? I think that the check starting at line 344 is unnecessary after the latest changes.

Besides that, this looks solid, good job. Not sure if the maintainers would like to see some tests (although I checked the test files and looks like that function wasn't being tested so maybe they won't block you for that).

I'm not familiar with the'commit suggestion' box。
Code optimization has been done according to your suggestions。

image

Comment on lines +344 to +349
err := ctx.Err()
for retries.Ongoing() {
if ctx.Err() != nil {
return nil, errors.Wrap(ctx.Err(), "ctx related error during s3 getObject")
}
err = instrument.CollectedRequest(ctx, "S3.GetObject", s3RequestDuration, instrument.ErrorCode, func(ctx context.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
err := ctx.Err()
for retries.Ongoing() {
if ctx.Err() != nil {
return nil, errors.Wrap(ctx.Err(), "ctx related error during s3 getObject")
}
err = instrument.CollectedRequest(ctx, "S3.GetObject", s3RequestDuration, instrument.ErrorCode, func(ctx context.Context) error {
for retries.Ongoing() {
if err := ctx.Err(); err != nil {
return nil, errors.Wrap(err, "ctx related error during s3 getObject")
}
err := instrument.CollectedRequest(ctx, "S3.GetObject", s3RequestDuration, instrument.ErrorCode, func(ctx context.Context) error {

@DylanGuedes
Copy link
Contributor

@DylanGuedes review pr pls

Do you mind having a look at this suggestion? I think that the check starting at line 344 is unnecessary after the latest changes.
Besides that, this looks solid, good job. Not sure if the maintainers would like to see some tests (although I checked the test files and looks like that function wasn't being tested so maybe they won't block you for that).

I'm not familiar with the'commit suggestion' box。 Code optimization has been done according to your suggestions。

My bad, I didn't notice the change. I added a final one where I suggest moving the err assignment.

Anyway, LGTM!

@liguozhong
Copy link
Contributor Author

@DylanGuedes review pr pls

Do you mind having a look at this suggestion? I think that the check starting at line 344 is unnecessary after the latest changes.
Besides that, this looks solid, good job. Not sure if the maintainers would like to see some tests (although I checked the test files and looks like that function wasn't being tested so maybe they won't block you for that).

I'm not familiar with the'commit suggestion' box。 Code optimization has been done according to your suggestions。

My bad, I didn't notice the change. I added a final one where I suggest moving the err assignment.

Anyway, LGTM!

sorry, I'm not familiar with the'commit suggestion' box。
I will try to learn this next time I submit a PR

Copy link
Member

@owen-d owen-d left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your patience.

@owen-d owen-d merged commit 6fcd02b into grafana:main Oct 25, 2021
@liguozhong
Copy link
Contributor Author

LGTM, thanks for your patience.

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[querier] s3: add getObject retry
5 participants