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

Include ring instance ID in InstanceDesc #387

Merged
merged 2 commits into from
Oct 3, 2023
Merged

Conversation

56quarters
Copy link
Contributor

@56quarters 56quarters commented Sep 25, 2023

What this PR does:

This change adds the ID on an instance in a ring to its InstanceDesc object. This allows callers to access the ID of a member of a ring.

This change also modifies the PoolFactory type to accept an InstanceDesc object when creating a new client instead of only the address. This allows PoolFactory implementations to attach any extra metadata about the instance to metrics/logs/traces for the client.

Which issue(s) this PR fixes:

See grafana/mimir#6128

Checklist

  • Tests updated
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@pstibrany
Copy link
Member

This looks like a good start, but the change will only apply to new entries that get added to the ring. What about existing entries?

I wonder if we should add some "fixup" method to the *ring.Desc that would fill all ID fields based on instances map, and call that fixup method after reading ring from the KV store (in (*Ring).starting, (*Ring).loop, or GetOrCreateRingDesc). This would also fix writes back to KV, because writes always read from ring first, and write back afterwards.

@56quarters
Copy link
Contributor Author

This looks like a good start, but the change will only apply to new entries that get added to the ring. What about existing entries?

I wonder if we should add some "fixup" method to the *ring.Desc that would fill all ID fields based on instances map, and call that fixup method after reading ring from the KV store (in (*Ring).starting, (*Ring).loop, or GetOrCreateRingDesc). This would also fix writes back to KV, because writes always read from ring first, and write back afterwards.

Sure, good idea. Is this the type of code that we'll need to keep around indefinitely or something to remove after a while?

@pstibrany
Copy link
Member

Sure, good idea. Is this the type of code that we'll need to keep around indefinitely or something to remove after a while?

I don't see a problem with keeping this indefinitely.

@56quarters
Copy link
Contributor Author

56quarters commented Sep 26, 2023

This looks like a good start, but the change will only apply to new entries that get added to the ring. What about existing entries?

Actually from what I can tell looking at the ring code, it seems like pods will add themselves to the ring on start up, updating their existing entry if required. If we make sure ID is set everywhere instances add themselves, do we still need to go through and update the ring.Desc? IDs for entries in the ring would become available after the first time they restart with this new code if I'm understanding correctly.

@56quarters
Copy link
Contributor Author

I guess explicitly fixing up the ring.Desc means that we have a shorter window of time where InstanceDesc.Id is empty during the first rollout.

@pstibrany
Copy link
Member

pstibrany commented Sep 27, 2023

I guess explicitly fixing up the ring.Desc means that we have a shorter window of time where InstanceDesc.Id is empty during the first rollout.

It would mean that any code using updated dskit can already start using ID field, without relying on other components to re-register in the ring. For example in a mixed environment, where Mimir distributor is updated, but Mimir ingester is not, distributor can already use ID.

@56quarters
Copy link
Contributor Author

I've tested setting instance IDs based on map keys locally with Mimir:

  • Ingesters ran Mimir 2.10 which does not have this change
  • All other components ran local image that included these changes

Everything worked as expected, distributors had access to the ingester IDs when creating clients for the ingesters.

I'm going to test in a dev cluster, only using this new code in distributors.

@56quarters 56quarters marked this pull request as ready for review September 29, 2023 17:55
Copy link
Member

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Thank you! The changes look good. I've verified that both lifecyclers update its instance's ID field in the ring.

BasicLifecycler makes sure to update ID of its entry in the ring in the registerInstance method, even if entry already exists.

Lifecycler uses initRing to add entry to the ring. But if the entry already exists and it's in the JOINING state, entry's ID field will not be updated. However it will be updated later during heartbeating.

I'd suggest to add changelog entry mentioning changes in the client package as well.

This change adds the ID on an instance in a ring to its InstanceDesc
object. This allows callers to access the ID of a member of a ring.

This change also modifies the PoolFactory type to accept an InstanceDesc
object when creating a new client instead of only the address. This
allows PoolFactory implementations to attach any extra metadata about
the instance to metrics/logs/traces for the client.

See grafana/mimir#6128

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
@56quarters 56quarters merged commit 80423d8 into main Oct 3, 2023
3 checks passed
@56quarters 56quarters deleted the 56quarters/ring-ids branch October 3, 2023 14:23
56quarters added a commit to grafana/mimir that referenced this pull request Oct 3, 2023
Update dskit to pull in changes that give us access to instance
IDs when connecting to them via the ring client pool. Specifically
the changes from grafana/dskit#387

Fixes #6128

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
56quarters added a commit to grafana/mimir that referenced this pull request Oct 4, 2023
Update dskit to pull in changes that give us access to instance
IDs when connecting to them via the ring client pool. Specifically
the changes from grafana/dskit#387

Fixes #6128

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
@charleskorn charleskorn mentioned this pull request Oct 13, 2023
2 tasks
ying-jeanne pushed a commit that referenced this pull request Nov 2, 2023
This change adds the ID on an instance in a ring to its InstanceDesc
object. This allows callers to access the ID of a member of a ring.

This change also modifies the PoolFactory type to accept an InstanceDesc
object when creating a new client instead of only the address. This
allows PoolFactory implementations to attach any extra metadata about
the instance to metrics/logs/traces for the client.

See grafana/mimir#6128

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
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.

None yet

2 participants