Skip to content
Merged
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
26 changes: 14 additions & 12 deletions backend/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/base64"
"fmt"
"net"
nethttp "net/http"
"sync"

"k8s.io/klog/v2"
Expand Down Expand Up @@ -92,15 +93,21 @@ func NewServer(ctx context.Context, c *Config) (*Server, error) {
return nil, fmt.Errorf("error setting up Kubernetes Manager: %w", err)
}

// Always create the web server for health check endpoints
s.WebServer, err = http.NewServer(c.Options.Serve)
if err != nil {
return nil, fmt.Errorf("error setting up HTTP Server: %w", err)
}

// Register health check endpoint
s.WebServer.Router.HandleFunc("/healthz", func(w nethttp.ResponseWriter, r *nethttp.Request) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjudeikis-bot after this merged we will have /api/healthz and /healthz`. Create a follow-up issue for this to merge, test and see if we can squash them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created follow-up issue: #507 — will track consolidating the duplicate /api/healthz and /healthz endpoints after this merges.

w.WriteHeader(nethttp.StatusOK)
w.Write([]byte("ok")) //nolint:errcheck
}).Methods("GET")

if c.Options.FrontendDisabled {
logger.Info("Frontend is disabled; running in backend only mode")
} else {
var err error
s.WebServer, err = http.NewServer(c.Options.Serve)
if err != nil {
return nil, fmt.Errorf("error setting up HTTP Server: %w", err)
}

// setup oidc backend
callback := c.Options.OIDC.CallbackURL
if callback == "" {
Expand Down Expand Up @@ -385,12 +392,7 @@ func (s *Server) Run(ctx context.Context) error {
}
}()

if !s.Config.Options.FrontendDisabled {
return s.WebServer.Start(ctx)
}
logger.Info("Frontend is disabled; skipping web server start")
<-ctx.Done()
return nil
return s.WebServer.Start(ctx)
}

func (s *Server) seedCluster(ctx context.Context) error {
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/framework/dex.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ func StartDex(t testing.TB) {
}

//nolint:gosec // test helper intentionally allows overriding dex binary/config via environment for local e2e runs.
// Use context.Background() instead of t.Context() because dexOnce.Do
// ties the process to the first test that calls StartDex. If we used
// t.Context(), Dex would be killed when that test finishes, but
// dexOnce prevents restarting it for subsequent tests.
// The Dex process will be cleaned up when the test binary exits.
dexCmd := exec.CommandContext(
t.Context(),
context.Background(),
dexBinary,
"serve",
dexConfig,
Expand Down
Loading