From 59f98a25032c9d83be80f72c080809fe13b0a485 Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Fri, 1 Mar 2024 21:33:51 +0000 Subject: [PATCH] Don't register embedded registry address as an upstream registry Signed-off-by: Brad Davidson --- pkg/spegel/spegel.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/spegel/spegel.go b/pkg/spegel/spegel.go index ae4a81a7fdfd..caa563db75a4 100644 --- a/pkg/spegel/spegel.go +++ b/pkg/spegel/spegel.go @@ -110,6 +110,7 @@ func init() { // Start starts the embedded p2p router, and binds the registry API to an existing HTTP router. func (c *Config) Start(ctx context.Context, nodeConfig *config.Node) error { + localAddr := net.JoinHostPort(c.InternalAddress, c.RegistryPort) // distribute images for all configured mirrors. there doesn't need to be a // configured endpoint, just having a key for the registry will do. urls := []url.URL{} @@ -117,7 +118,7 @@ func (c *Config) Start(ctx context.Context, nodeConfig *config.Node) error { for host := range nodeConfig.AgentConfig.Registry.Mirrors { if u, err := url.Parse("https://" + host); err != nil { logrus.Errorf("Distributed registry mirror skipping invalid registry: %s", host) - } else { + } else if u.Host != localAddr { urls = append(urls, *u) registries = append(registries, host) } @@ -209,7 +210,6 @@ func (c *Config) Start(ctx context.Context, nodeConfig *config.Node) error { if err != nil { return errors.Wrap(err, "failed to read server CA") } - localAddr := net.JoinHostPort(c.InternalAddress, c.RegistryPort) client := clientaccess.GetHTTPClient(caCert, c.ClientCertFile, c.ClientKeyFile) metrics.Register() registryOpts := []registry.Option{