Pārlūkot izejas kodu

fix: Add missing fallback path for cloud integration config

Fixes #3450

After upgrading from 1.115.0 to 1.118.0, cloud cost integrations broke
because the Helm chart now mounts the cloudIntegrationSecret as a
subdirectory (/var/configs/cloud-integration/) instead of directly as a
file (/var/configs/cloud-integration.json).

This commit adds a second fallback path check that looks for the config
at /var/configs/cloud-integration/cloud-integration.json, maintaining
backward compatibility with all three mounting scenarios:

1. Primary: /var/configs/cloud-integration.json (direct file mount)
2. New fallback: /var/configs/cloud-integration/cloud-integration.json (directory mount)
3. Legacy fallback: /var/cloud-integration/cloud-integration.json (original secret mount)

Changes:
- Added GetConfigPath() wrapper function to pkg/env/cloudcost.go
- Added intermediate path check in MultiCloudWatcher.GetConfigs()
Claude 6 mēneši atpakaļ
vecāks
revīzija
9dec672cac
2 mainītis faili ar 18 papildinājumiem un 4 dzēšanām
  1. 14 4
      pkg/cloud/config/watcher.go
  2. 4 0
      pkg/env/cloudcost.go

+ 14 - 4
pkg/cloud/config/watcher.go

@@ -248,16 +248,26 @@ func (mcw *MultiCloudWatcher) GetConfigs() []cloud.KeyedConfig {
 
 	// If config does not exist implies that this configuration method was not used
 	if !exists {
-		// check the original location of secret mount
-		multiConfigPath = path.Join("/var", cloudIntegrationSecretPath)
+		// check if secret was mounted as a subdirectory under config path (fixes #3450)
+		// this handles the case where the secret is mounted at /var/configs/cloud-integration/cloud-integration.json
+		multiConfigPath = path.Join(env.GetConfigPath(), "cloud-integration", "cloud-integration.json")
 		exists, err = fileutil.FileExists(multiConfigPath)
 		if err != nil {
 			log.Errorf("MultiCloudWatcher:  error checking file at '%s': %s", multiConfigPath, err.Error())
 		}
 
-		// If config does not exist implies that this configuration method was not used
 		if !exists {
-			return nil
+			// check the original location of secret mount
+			multiConfigPath = path.Join("/var", cloudIntegrationSecretPath)
+			exists, err = fileutil.FileExists(multiConfigPath)
+			if err != nil {
+				log.Errorf("MultiCloudWatcher:  error checking file at '%s': %s", multiConfigPath, err.Error())
+			}
+
+			// If config does not exist implies that this configuration method was not used
+			if !exists {
+				return nil
+			}
 		}
 	}
 

+ 4 - 0
pkg/env/cloudcost.go

@@ -36,6 +36,10 @@ func IsCustomCostEnabled() bool {
 	return env.GetBool(CustomCostEnabledEnvVar, false)
 }
 
+func GetConfigPath() string {
+	return env.GetConfigPath()
+}
+
 func GetCloudCostConfigPath() string {
 	return env.GetPathFromConfig(CloudIntegrationConfigFile)
 }