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

ISSUE 314: use notifier threshold to configure evaluator ShowAll #354

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/internal/notifier/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ type Coordinator struct {

clusters map[string]*clusterGroups
clusterLock *sync.RWMutex

// The value of the 'ShowAll' parameter when submitting a request to
// the evaluator. This flag is determined based on the notifier
// 'threshold' configuration.
ShowAll bool
}

// getModuleForClass returns the correct module based on the passed className. As part of the Configure steps, if there
Expand Down Expand Up @@ -162,6 +167,7 @@ func (nc *Coordinator) Configure() {
nc.quitChannel = make(chan struct{})
nc.running = sync.WaitGroup{}
nc.evaluatorResponse = make(chan *protocol.ConsumerGroupStatus)
nc.ShowAll = false

// Set the function for parsing templates and calling module Notify (configurable to enable testing)
if nc.templateParseFunc == nil {
Expand All @@ -185,6 +191,13 @@ func (nc *Coordinator) Configure() {
viper.SetDefault(configRoot+".send-interval", viper.GetInt64(configRoot+".interval"))
viper.SetDefault(configRoot+".threshold", 2)

// if any of the notifier thresholds are 1, we need to fetch
// status of all consumer groups from the evaluator
threshold := viper.GetInt(configRoot + ".threshold")
if threshold == 1 {
nc.ShowAll = true
}

// Compile the whitelist for the consumer groups to notify for
var groupWhitelist *regexp.Regexp
whitelist := viper.GetString(configRoot + ".group-whitelist")
Expand Down Expand Up @@ -375,6 +388,7 @@ func (nc *Coordinator) sendEvaluatorRequests() {
Reply: nc.evaluatorResponse,
Cluster: sendCluster,
Group: sendConsumer,
ShowAll: nc.ShowAll,
}
}(cluster, consumer)
groupInfo.LastEval = timeNow
Expand Down
4 changes: 2 additions & 2 deletions core/internal/notifier/coordinator_race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func TestCoordinator_sendEvaluatorRequests(t *testing.T) {
case "testcluster":
assert.Equalf(t, "testcluster", request.Cluster, "Expected request cluster to be testcluster, not %v", request.Cluster)
assert.Equalf(t, "testgroup", request.Group, "Expected request group to be testgroup, not %v", request.Group)
assert.False(t, request.ShowAll, "Expected ShowAll to be false")
assert.True(t, request.ShowAll, "Expected ShowAll to be true")
case "testcluster2":
assert.Equalf(t, "testcluster2", request.Cluster, "Expected request cluster to be testcluster2, not %v", request.Cluster)
assert.Equalf(t, "testgroup2", request.Group, "Expected request group to be testgroup2, not %v", request.Group)
assert.False(t, request.ShowAll, "Expected ShowAll to be false")
assert.True(t, request.ShowAll, "Expected ShowAll to be true")
default:
assert.Failf(t, "Received unexpected request for cluster %v, group %v", request.Cluster, request.Group)
}
Expand Down