mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-27 23:18:13 +02:00
core/config: remove version (#4653)
* core/config: remove version * lint * fix
This commit is contained in:
parent
6511440c2f
commit
53573dc046
9 changed files with 761 additions and 800 deletions
|
@ -27,7 +27,6 @@ type Config struct {
|
|||
Options *Options
|
||||
AutoCertificates []tls.Certificate
|
||||
EnvoyVersion string
|
||||
Version int64
|
||||
|
||||
// DerivedCertificates are TLS certificates derived from the shared secret
|
||||
DerivedCertificates []tls.Certificate
|
||||
|
@ -63,7 +62,6 @@ func (cfg *Config) Clone() *Config {
|
|||
_ = copy(endpoints, cfg.MetricsScrapeEndpoints)
|
||||
|
||||
return &Config{
|
||||
Version: cfg.Version,
|
||||
Options: newOptions,
|
||||
AutoCertificates: cfg.AutoCertificates,
|
||||
EnvoyVersion: cfg.EnvoyVersion,
|
||||
|
|
|
@ -114,7 +114,6 @@ func NewFileOrEnvironmentSource(
|
|||
cfg := &Config{
|
||||
Options: options,
|
||||
EnvoyVersion: envoyVersion,
|
||||
Version: 1,
|
||||
}
|
||||
|
||||
ports, err := netutil.AllocatePorts(6)
|
||||
|
@ -152,7 +151,6 @@ func (src *FileOrEnvironmentSource) check(ctx context.Context) {
|
|||
options, err := newOptionsFromConfig(src.configFile)
|
||||
if err == nil {
|
||||
cfg = cfg.Clone()
|
||||
cfg.Version++
|
||||
cfg.Options = options
|
||||
metrics.SetConfigInfo(ctx, cfg.Options.Services, "local", cfg.Checksum(), true)
|
||||
} else {
|
||||
|
@ -162,7 +160,7 @@ func (src *FileOrEnvironmentSource) check(ctx context.Context) {
|
|||
src.config = cfg
|
||||
src.mu.Unlock()
|
||||
|
||||
log.Info(ctx).Int64("config-version", cfg.Version).Msg("config: loaded configuration")
|
||||
log.Info(ctx).Msg("config: loaded configuration")
|
||||
|
||||
src.Trigger(ctx, cfg)
|
||||
}
|
||||
|
|
|
@ -255,7 +255,6 @@ func (srv *Server) Run(ctx context.Context) error {
|
|||
err := srv.update(ctx, cfg)
|
||||
if err != nil {
|
||||
log.Error(ctx).Err(err).
|
||||
Int64("config-version", cfg.Version).
|
||||
Msg("controlplane: error updating server with new config")
|
||||
}
|
||||
}
|
||||
|
@ -303,7 +302,7 @@ func (srv *Server) update(ctx context.Context, cfg *config.Config) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
srv.xdsmgr.Update(ctx, cfg.Version, res)
|
||||
srv.xdsmgr.Update(ctx, res)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ func (srv *Server) buildDiscoveryResources(ctx context.Context) (map[string][]*e
|
|||
|
||||
cfg := srv.currentConfig.Load()
|
||||
|
||||
log.Info(ctx).Int64("config-version", cfg.Version).Msg("controlplane: building discovery resources")
|
||||
log.Info(ctx).Msg("controlplane: building discovery resources")
|
||||
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
||||
|
||||
|
@ -84,7 +84,6 @@ func (srv *Server) buildDiscoveryResources(ctx context.Context) (map[string][]*e
|
|||
}
|
||||
|
||||
log.Info(ctx).
|
||||
Int64("config-version", cfg.Version).
|
||||
Int("cluster-count", len(clusterResources)).
|
||||
Int("listener-count", len(listenerResources)).
|
||||
Int("route-configuration-count", len(routeConfigurationResources)).
|
||||
|
|
|
@ -3,9 +3,6 @@ package xdsmgr
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
envoy_service_discovery_v3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
|
||||
|
@ -40,7 +37,7 @@ func NewManager(resources map[string][]*envoy_service_discovery_v3.Resource) *Ma
|
|||
return &Manager{
|
||||
signal: signal.New(),
|
||||
|
||||
nonce: toNonce(0),
|
||||
nonce: uuid.New().String(),
|
||||
resources: resources,
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +109,6 @@ func (mgr *Manager) DeltaAggregatedResources(
|
|||
case req.GetErrorDetail() != nil:
|
||||
log.Info(ctx).
|
||||
Any("error-detail", req.GetErrorDetail()).
|
||||
Int64("config-version", versionFromNonce(req.GetResponseNonce())).
|
||||
Msg("xdsmgr: nack")
|
||||
// a NACK
|
||||
// - set the client resource versions to the current resource versions
|
||||
|
@ -122,7 +118,6 @@ func (mgr *Manager) DeltaAggregatedResources(
|
|||
}
|
||||
case req.GetResponseNonce() == mgr.nonce:
|
||||
log.Info(ctx).
|
||||
Int64("config-version", versionFromNonce(req.GetResponseNonce())).
|
||||
Msg("xdsmgr: ack")
|
||||
// an ACK for the last response
|
||||
// - set the client resource versions to the current resource versions
|
||||
|
@ -133,7 +128,6 @@ func (mgr *Manager) DeltaAggregatedResources(
|
|||
default:
|
||||
// an ACK for a response that's not the last response
|
||||
log.Info(ctx).
|
||||
Int64("config-version", versionFromNonce(req.GetResponseNonce())).
|
||||
Msg("xdsmgr: ack")
|
||||
}
|
||||
|
||||
|
@ -215,7 +209,6 @@ func (mgr *Manager) DeltaAggregatedResources(
|
|||
return ctx.Err()
|
||||
case res := <-outgoing:
|
||||
log.Info(ctx).
|
||||
Int64("config-version", versionFromNonce(res.GetNonce())).
|
||||
Int("resource-count", len(res.GetResources())).
|
||||
Int("removed-resource-count", len(res.GetRemovedResources())).
|
||||
Msg("xdsmgr: sending resources")
|
||||
|
@ -238,8 +231,8 @@ func (mgr *Manager) StreamAggregatedResources(
|
|||
|
||||
// Update updates the state of resources. If any changes are made they will be pushed to any listening
|
||||
// streams. For each TypeURL the list of resources should be the complete list of resources.
|
||||
func (mgr *Manager) Update(ctx context.Context, version int64, resources map[string][]*envoy_service_discovery_v3.Resource) {
|
||||
nonce := toNonce(version)
|
||||
func (mgr *Manager) Update(ctx context.Context, resources map[string][]*envoy_service_discovery_v3.Resource) {
|
||||
nonce := uuid.New().String()
|
||||
|
||||
mgr.mu.Lock()
|
||||
mgr.nonce = nonce
|
||||
|
@ -248,15 +241,3 @@ func (mgr *Manager) Update(ctx context.Context, version int64, resources map[str
|
|||
|
||||
mgr.signal.Broadcast(ctx)
|
||||
}
|
||||
|
||||
func toNonce(version int64) string {
|
||||
return fmt.Sprintf("%d/%s", version, uuid.New().String())
|
||||
}
|
||||
|
||||
// versionFromNonce parses the version out of the nonce. A missing or invalid version will be returned as 0.
|
||||
func versionFromNonce(nonce string) (version int64) {
|
||||
if idx := strings.Index(nonce, "/"); idx > 0 {
|
||||
version, _ = strconv.ParseInt(nonce[:idx], 10, 64)
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ func TestManager(t *testing.T) {
|
|||
}, msg.GetResources())
|
||||
ack(msg.Nonce)
|
||||
|
||||
mgr.Update(ctx, 1, map[string][]*envoy_service_discovery_v3.Resource{
|
||||
mgr.Update(ctx, map[string][]*envoy_service_discovery_v3.Resource{
|
||||
typeURL: {{Name: "r1", Version: "2"}},
|
||||
})
|
||||
|
||||
|
@ -105,7 +105,7 @@ func TestManager(t *testing.T) {
|
|||
}, msg.GetResources())
|
||||
ack(msg.Nonce)
|
||||
|
||||
mgr.Update(ctx, 1, map[string][]*envoy_service_discovery_v3.Resource{
|
||||
mgr.Update(ctx, map[string][]*envoy_service_discovery_v3.Resource{
|
||||
typeURL: nil,
|
||||
})
|
||||
|
||||
|
|
|
@ -109,9 +109,6 @@ func (src *ConfigSource) rebuild(ctx context.Context, firstTime firstTime) {
|
|||
// add all the config policies to the list
|
||||
for _, id := range ids {
|
||||
cfgpb := src.dbConfigs[id]
|
||||
if cfgpb.GetVersion() > 0 {
|
||||
cfg.Version = cfgpb.GetVersion()
|
||||
}
|
||||
|
||||
cfg.Options.ApplySettings(ctx, certsIndex, cfgpb.Settings)
|
||||
var errCount uint64
|
||||
|
@ -171,7 +168,7 @@ func (src *ConfigSource) rebuild(ctx context.Context, firstTime firstTime) {
|
|||
// add the additional policies here since calling `Validate` will reset them.
|
||||
cfg.Options.AdditionalPolicies = append(cfg.Options.AdditionalPolicies, additionalPolicies...)
|
||||
|
||||
log.Info(ctx).Int64("config-version", cfg.Version).Msg("databroker: built new config")
|
||||
log.Info(ctx).Msg("databroker: built new config")
|
||||
|
||||
src.computedConfig = cfg
|
||||
if !firstTime {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,7 +12,6 @@ import "crypt/crypt.proto";
|
|||
|
||||
message Config {
|
||||
string name = 1;
|
||||
int64 version = 4;
|
||||
repeated Route routes = 2;
|
||||
Settings settings = 3;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue