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

server: open most HTTP endpoints later #19598

Merged
merged 1 commit into from
Oct 28, 2017
Merged
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
30 changes: 16 additions & 14 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,14 @@ func (s *Server) Start(ctx context.Context) error {
// TODO(marc): when cookie-based authentication exists, apply it to all web
// endpoints.
s.mux.Handle(debugEndpoint, authorizedHandler(http.HandlerFunc(handleDebug)))
// Also throw the landing page in there. It won't work well, but it's better than a 404.
// The remaining endpoints will be opened late, when we're sure that the subsystems they
// talk to are functional.
s.mux.Handle("/", http.FileServer(&assetfs.AssetFS{
Asset: ui.Asset,
AssetDir: ui.AssetDir,
AssetInfo: ui.AssetInfo,
}))

// Filter the gossip bootstrap resolvers based on the listen and
// advertise addresses.
Expand Down Expand Up @@ -1014,20 +1022,6 @@ If problems persist, please see ` + base.DocsURL("cluster-setup-troubleshooting.
}
}

s.mux.Handle("/", http.FileServer(&assetfs.AssetFS{
Asset: ui.Asset,
AssetDir: ui.AssetDir,
AssetInfo: ui.AssetInfo,
}))

s.mux.Handle(adminPrefix, authHandler)
s.mux.Handle(ts.URLPrefix, authHandler)
s.mux.Handle(statusPrefix, authHandler)
s.mux.Handle(authPrefix, gwMux)
s.mux.Handle("/health", gwMux)
s.mux.Handle(statusVars, http.HandlerFunc(s.status.handleVars))
log.Event(ctx, "added http endpoints")

// Now that we have a monotonic HLC wrt previous incarnations of the process,
// init all the replicas. At this point *some* store has been bootstrapped or
// we're joining an existing cluster for the first time.
Expand Down Expand Up @@ -1112,6 +1106,14 @@ If problems persist, please see ` + base.DocsURL("cluster-setup-troubleshooting.

atomic.StoreInt32(&s.serveNonGossip, 1)

s.mux.Handle(adminPrefix, authHandler)
s.mux.Handle(ts.URLPrefix, authHandler)
s.mux.Handle(statusPrefix, authHandler)
s.mux.Handle(authPrefix, gwMux)
s.mux.Handle("/health", gwMux)
s.mux.Handle(statusVars, http.HandlerFunc(s.status.handleVars))
log.Event(ctx, "added http endpoints")

log.Infof(ctx, "starting %s server at %s", s.cfg.HTTPRequestScheme(), unresolvedHTTPAddr)
log.Infof(ctx, "starting grpc/postgres server at %s", unresolvedListenAddr)
log.Infof(ctx, "advertising CockroachDB node at %s", unresolvedAdvertAddr)
Expand Down