Restore info metrics (#252)

This commit is contained in:
Travis Groth 2019-08-03 12:58:21 -04:00 committed by GitHub
parent 5e3eb69dca
commit 790619ef01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 2 deletions

View file

@ -60,10 +60,10 @@ func (a *Authorize) ValidIdentity(route string, identity *Identity) bool {
// UpdateOptions updates internal structures based on config.Options
func (a *Authorize) UpdateOptions(o config.Options) error {
log.Info().Msg("authorize: updating options")
if a == nil {
return nil
}
log.Info().Msg("authorize: updating options")
a.identityAccess = NewIdentityWhitelist(o.Policies, o.Administrators)
return nil
}

View file

@ -166,6 +166,8 @@ func setupMetrics(opt *config.Options) {
if handler, err := metrics.PrometheusHandler(); err != nil {
log.Error().Err(err).Msg("cmd/pomerium: couldn't start metrics server")
} else {
metrics.SetBuildInfo(opt.Services)
metrics.RegisterInfoMetrics()
serverOpts := &httputil.ServerOptions{Addr: opt.MetricsAddr}
srv := httputil.NewHTTPServer(serverOpts, handler)
go httputil.Shutdown(srv)

View file

@ -384,6 +384,7 @@ func HandleConfigUpdate(configFile string, opt *Options, services []OptionsUpdat
newOpt, err := ParseOptions(configFile)
if err != nil {
log.Error().Err(err).Msg("config: could not reload configuration")
metrics.SetConfigInfo(opt.Services, false, "")
return opt
}
optChecksum := opt.Checksum()
@ -396,11 +397,17 @@ func HandleConfigUpdate(configFile string, opt *Options, services []OptionsUpdat
return opt
}
errored := false
for _, service := range services {
if err := service.UpdateOptions(*newOpt); err != nil {
log.Error().Err(err).Msg("internal/config: could not update options")
errored = true
metrics.SetConfigInfo(opt.Services, false, "")
}
}
if !errored {
metrics.SetConfigInfo(newOpt.Services, true, newOptChecksum)
}
return newOpt
}

View file

@ -37,5 +37,7 @@ var (
GRPCServerViews,
HTTPServerViews,
GRPCClientViews,
GRPCServerViews}
GRPCServerViews,
InfoViews,
}
)

View file

@ -324,5 +324,6 @@ func (p *Proxy) UpdateOptions(o config.Options) error {
if p == nil {
return nil
}
log.Info().Msg("proxy: updating options")
return p.UpdatePolicies(&o)
}