From 8ca73e2079d63cdd3c19b1700a424ac0331f6e05 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, now the check for the default name takes place directly in the prepareVHSNamespaces function based on previously read default names. Signed-off-by: Roman Loginov --- cmd/s3-gw/app.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/s3-gw/app.go b/cmd/s3-gw/app.go index 96ad889..45685af 100644 --- a/cmd/s3-gw/app.go +++ b/cmd/s3-gw/app.go @@ -239,6 +239,7 @@ func newAppSettings(log *Logger, v *viper.Viper) *appSettings { func (s *appSettings) update(v *viper.Viper, log *zap.Logger) { namespaceHeader := v.GetString(cfgResolveNamespaceHeader) nsConfig, defaultNamespaces := fetchNamespacesConfig(log, v) + vhsNamespacesEnabled := s.prepareVHSNamespaces(v, log, defaultNamespaces) defaultXMLNS := v.GetBool(cfgKludgeUseDefaultXMLNS) bypassContentEncodingInChunks := v.GetBool(cfgKludgeBypassContentEncodingCheckInChunks) clientCut := v.GetBool(cfgClientCut) @@ -253,7 +254,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) @@ -290,11 +290,14 @@ func (s *appSettings) update(v *viper.Viper, log *zap.Logger) { s.vhsNamespacesEnabled = vhsNamespacesEnabled } -func (s *appSettings) prepareVHSNamespaces(v *viper.Viper, log *zap.Logger) map[string]bool { +func (s *appSettings) prepareVHSNamespaces(v *viper.Viper, log *zap.Logger, defaultNamespaces []string) map[string]bool { nsMap := fetchVHSNamespaces(v, log) vhsNamespaces := make(map[string]bool, len(nsMap)) for ns, flag := range nsMap { - vhsNamespaces[s.ResolveNamespaceAlias(ns)] = flag + if slices.Contains(defaultNamespaces, ns) { + ns = defaultNamespace + } + vhsNamespaces[ns] = flag } return vhsNamespaces