From 57dc2e4bbffeb764afc5f339758e993fcb35aa8f Mon Sep 17 00:00:00 2001 From: Roman Loginov Date: Mon, 16 Sep 2024 13:43:07 +0300 Subject: [PATCH] [#493] Fix of receiving VHS namespaces map In the process of forming a map with namespaces for which VHS is enabled, we resolve the alias of the namespace. The problem is that to resolve, we need default namespace names, which in turn do not have time to decide by this time. Therefore, the receipt of a card with VHS namespaces must be postponed after reading the default names for the namespace. Signed-off-by: Roman Loginov --- cmd/s3-gw/app.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/s3-gw/app.go b/cmd/s3-gw/app.go index 96ad889..5e19f01 100644 --- a/cmd/s3-gw/app.go +++ b/cmd/s3-gw/app.go @@ -253,7 +253,6 @@ func (s *appSettings) update(v *viper.Viper, log *zap.Logger) { vhsEnabled := v.GetBool(cfgVHSEnabled) vhsHeader := v.GetString(cfgVHSHeader) servernameHeader := v.GetString(cfgServernameHeader) - vhsNamespacesEnabled := s.prepareVHSNamespaces(v, log) httpLoggingEnabled := v.GetBool(cfgHTTPLoggingEnabled) httpLoggingMaxBody := v.GetInt64(cfgHTTPLoggingMaxBody) httpLoggingMaxLogSize := v.GetInt(cfgHTTPLoggingMaxLogSize) @@ -261,7 +260,6 @@ func (s *appSettings) update(v *viper.Viper, log *zap.Logger) { httpLoggingUseGzip := v.GetBool(cfgHTTPLoggingGzip) s.mu.Lock() - defer s.mu.Unlock() s.httpLogging.Enabled = httpLoggingEnabled s.httpLogging.MaxBody = httpLoggingMaxBody @@ -287,17 +285,22 @@ func (s *appSettings) update(v *viper.Viper, log *zap.Logger) { s.vhsEnabled = vhsEnabled s.vhsHeader = vhsHeader s.servernameHeader = servernameHeader - s.vhsNamespacesEnabled = vhsNamespacesEnabled + + s.mu.Unlock() + + s.prepareVHSNamespaces(v, log) } -func (s *appSettings) prepareVHSNamespaces(v *viper.Viper, log *zap.Logger) map[string]bool { +func (s *appSettings) prepareVHSNamespaces(v *viper.Viper, log *zap.Logger) { nsMap := fetchVHSNamespaces(v, log) vhsNamespaces := make(map[string]bool, len(nsMap)) for ns, flag := range nsMap { vhsNamespaces[s.ResolveNamespaceAlias(ns)] = flag } - return vhsNamespaces + s.mu.Lock() + s.vhsNamespacesEnabled = vhsNamespaces + s.mu.Unlock() } func (s *appSettings) Domains() []string {