Skip to content

Commit

Permalink
Add /ready endpoint to table-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
adityacs committed Mar 10, 2020
1 parent 5ae6ea7 commit 9b14726
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/loki/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,21 @@ func (t *Loki) initTableManager() error {
if err != nil {
return err
}
return services.StartAndAwaitRunning(context.Background(), t.tableManager)

if err := services.StartAndAwaitRunning(context.Background(), t.tableManager); err != nil {
return err
}

// Once the execution reaches this point, synchronous table initialization has been
// done and the table-manager is ready to serve, so we're just returning a 200.
t.server.HTTP.Path("/ready").Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
if _, err := w.Write([]byte("Ready")); err != nil {
level.Error(util.Logger).Log("msg", "error writing success message", "error", err)
}
}))

return nil
}

func (t *Loki) stopTableManager() error {
Expand Down
4 changes: 4 additions & 0 deletions production/ksonnet/loki/table-manager.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
container.new('table-manager', $._images.tableManager) +
container.withPorts($.util.defaultPorts) +
container.withArgsMixin($.util.mapToFlags($.table_manager_args)) +
container.mixin.readinessProbe.httpGet.withPath('/ready') +
container.mixin.readinessProbe.httpGet.withPort(80) +
container.mixin.readinessProbe.withInitialDelaySeconds(15) +
container.mixin.readinessProbe.withTimeoutSeconds(1) +
$.util.resourcesRequests('100m', '100Mi') +
$.util.resourcesLimits('200m', '200Mi'),

Expand Down

0 comments on commit 9b14726

Please sign in to comment.