Skip to content

Commit

Permalink
add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherzli committed Jan 24, 2024
1 parent f6e7a2b commit 8cb9803
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,8 @@ When a Pod becomes unready, the controller will remove it from the hashring.
This behaviour can be considered for use alongside the [Ketama hashing algorithm](https://thanos.io/tip/components/receive.md/#ketama-recommended).

## About the `--use-az-aware-hashring` flag
By default, the controller does not support
By default, the controller does not support az aware hashring introduced in Thanos v0.32+ (https://thanos.io/tip/components/receive.md/#az-aware-ketama-hashring-experimental),
This flag allows the user to enable this behaviour.
When enabled, the controller will generate az aware hashring configuration based on the `--pod-az-annotation-key` flag, namely the value of the annotation key will be used as the az name for each pod.
If not specified, the statefulset name will be used as AZ field.
Note that Thanos has be upgraded to v0.32+ to work with new hashring endpoint struct.
15 changes: 8 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ func (c *controller) sync(ctx context.Context) {
}
// Append the new value to the slice associated with the key
statefulsets[hashring] = append(statefulsets[hashring], sts.DeepCopy())
level.Info(c.logger).Log("Hashring ", hashring, " got a statefulset: ", sts.Name)

time.Sleep(c.options.scaleTimeout) // Give some time for all replicas before they receive hundreds req/s
}
Expand Down Expand Up @@ -697,7 +698,7 @@ func (c *controller) populate(ctx context.Context, hashrings []receive.HashringC
}

endpoints = append(endpoints, endpoint)

level.Info(c.logger).Log("Hashring ", h.Hashring, " got an endpoint: ", endpoint.Address, "with AZ", endpoint.AZ)
}
}

Expand Down Expand Up @@ -825,8 +826,8 @@ func newQueue() *queue {
}

func (q *queue) add() {
q.Lock()
defer q.Unlock()
q.Mutex.Lock()
defer q.Mutex.Unlock()

if !q.ok {
return
Expand All @@ -838,8 +839,8 @@ func (q *queue) add() {
}

func (q *queue) stop() {
q.Lock()
defer q.Unlock()
q.Mutex.Lock()
defer q.Mutex.Unlock()

if !q.ok {
return
Expand All @@ -851,8 +852,8 @@ func (q *queue) stop() {

func (q *queue) get() bool {
<-q.ch
q.Lock()
defer q.Unlock()
q.Mutex.Lock()
defer q.Mutex.Unlock()

return q.ok
}

0 comments on commit 8cb9803

Please sign in to comment.