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

feat: add recalculateOwnedStreams to check stream ownership if the ring is changed #13103

Conversation

JordanRushing
Copy link
Contributor

@JordanRushing JordanRushing commented Jun 3, 2024

What this PR does / why we need it:

re:

This PR adds a recalculateOwnedStreams service to ingesters which periodically polls in the ingester ring and updates the owned stream counts of each instance.

When Loki ingesters are auto-scaled and run in a zone-aware configuration adding replicas to an ingester statefulset can cause inadvertent stream limiting until old streams are flushed from memory. Using a new limiter that dynamically determines owned streams helps to solve this issue.

Which issue(s) this PR fixes:

N/A

Special notes for your reviewer:

N/A

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • For Helm chart changes bump the Helm chart version in production/helm/loki/Chart.yaml and update production/helm/loki/CHANGELOG.md and production/helm/loki/README.md. Example PR
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

…re recalculating owned streams; `go mod tidy && go mod vendor`; update ingester tests

Signed-off-by: JordanRushing <[email protected]>
@JordanRushing JordanRushing self-assigned this Jun 3, 2024
Copy link
Contributor

@vlad-diachenko vlad-diachenko left a comment

Choose a reason for hiding this comment

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

the implementation looks really great. just minor things to address

pkg/ingester/instance.go Outdated Show resolved Hide resolved
pkg/ingester/recalculate_owned_streams.go Outdated Show resolved Hide resolved
pkg/ingester/ingester.go Outdated Show resolved Hide resolved
pkg/ingester/ingester.go Outdated Show resolved Hide resolved
…r-limit

# Conflicts:
#	pkg/ingester/instance_test.go
Signed-off-by: Vladyslav Diachenko <[email protected]>
@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Jun 12, 2024
@vlad-diachenko vlad-diachenko changed the title [WIP] Update ownedStreamService to check the ingester ring for changes before recalculating an instance's owned streams; go mod tidy && go mod vendor; update ingester tests feat: add recalculateOwnedStreams to check stream ownership if the ring is changed Jun 12, 2024
@vlad-diachenko vlad-diachenko marked this pull request as ready for review June 12, 2024 11:29
@vlad-diachenko vlad-diachenko requested a review from a team as a code owner June 12, 2024 11:29
Copy link
Contributor

@vlad-diachenko vlad-diachenko left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor Author

@JordanRushing JordanRushing left a comment

Choose a reason for hiding this comment

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

Changes look great. Should we consider combining owned_streams and recalculate_owned_streams into a single file? I also wonder if we should re-name them ownedStreamsCountService and recalculateOwnedStreamCount for clarity? Not blocking though.

@vlad-diachenko
Copy link
Contributor

Changes look great. Should we consider combining owned_streams and recalculate_owned_streams into a single file? I also wonder if we should re-name them ownedStreamsCountService and recalculateOwnedStreamCount for clarity? Not blocking though.

I would keep these two files separately. that said, we can find better names for it ))) let's discuss it next week and rename it afterward

@vlad-diachenko vlad-diachenko enabled auto-merge (squash) June 14, 2024 07:54
@vlad-diachenko
Copy link
Contributor

merging it to have these changes included in the next weekly release.

@vlad-diachenko vlad-diachenko merged commit e7689b2 into grafana:main Jun 14, 2024
60 checks passed
JordanRushing added a commit to JordanRushing/loki that referenced this pull request Jul 15, 2024
Ingester stream limits now take into account "owned streams" and periodically
update when the Ingester ring is changed. Non-owned streams are now also
flushed when this update takes place. The stream limit calculation has also been updated for improved
accuracy in multi-zone ingester deployments.

Relevant PRs:
- grafana#13006
- grafana#13030
- grafana#13232
- grafana#13103
- grafana#13231
- grafana#13254
- grafana#13314
- grafana#13321
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants