lib/promscrape: follow-up after eabcfc9bcd

`-promscrape.cluster.membersCount` by default should be `1`, like every
single vmagent is a cluster of one member on its own.
The change additionally validates that user can't set `-promscrape.cluster.membersCount`
to value lower than `1`.

eabcfc9bcd
Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
hagen1778 2023-08-29 10:04:57 +02:00 committed by Aliaksandr Valialkin
parent 685c3d95e7
commit d70b346623
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 5 additions and 1 deletions

View file

@ -83,7 +83,10 @@ func mustInitClusterMemberID() {
if err != nil {
logger.Fatalf("cannot parse -promscrape.cluster.memberNum=%q: %s", *clusterMemberNum, err)
}
if n < 0 || (*clusterMembersCount != 0 && n >= *clusterMembersCount) {
if *clusterMembersCount < 1 {
logger.Fatalf("-promscrape.cluster.membersCount can't be lower than 1: got %d", *clusterMembersCount)
}
if n < 0 || n >= *clusterMembersCount {
logger.Fatalf("-promscrape.cluster.memberNum must be in the range [0..%d] according to -promscrape.cluster.membersCount=%d",
*clusterMembersCount, *clusterMembersCount)
}

View file

@ -123,6 +123,7 @@ func TestNeedSkipScrapeWork(t *testing.T) {
}
// Disabled clustering
f("foo", 0, 0, 0, false)
f("foo", 0, 0, 1, false)
// A cluster with 2 nodes with disabled replication
f("foo", 2, 0, 0, true)