@@ -13,6 +13,13 @@ const (
13
13
GossipPort = 9094
14
14
)
15
15
16
+ type RingStore string
17
+
18
+ const (
19
+ RingStoreConsul RingStore = "consul"
20
+ RingStoreEtcd RingStore = "etcd"
21
+ )
22
+
16
23
// GetDefaultImage returns the Docker image to use to run Cortex.
17
24
func GetDefaultImage () string {
18
25
// Get the cortex image from the CORTEX_IMAGE env variable,
@@ -24,15 +31,23 @@ func GetDefaultImage() string {
24
31
return "quay.io/cortexproject/cortex:latest"
25
32
}
26
33
27
- func NewDistributor (name string , consulAddress string , flags map [string ]string , image string ) * CortexService {
28
- return NewDistributorWithConfigFile (name , consulAddress , "" , flags , image )
34
+ func NewDistributor (name string , store RingStore , address string , flags map [string ]string , image string ) * CortexService {
35
+ return NewDistributorWithConfigFile (name , store , address , "" , flags , image )
29
36
}
30
37
31
- func NewDistributorWithConfigFile (name , consulAddress , configFile string , flags map [string ]string , image string ) * CortexService {
38
+ func NewDistributorWithConfigFile (name string , store RingStore , address , configFile string , flags map [string ]string , image string ) * CortexService {
32
39
if configFile != "" {
33
40
flags ["-config.file" ] = filepath .Join (e2e .ContainerSharedDir , configFile )
34
41
}
35
42
43
+ // Configure the ingesters ring backend
44
+ flags ["-ring.store" ] = string (store )
45
+ if store == RingStoreConsul {
46
+ flags ["-consul.hostname" ] = address
47
+ } else if store == RingStoreEtcd {
48
+ flags ["-etcd.endpoints" ] = address
49
+ }
50
+
36
51
if image == "" {
37
52
image = GetDefaultImage ()
38
53
}
@@ -45,25 +60,39 @@ func NewDistributorWithConfigFile(name, consulAddress, configFile string, flags
45
60
"-log.level" : "warn" ,
46
61
"-auth.enabled" : "true" ,
47
62
"-distributor.replication-factor" : "1" ,
48
- // Configure the ingesters ring backend
49
- "-ring.store" : "consul" ,
50
- "-consul.hostname" : consulAddress ,
51
63
}, flags ))... ),
52
64
e2e .NewHTTPReadinessProbe (httpPort , "/ready" , 200 , 299 ),
53
65
httpPort ,
54
66
grpcPort ,
55
67
)
56
68
}
57
69
58
- func NewQuerier (name string , consulAddress string , flags map [string ]string , image string ) * CortexService {
59
- return NewQuerierWithConfigFile (name , consulAddress , "" , flags , image )
70
+ func NewQuerier (name string , store RingStore , address string , flags map [string ]string , image string ) * CortexService {
71
+ return NewQuerierWithConfigFile (name , store , address , "" , flags , image )
60
72
}
61
73
62
- func NewQuerierWithConfigFile (name , consulAddress , configFile string , flags map [string ]string , image string ) * CortexService {
74
+ func NewQuerierWithConfigFile (name string , store RingStore , address , configFile string , flags map [string ]string , image string ) * CortexService {
63
75
if configFile != "" {
64
76
flags ["-config.file" ] = filepath .Join (e2e .ContainerSharedDir , configFile )
65
77
}
66
78
79
+ // Configure the ingesters ring backend and the store-gateway ring backend.
80
+ ringBackendFlags := map [string ]string {
81
+ "-ring.store" : string (store ),
82
+ "-store-gateway.sharding-ring.store" : string (store ),
83
+ }
84
+
85
+ if store == RingStoreConsul {
86
+ ringBackendFlags ["-consul.hostname" ] = address
87
+ ringBackendFlags ["-store-gateway.sharding-ring.consul.hostname" ] = address
88
+ } else if store == RingStoreEtcd {
89
+ ringBackendFlags ["-etcd.endpoints" ] = address
90
+ ringBackendFlags ["-store-gateway.sharding-ring.etcd.endpoints" ] = address
91
+ }
92
+
93
+ // For backward compatibility
94
+ flags = e2e .MergeFlagsWithoutRemovingEmpty (ringBackendFlags , flags )
95
+
67
96
if image == "" {
68
97
image = GetDefaultImage ()
69
98
}
@@ -75,9 +104,6 @@ func NewQuerierWithConfigFile(name, consulAddress, configFile string, flags map[
75
104
"-target" : "querier" ,
76
105
"-log.level" : "warn" ,
77
106
"-distributor.replication-factor" : "1" ,
78
- // Ingesters ring backend.
79
- "-ring.store" : "consul" ,
80
- "-consul.hostname" : consulAddress ,
81
107
// Query-frontend worker.
82
108
"-querier.frontend-client.backoff-min-period" : "100ms" ,
83
109
"-querier.frontend-client.backoff-max-period" : "100ms" ,
@@ -87,8 +113,6 @@ func NewQuerierWithConfigFile(name, consulAddress, configFile string, flags map[
87
113
"-querier.dns-lookup-period" : "1s" ,
88
114
// Store-gateway ring backend.
89
115
"-store-gateway.sharding-enabled" : "true" ,
90
- "-store-gateway.sharding-ring.store" : "consul" ,
91
- "-store-gateway.sharding-ring.consul.hostname" : consulAddress ,
92
116
"-store-gateway.sharding-ring.replication-factor" : "1" ,
93
117
}, flags ))... ),
94
118
e2e .NewHTTPReadinessProbe (httpPort , "/ready" , 200 , 299 ),
@@ -97,15 +121,23 @@ func NewQuerierWithConfigFile(name, consulAddress, configFile string, flags map[
97
121
)
98
122
}
99
123
100
- func NewStoreGateway (name string , consulAddress string , flags map [string ]string , image string ) * CortexService {
101
- return NewStoreGatewayWithConfigFile (name , consulAddress , "" , flags , image )
124
+ func NewStoreGateway (name string , store RingStore , address string , flags map [string ]string , image string ) * CortexService {
125
+ return NewStoreGatewayWithConfigFile (name , store , address , "" , flags , image )
102
126
}
103
127
104
- func NewStoreGatewayWithConfigFile (name , consulAddress , configFile string , flags map [string ]string , image string ) * CortexService {
128
+ func NewStoreGatewayWithConfigFile (name string , store RingStore , address string , configFile string , flags map [string ]string , image string ) * CortexService {
105
129
if configFile != "" {
106
130
flags ["-config.file" ] = filepath .Join (e2e .ContainerSharedDir , configFile )
107
131
}
108
132
133
+ if store == RingStoreConsul {
134
+ flags ["-consul.hostname" ] = address
135
+ flags ["-store-gateway.sharding-ring.consul.hostname" ] = address
136
+ } else if store == RingStoreEtcd {
137
+ flags ["-etcd.endpoints" ] = address
138
+ flags ["-store-gateway.sharding-ring.etcd.endpoints" ] = address
139
+ }
140
+
109
141
if image == "" {
110
142
image = GetDefaultImage ()
111
143
}
@@ -118,8 +150,7 @@ func NewStoreGatewayWithConfigFile(name, consulAddress, configFile string, flags
118
150
"-log.level" : "warn" ,
119
151
// Store-gateway ring backend.
120
152
"-store-gateway.sharding-enabled" : "true" ,
121
- "-store-gateway.sharding-ring.store" : "consul" ,
122
- "-store-gateway.sharding-ring.consul.hostname" : consulAddress ,
153
+ "-store-gateway.sharding-ring.store" : string (store ),
123
154
"-store-gateway.sharding-ring.replication-factor" : "1" ,
124
155
// Startup quickly.
125
156
"-store-gateway.sharding-ring.wait-stability-min-duration" : "0" ,
@@ -131,14 +162,23 @@ func NewStoreGatewayWithConfigFile(name, consulAddress, configFile string, flags
131
162
)
132
163
}
133
164
134
- func NewIngester (name string , consulAddress string , flags map [string ]string , image string ) * CortexService {
135
- return NewIngesterWithConfigFile (name , consulAddress , "" , flags , image )
165
+ func NewIngester (name string , store RingStore , address string , flags map [string ]string , image string ) * CortexService {
166
+ return NewIngesterWithConfigFile (name , store , address , "" , flags , image )
136
167
}
137
168
138
- func NewIngesterWithConfigFile (name , consulAddress , configFile string , flags map [string ]string , image string ) * CortexService {
169
+ func NewIngesterWithConfigFile (name string , store RingStore , address , configFile string , flags map [string ]string , image string ) * CortexService {
139
170
if configFile != "" {
140
171
flags ["-config.file" ] = filepath .Join (e2e .ContainerSharedDir , configFile )
141
172
}
173
+
174
+ // Configure the ingesters ring backend
175
+ flags ["-ring.store" ] = string (store )
176
+ if store == RingStoreConsul {
177
+ flags ["-consul.hostname" ] = address
178
+ } else if store == RingStoreEtcd {
179
+ flags ["-etcd.endpoints" ] = address
180
+ }
181
+
142
182
if image == "" {
143
183
image = GetDefaultImage ()
144
184
}
@@ -155,9 +195,6 @@ func NewIngesterWithConfigFile(name, consulAddress, configFile string, flags map
155
195
"-ingester.concurrent-flushes" : "10" ,
156
196
"-ingester.max-transfer-retries" : "10" ,
157
197
"-ingester.num-tokens" : "512" ,
158
- // Configure the ingesters ring backend
159
- "-ring.store" : "consul" ,
160
- "-consul.hostname" : consulAddress ,
161
198
}, flags ))... ),
162
199
e2e .NewHTTPReadinessProbe (httpPort , "/ready" , 200 , 299 ),
163
200
httpPort ,
0 commit comments