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

feat: tms readiness check bypass implementation #1926

Closed
Closed
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
3 changes: 3 additions & 0 deletions docs/clients/promtail/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ The `server_config` block configures Promtail's behavior as an HTTP server:

# Base path to server all API routes from (e.g., /v1/).
[http_path_prefix: <string>]

# Target managers check flag for promtail readiness, if set to false the check is ignored
[health_check_target: <bool> | default = true]
```

## client_config
Expand Down
24 changes: 16 additions & 8 deletions pkg/promtail/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ var (
// Server embed weaveworks server with static file and templating capability
type Server struct {
*serverww.Server
tms *targets.TargetManagers
externalURL *url.URL
tms *targets.TargetManagers
externalURL *url.URL
healthCheckTarget bool
}

// Config extends weaveworks server config
type Config struct {
serverww.Config `yaml:",inline"`
ExternalURL string `yaml:"external_url"`
serverww.Config `yaml:",inline"`
ExternalURL string `yaml:"external_url"`
HealthCheckTarget *bool `yaml:"health_check_target"`
}

// New makes a new Server
Expand All @@ -51,10 +53,16 @@ func New(cfg Config, tms *targets.TargetManagers) (*Server, error) {
}
cfg.PathPrefix = externalURL.Path

healthCheckTargetFlag := true
if cfg.HealthCheckTarget != nil {
healthCheckTargetFlag = *cfg.HealthCheckTarget
}

serv := &Server{
Server: wws,
tms: tms,
externalURL: externalURL,
Server: wws,
tms: tms,
externalURL: externalURL,
healthCheckTarget: healthCheckTargetFlag,
}

serv.HTTP.Path("/").Handler(http.RedirectHandler(path.Join(serv.externalURL.Path, "/targets"), 303))
Expand Down Expand Up @@ -169,7 +177,7 @@ func (s *Server) targets(rw http.ResponseWriter, req *http.Request) {

// ready serves the ready endpoint
func (s *Server) ready(rw http.ResponseWriter, _ *http.Request) {
if !s.tms.Ready() {
if s.healthCheckTarget && !s.tms.Ready() {
http.Error(rw, readinessProbeFailure, http.StatusInternalServerError)
return
}
Expand Down