bugfix/vhs #493

Merged
alexvanin merged 1 commit from r.loginov/frostfs-s3-gw:feature/vhs into master 2024-10-26 11:30:29 +00:00
Showing only changes of commit 8ca73e2079 - Show all commits

View file

@ -239,6 +239,7 @@ func newAppSettings(log *Logger, v *viper.Viper) *appSettings {
func (s *appSettings) update(v *viper.Viper, log *zap.Logger) { func (s *appSettings) update(v *viper.Viper, log *zap.Logger) {
namespaceHeader := v.GetString(cfgResolveNamespaceHeader) namespaceHeader := v.GetString(cfgResolveNamespaceHeader)
nsConfig, defaultNamespaces := fetchNamespacesConfig(log, v) nsConfig, defaultNamespaces := fetchNamespacesConfig(log, v)
vhsNamespacesEnabled := s.prepareVHSNamespaces(v, log, defaultNamespaces)
defaultXMLNS := v.GetBool(cfgKludgeUseDefaultXMLNS) defaultXMLNS := v.GetBool(cfgKludgeUseDefaultXMLNS)
bypassContentEncodingInChunks := v.GetBool(cfgKludgeBypassContentEncodingCheckInChunks) bypassContentEncodingInChunks := v.GetBool(cfgKludgeBypassContentEncodingCheckInChunks)
clientCut := v.GetBool(cfgClientCut) clientCut := v.GetBool(cfgClientCut)
@ -253,7 +254,6 @@ func (s *appSettings) update(v *viper.Viper, log *zap.Logger) {
vhsEnabled := v.GetBool(cfgVHSEnabled) vhsEnabled := v.GetBool(cfgVHSEnabled)
vhsHeader := v.GetString(cfgVHSHeader) vhsHeader := v.GetString(cfgVHSHeader)
servernameHeader := v.GetString(cfgServernameHeader) servernameHeader := v.GetString(cfgServernameHeader)
vhsNamespacesEnabled := s.prepareVHSNamespaces(v, log)
httpLoggingEnabled := v.GetBool(cfgHTTPLoggingEnabled) httpLoggingEnabled := v.GetBool(cfgHTTPLoggingEnabled)
httpLoggingMaxBody := v.GetInt64(cfgHTTPLoggingMaxBody) httpLoggingMaxBody := v.GetInt64(cfgHTTPLoggingMaxBody)
httpLoggingMaxLogSize := v.GetInt(cfgHTTPLoggingMaxLogSize) httpLoggingMaxLogSize := v.GetInt(cfgHTTPLoggingMaxLogSize)
@ -290,11 +290,14 @@ func (s *appSettings) update(v *viper.Viper, log *zap.Logger) {
s.vhsNamespacesEnabled = vhsNamespacesEnabled 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) nsMap := fetchVHSNamespaces(v, log)
vhsNamespaces := make(map[string]bool, len(nsMap)) vhsNamespaces := make(map[string]bool, len(nsMap))
for ns, flag := range nsMap { for ns, flag := range nsMap {
vhsNamespaces[s.ResolveNamespaceAlias(ns)] = flag if slices.Contains(defaultNamespaces, ns) {
ns = defaultNamespace
}
vhsNamespaces[ns] = flag
} }
return vhsNamespaces return vhsNamespaces
alexvanin marked this conversation as resolved Outdated

In #463 we reduced mutex usage, and here we add one more mutex call again. Let's change this a bit.

Maybe we can pass some values into prepareVHSNamespaces that has been read in update() function? Use these values, return map and set it once during mutex lock in update() function as it was before.

If I didn't understand the problem correctly, please elaborate.

In https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/pulls/463 we reduced mutex usage, and here we add one more mutex call again. Let's change this a bit. Maybe we can pass some values into `prepareVHSNamespaces` that has been read in `update()` function? Use these values, return map and set it once during mutex lock in `update()` function as it was before. If I didn't understand the problem correctly, please elaborate.