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

Add PartitionInstanceLifecycler #483

Merged
merged 13 commits into from
Feb 13, 2024
Merged

Conversation

pracucci
Copy link
Contributor

@pracucci pracucci commented Feb 9, 2024

What this PR does:

This is another PR to add another piece of the experimental partitions ring support we're working on. In this PR I'm adding ring.PartitionInstanceLifecycler which is similar to ring.Lifecycler / ring.BasicLifecycler but for partitions ring.

Contrary to ring.BasicLifecycler, ring.PartitionInstanceLifecycler doesn't support hooks: reason is not that hooks are a bad thing and shouldn't be supported (actually it turned out to be a flexible design) but it's just because we don't need hooks right now, so I preferred to keep code simpler and focused on the actual use case we have.

Which issue(s) this PR fixes:

N/A

Checklist

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

Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci pracucci marked this pull request as ready for review February 9, 2024 15:18
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
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.

Great job! (My comments are just tiny suggestions).

actorChan chan func()

// Whether the partitions should be created on startup if it doesn't exist yet.
createPartitionOnStartup *atomic.Bool
Copy link
Member

Choose a reason for hiding this comment

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

nit: Why does this need to be atomic.Bool? I would expect that this flag can only be set before the service is started, and don't expect this to be changed concurrently. (Can this flag be part of config?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can this flag be part of config?

Following current mimir logic, this flag is currently set after the lifecycler is created (and before it's started). That's why I've created a setter.

Why does this need to be atomic.Bool?

Not being part of config, I think we should make it safe even if it's not expected to be changed after lifecycler is started.

Copy link
Member

Choose a reason for hiding this comment

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

After seeing Mimir PR, I understand this choice, but I still think making this part of config would make it clear that this isn't settable after creation of lifecycler.

ring/partition_instance_lifecycler.go Outdated Show resolved Hide resolved

// CreatePartitionOnStartup returns whether the lifecycle creates the partition on startup
// if it doesn't exist.
func (l *PartitionInstanceLifecycler) CreatePartitionOnStartup() bool {
Copy link
Member

Choose a reason for hiding this comment

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

Curious why do we need this "getter", if the flag can only be set before starting lifecycler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's just a getter for any setter. I don't see it a big concern.

ring/partition_instance_lifecycler.go Outdated Show resolved Hide resolved
ring/partition_instance_lifecycler.go Outdated Show resolved Hide resolved
ring/partition_instance_lifecycler.go Outdated Show resolved Hide resolved
ring/partition_instance_lifecycler.go Outdated Show resolved Hide resolved
ring/partition_instance_lifecycler_test.go Outdated Show resolved Hide resolved
ring/partition_instance_lifecycler_test.go Outdated Show resolved Hide resolved
ring/partition_instance_lifecycler_test.go Outdated Show resolved Hide resolved
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
…here was a running error

Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
@pracucci
Copy link
Contributor Author

Thanks @pstibrany for your review. I've either replied or addressed comments. Could you take another look, please?

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 for addressing my feedback.

@pracucci pracucci merged commit 80881aa into main Feb 13, 2024
3 checks passed
@pracucci pracucci deleted the add-partition-instance-lifecycler branch February 13, 2024 10:39
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.

2 participants