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

support az aware endpoints with multiple sts in one hashring #1

Merged
merged 7 commits into from
Jan 25, 2024

Conversation

christopherzli
Copy link

@christopherzli christopherzli commented Jan 23, 2024

What changes are proposed in this pull request?

  1. Support az aware hashring in Thanos v0.32+
    https://thanos.io/tip/components/receive.md/#az-aware-ketama-hashring-experimental,
  2. also supported multiple sts in one hashring config
  3. fix lint and go dependency issues
    OSS PR: support az aware hashring and multiple sts in one hashring observatorium/thanos-receive-controller#129

How is this tested?

main_test.go,
Make thanos-receive-controller
pending test in deployment

main_test.go Show resolved Hide resolved
@christopherzli christopherzli changed the title support az aware endpoints support az aware endpoints with multiple sts in one hashring Jan 24, 2024
@christopherzli christopherzli requested a review from jnyi January 24, 2024 02:33
main.go Show resolved Hide resolved
main.go Show resolved Hide resolved
main.go Show resolved Hide resolved
Copy link

@hczhu-db hczhu-db left a comment

Choose a reason for hiding this comment

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

nice work

main.go Outdated Show resolved Hide resolved
@@ -5,6 +5,7 @@
# But not these files:
Copy link
Author

Choose a reason for hiding this comment

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

update bingo depdencies

Copy link
Author

Choose a reason for hiding this comment

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

for lint

@@ -283,7 +289,7 @@ func newReflectorMetrics(reg *prometheus.Registry) prometheusReflectorMetrics {

const labelParts = 2

func splitLabel(in string) (key, value string) {
func splitLabel(in string) (string, string) {
Copy link
Author

Choose a reason for hiding this comment

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

nonamedreturns lint rule

@@ -292,35 +298,35 @@ func splitLabel(in string) (key, value string) {
return parts[0], parts[1]
}

func (p prometheusReflectorMetrics) NewListsMetric(name string) cache.CounterMetric {
func (p prometheusReflectorMetrics) NewListsMetric(_ string) cache.CounterMetric {
Copy link
Author

Choose a reason for hiding this comment

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

name is not used

main.go Outdated
@@ -679,6 +686,40 @@ func (c *controller) populate(ctx context.Context, hashrings []receive.HashringC
}
}

func (c *controller) populateEndpoint(sts *appsv1.StatefulSet, podIndex int, err error, pod *corev1.Pod) receive.Endpoint {
Copy link
Author

Choose a reason for hiding this comment

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

extract method to reduce cognitive complexity to resolve lint errors

main_test.go Show resolved Hide resolved
Copy link

@jnyi jnyi left a comment

Choose a reason for hiding this comment

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

this is great, one small comment, you can consider to send this PR to upstream for review too

@christopherzli
Copy link
Author

verified in k8s that this will work
Screenshot 2024-01-25 at 2 16 19 AM
cc @jnyi

@@ -563,9 +573,9 @@ func (c *controller) sync(ctx context.Context) {
}

// If there's an increase in replicas we poll for the new replicas to be ready
if _, ok := c.replicas[hashring]; ok && c.replicas[hashring] < *sts.Spec.Replicas {
if _, ok := c.replicas[sts.Name]; ok && c.replicas[sts.Name] < *sts.Spec.Replicas {
Copy link
Author

Choose a reason for hiding this comment

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

found a bug when multiple sts pointing to same replicas, not sure whats the point of using hashring name as the key

@christopherzli christopherzli merged commit a3e6cb4 into main Jan 25, 2024
4 checks passed
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.

3 participants