From 96adfaebe1ae63a7cdcace71068402d9f27da93d Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Thu, 21 Apr 2022 12:07:33 -0700 Subject: [PATCH] Make storage class config dynamic (#14791) Updating the storage class is already thread safe, so we can do this safely. --- cmd/config-current.go | 32 ++++++++++++++++---------------- internal/config/config.go | 1 + 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/cmd/config-current.go b/cmd/config-current.go index f3f2c677b..9894d9dc6 100644 --- a/cmd/config-current.go +++ b/cmd/config-current.go @@ -484,22 +484,6 @@ func lookupConfigs(s config.Config, objAPI ObjectLayer) { getRemoteInstanceTransport = newGatewayHTTPTransport(apiConfig.RemoteTransportDeadline) }) - if globalIsErasure && objAPI != nil { - setDriveCounts := objAPI.SetDriveCounts() - for i, setDriveCount := range setDriveCounts { - sc, err := storageclass.LookupConfig(s[config.StorageClassSubSys][config.Default], setDriveCount) - if err != nil { - logger.LogIf(ctx, fmt.Errorf("Unable to initialize storage class config: %w", err)) - break - } - // if we validated all setDriveCounts and it was successful - // proceed to store the correct storage class globally. - if i == len(setDriveCounts)-1 { - globalStorageClass.Update(sc) - } - } - } - globalCacheConfig, err = cache.LookupConfig(s[config.CacheSubSys][config.Default]) if err != nil { if globalIsGateway { @@ -670,6 +654,22 @@ func applyDynamicConfigForSubSys(ctx context.Context, objAPI ObjectLayer, s conf if err != nil { logger.LogIf(ctx, fmt.Errorf("Unable to update audit kafka targets: %w", err)) } + case config.StorageClassSubSys: + if globalIsErasure && objAPI != nil { + setDriveCounts := objAPI.SetDriveCounts() + for i, setDriveCount := range setDriveCounts { + sc, err := storageclass.LookupConfig(s[config.StorageClassSubSys][config.Default], setDriveCount) + if err != nil { + logger.LogIf(ctx, fmt.Errorf("Unable to initialize storage class config: %w", err)) + break + } + // if we validated all setDriveCounts and it was successful + // proceed to store the correct storage class globally. + if i == len(setDriveCounts)-1 { + globalStorageClass.Update(sc) + } + } + } } globalServerConfigMu.Lock() defer globalServerConfigMu.Unlock() diff --git a/internal/config/config.go b/internal/config/config.go index 400cc7191..8706eaff5 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -169,6 +169,7 @@ var SubSystemsDynamic = set.CreateStringSet( LoggerWebhookSubSys, AuditWebhookSubSys, AuditKafkaSubSys, + StorageClassSubSys, ) // SubSystemsSingleTargets - subsystems which only support single target.