Skip to content

Commit

Permalink
Add the missing health check
Browse files Browse the repository at this point in the history
  • Loading branch information
airycanon committed Dec 5, 2024
1 parent 3075ebb commit a56348f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/adapter/v2/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,14 @@ func ConfiguratorOptionsFromContext(ctx context.Context) []ConfiguratorOption {
}
return value.([]ConfiguratorOption)
}

type healthProbesDisabledKey struct{}

// WithHealthProbesDisabled signals to MainWithContext that it should disable default probes (readiness and liveness).
func WithHealthProbesDisabled(ctx context.Context) context.Context {
return context.WithValue(ctx, healthProbesDisabledKey{}, struct{}{})
}

func HealthProbesDisabled(ctx context.Context) bool {
return ctx.Value(healthProbesDisabledKey{}) != nil
}
8 changes: 8 additions & 0 deletions pkg/adapter/v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ func MainWithInformers(ctx context.Context, component string, env EnvConfigAcces
}()
}

if !HealthProbesDisabled(ctx) {
wg.Add(1)
go func() {
defer wg.Done()
injection.ServeHealthProbes(ctx, injection.HealthCheckDefaultPort)
}()
}

// Finally start the adapter (blocking)
if err := adapter.Start(ctx); err != nil {
logger.Fatalw("Start returned an error", zap.Error(err))
Expand Down

0 comments on commit a56348f

Please sign in to comment.