diff --git a/go/daemon/main.go b/go/daemon/main.go index e3469c9336..e220297a88 100644 --- a/go/daemon/main.go +++ b/go/daemon/main.go @@ -219,9 +219,9 @@ func realMain(ctx context.Context) error { "info": service.NewInfoStatusPage(), "config": service.NewConfigStatusPage(globalCfg), "log/level": service.NewLogLevelStatusPage(), - "topology": service.StatusPage{Handler: itopo.TopologyHandler}, + "topology": service.NewTopologyStatusPage(), "digests/config": service.NewConfigDigestStatusPage(&globalCfg), - "digests/topology": service.StatusPage{Handler: itopo.TopologyDigestHandler}, + "digests/topology": service.NewTopologyDigestStatusPage(), } if err := statusPages.Register(http.DefaultServeMux, globalCfg.General.ID); err != nil { return serrors.WrapStr("registering status pages", err) diff --git a/go/pkg/cs/BUILD.bazel b/go/pkg/cs/BUILD.bazel index 5e7a5247d2..1ef5d3b0d3 100644 --- a/go/pkg/cs/BUILD.bazel +++ b/go/pkg/cs/BUILD.bazel @@ -27,7 +27,6 @@ go_library( "//go/lib/ctrl/seg:go_default_library", "//go/lib/env:go_default_library", "//go/lib/infra:go_default_library", - "//go/lib/infra/modules/itopo:go_default_library", "//go/lib/infra/modules/seghandler:go_default_library", "//go/lib/keyconf:go_default_library", "//go/lib/log:go_default_library", diff --git a/go/pkg/cs/observability.go b/go/pkg/cs/observability.go index ed2fd81531..c319b026d7 100644 --- a/go/pkg/cs/observability.go +++ b/go/pkg/cs/observability.go @@ -28,7 +28,6 @@ import ( "github.com/scionproto/scion/go/lib/addr" "github.com/scionproto/scion/go/lib/config" "github.com/scionproto/scion/go/lib/env" - "github.com/scionproto/scion/go/lib/infra/modules/itopo" "github.com/scionproto/scion/go/lib/prom" "github.com/scionproto/scion/go/lib/scrypto" "github.com/scionproto/scion/go/lib/scrypto/cppki" @@ -240,10 +239,10 @@ func StartHTTPEndpoints( "info": service.NewInfoStatusPage(), "config": service.NewConfigStatusPage(cfg), "log/level": service.NewLogLevelStatusPage(), - "topology": service.StatusPage{Handler: itopo.TopologyHandler}, + "topology": service.NewTopologyStatusPage(), "signer": signerStatusPage(signer), "digests/config": service.NewConfigDigestStatusPage(cfg), - "digests/topology": service.StatusPage{Handler: itopo.TopologyDigestHandler}, + "digests/topology": service.NewTopologyDigestStatusPage(), "digests/policies": policyDigestsStatusPage(policyDigests), } if ca != (renewal.ChainBuilder{}) { @@ -306,7 +305,10 @@ func signerStatusPage(signer cstrust.RenewingSigner) service.StatusPage { return } } - return service.StatusPage{Handler: handler} + return service.StatusPage{ + Info: "SCION signer info", + Handler: handler, + } } func caStatusPage(signer renewal.ChainBuilder) service.StatusPage { @@ -357,7 +359,10 @@ func caStatusPage(signer renewal.ChainBuilder) service.StatusPage { return } } - return service.StatusPage{Handler: handler} + return service.StatusPage{ + Info: "CA status", + Handler: handler, + } } func policyDigestsStatusPage(digests map[string][]byte) service.StatusPage { @@ -379,5 +384,8 @@ func policyDigestsStatusPage(digests map[string][]byte) service.StatusPage { return } } - return service.StatusPage{Handler: handler} + return service.StatusPage{ + Info: "sha256 policies digest", + Handler: handler, + } } diff --git a/go/pkg/gateway/gateway.go b/go/pkg/gateway/gateway.go index 81e1db6081..5db5ad2f2c 100644 --- a/go/pkg/gateway/gateway.go +++ b/go/pkg/gateway/gateway.go @@ -588,6 +588,7 @@ func (g *Gateway) Run(ctx context.Context) error { }() logger.Debug("Session configurator started") g.HTTPEndpoints["sessionconfigurator"] = service.StatusPage{ + Info: "session configurator diagnostics", Handler: func(w http.ResponseWriter, _ *http.Request) { sessionConfigurator.DiagnosticsWrite(w) }, @@ -630,27 +631,32 @@ func (g *Gateway) Run(ctx context.Context) error { logger.Debug("Engine controller started") g.HTTPEndpoints["engine"] = service.StatusPage{ + Info: "gateway diagnostics", Handler: func(w http.ResponseWriter, _ *http.Request) { engineController.DiagnosticsWrite(w) }, } g.HTTPEndpoints["status"] = service.StatusPage{ + Info: "gateway status (remote ASes, sessions, paths)", Handler: func(w http.ResponseWriter, _ *http.Request) { engineController.Status(w) }, } g.HTTPEndpoints["diagnostics/prefixwatcher"] = service.StatusPage{ + Info: "IP prefixes incoming via SGRP", Handler: func(w http.ResponseWriter, _ *http.Request) { remoteMonitor.DiagnosticsWrite(w) }, } g.HTTPEndpoints["diagnostics/sgrp"] = service.StatusPage{ + Info: "SGRP diagnostics", Handler: g.diagnosticsSGRP(routePublisherFactory, configPublisher), } // XXX(scrye): Use an empty file here because the server often doesn't have // write access to its configuration folder. g.HTTPEndpoints["ip-routing/policy"] = service.StatusPage{ + Info: "IP routing policy (supports PUT)", Handler: routing.NewPolicyHandler( RoutingPolicyPublisherAdapter{ConfigPublisher: configPublisher}, ""), } diff --git a/go/pkg/service/BUILD.bazel b/go/pkg/service/BUILD.bazel index 4d6b8d7274..625499ebf9 100644 --- a/go/pkg/service/BUILD.bazel +++ b/go/pkg/service/BUILD.bazel @@ -8,6 +8,7 @@ go_library( deps = [ "//go/lib/config:go_default_library", "//go/lib/env:go_default_library", + "//go/lib/infra/modules/itopo:go_default_library", "//go/lib/log:go_default_library", "//go/lib/serrors:go_default_library", "//go/lib/util:go_default_library", diff --git a/go/pkg/service/statuspages.go b/go/pkg/service/statuspages.go index 2632172647..d84b2f5821 100644 --- a/go/pkg/service/statuspages.go +++ b/go/pkg/service/statuspages.go @@ -29,6 +29,7 @@ import ( "github.com/scionproto/scion/go/lib/config" "github.com/scionproto/scion/go/lib/env" + "github.com/scionproto/scion/go/lib/infra/modules/itopo" "github.com/scionproto/scion/go/lib/log" "github.com/scionproto/scion/go/lib/serrors" "github.com/scionproto/scion/go/lib/util" @@ -42,20 +43,29 @@ const mainTmpl = `

{{ .ElemId }}

+ {{ range .Pages }} - [{{ . }}]
+ {{ end }} +
[{{ .Endpoint }}]{{ .Info }}
` +type pageData struct { + Info string + Endpoint string +} + type mainData struct { ElemId string - Pages []string + Pages []pageData } // StatusPages describes a status page (HTTP endpoint exposed by the service). type StatusPage struct { + // Short description on what the endpoint is for. It will be shown on the main page. + Info string // Handler processes the HTTP request for this status page. Handler http.HandlerFunc // Special status page is one that should not be dumped via /all endpoint. @@ -75,13 +85,21 @@ func (s StatusPages) Register(serveMux *http.ServeMux, elemId string) error { if err != nil { return err } - var pages []string - for endpoint, page := range s { - pages = append(pages, endpoint) - serveMux.HandleFunc(fmt.Sprintf("/%s", endpoint), page.Handler) + var pages []pageData + for endpoint, p := range s { + pages = append(pages, pageData{ + Info: p.Info, + Endpoint: endpoint, + }) + serveMux.HandleFunc(fmt.Sprintf("/%s", endpoint), p.Handler) } - pages = append(pages, "metrics") - sort.Strings(pages) + pages = append(pages, pageData{ + Info: "prometheus metrics", + Endpoint: "metrics", + }) + sort.Slice(pages, func(x, y int) bool { + return pages[x].Endpoint < pages[y].Endpoint + }) var mainBuf bytes.Buffer if err := t.Execute(&mainBuf, mainData{ElemId: elemId, Pages: pages}); err != nil { return serrors.WrapStr("executing template", err) @@ -117,7 +135,10 @@ func NewConfigStatusPage(config interface{}) StatusPage { toml.NewEncoder(&buf).Order(toml.OrderPreserve).Encode(config) fmt.Fprint(w, buf.String()) } - return StatusPage{Handler: handler} + return StatusPage{ + Info: "configuration of the service", + Handler: handler, + } } func NewConfigDigestStatusPage(cfg config.Config) StatusPage { @@ -139,7 +160,17 @@ func NewConfigDigestStatusPage(cfg config.Config) StatusPage { return } } - return StatusPage{Handler: handler} + return StatusPage{ + Info: "sha256 digest of the configuration", + Handler: handler, + } +} + +func NewTopologyDigestStatusPage() StatusPage { + return StatusPage{ + Info: "sha256 digest of SCION topology", + Handler: itopo.TopologyDigestHandler, + } } // NewInfoStatusPage returns a page with basic info about the process. @@ -156,10 +187,23 @@ func NewInfoStatusPage() StatusPage { w.Header().Set("Content-Type", "text/plain") fmt.Fprint(w, info) } - return StatusPage{Handler: handler} + return StatusPage{ + Info: "generic info about the process", + Handler: handler, + } } // NewLogLevelStatusPage returns a page with basic info about the process. func NewLogLevelStatusPage() StatusPage { - return StatusPage{Handler: log.ConsoleLevel.ServeHTTP} + return StatusPage{ + Info: "logging level (supports PUT)", + Handler: log.ConsoleLevel.ServeHTTP, + } +} + +func NewTopologyStatusPage() StatusPage { + return StatusPage{ + Info: "SCION topology", + Handler: itopo.TopologyHandler, + } } diff --git a/go/posix-router/main.go b/go/posix-router/main.go index 3b43692ef5..865e6dac3e 100644 --- a/go/posix-router/main.go +++ b/go/posix-router/main.go @@ -130,7 +130,10 @@ func topologyHandler(topo topology.Topology) service.StatusPage { } fmt.Fprint(w, string(bytes)+"\n") } - return service.StatusPage{Handler: handler} + return service.StatusPage{ + Info: "SCION topology", + Handler: handler, + } } func topologyDigestHandler(topo topology.Topology) service.StatusPage { @@ -154,5 +157,8 @@ func topologyDigestHandler(topo topology.Topology) service.StatusPage { return } } - return service.StatusPage{Handler: handler} + return service.StatusPage{ + Info: "sha256 of SCION topology", + Handler: handler, + } }