Skip to content

Commit

Permalink
main.go: controller generate gRPC endpoints
Browse files Browse the repository at this point in the history
This commit updates the controller to generate gRPC endpoints rather
than HTTP endpoints, following
thanos-io/thanos#1970.

Signed-off-by: Lucas Servén Marín <[email protected]>
  • Loading branch information
squat committed Jan 13, 2020
1 parent 47c08cc commit 65ab835
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,14 @@ func (c *controller) populate(hashrings []receive.HashringConfig, statefulsets m
var endpoints []string
for i := 0; i < int(*sts.Spec.Replicas); i++ {
endpoints = append(endpoints,
fmt.Sprintf("%s://%s-%d.%s.%s.svc.%s:%d/%s",
c.options.scheme,
fmt.Sprintf("%s-%d.%s.%s.svc.%s:%d",
sts.Name,
i,
sts.Spec.ServiceName,
c.options.namespace,
c.options.clusterDomain,
c.options.port,
strings.TrimPrefix(c.options.path, "/")),
),
)
}
hashrings[i].Endpoints = endpoints
Expand Down
32 changes: 16 additions & 16 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ func TestController(t *testing.T) {
Hashring: "hashring0",
Tenants: []string{"foo", "bar"},
Endpoints: []string{
"http://thanos-receive-hashring0-0.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"http://thanos-receive-hashring0-1.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"http://thanos-receive-hashring0-2.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"thanos-receive-hashring0-0.h0.namespace.svc.cluster.local:19291",
"thanos-receive-hashring0-1.h0.namespace.svc.cluster.local:19291",
"thanos-receive-hashring0-2.h0.namespace.svc.cluster.local:19291",
},
}},
},
Expand Down Expand Up @@ -128,9 +128,9 @@ func TestController(t *testing.T) {
Hashring: "hashring0",
Tenants: []string{"foo", "bar"},
Endpoints: []string{
"http://hashring0-0.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"http://hashring0-1.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"http://hashring0-2.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"hashring0-0.h0.namespace.svc.cluster.local:19291",
"hashring0-1.h0.namespace.svc.cluster.local:19291",
"hashring0-2.h0.namespace.svc.cluster.local:19291",
},
}},
},
Expand Down Expand Up @@ -174,15 +174,15 @@ func TestController(t *testing.T) {
Hashring: "hashring0",
Tenants: []string{"foo", "bar"},
Endpoints: []string{
"http://hashring0-0.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"http://hashring0-1.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"http://hashring0-2.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"hashring0-0.h0.namespace.svc.cluster.local:19291",
"hashring0-1.h0.namespace.svc.cluster.local:19291",
"hashring0-2.h0.namespace.svc.cluster.local:19291",
},
}, {
Hashring: "hashring1",
Endpoints: []string{
"http://hashring1-0.h1.namespace.svc.cluster.local:19291/api/v1/receive",
"http://hashring1-1.h1.namespace.svc.cluster.local:19291/api/v1/receive",
"hashring1-0.h1.namespace.svc.cluster.local:19291",
"hashring1-1.h1.namespace.svc.cluster.local:19291",
},
}},
},
Expand All @@ -200,7 +200,7 @@ func TestController(t *testing.T) {
configMapName: "original",
configMapGeneratedName: "generated",
namespace: "namespace",
path: "/api/v1/receive",
path: "",
port: 19291,
scheme: "http",
}
Expand Down Expand Up @@ -234,9 +234,9 @@ func TestControllerConfigmapUpdate(t *testing.T) {
Hashring: "hashring0",
Tenants: []string{"foo", "bar"},
Endpoints: []string{
"http://thanos-receive-hashring0-0.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"http://thanos-receive-hashring0-1.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"http://thanos-receive-hashring0-2.h0.namespace.svc.cluster.local:19291/api/v1/receive",
"thanos-receive-hashring0-0.h0.namespace.svc.cluster.local:19291",
"thanos-receive-hashring0-1.h0.namespace.svc.cluster.local:19291",
"thanos-receive-hashring0-2.h0.namespace.svc.cluster.local:19291",
},
}}
intendedLabels := map[string]string{
Expand Down Expand Up @@ -278,7 +278,7 @@ func TestControllerConfigmapUpdate(t *testing.T) {
configMapName: "original",
configMapGeneratedName: "generated",
namespace: "namespace",
path: "/api/v1/receive",
path: "",
port: 19291,
scheme: "http",
}
Expand Down

0 comments on commit 65ab835

Please sign in to comment.