Przeglądaj źródła

Ensure we don't request resources for specific option.

Signed-off-by: Matt Bolt <mbolt35@gmail.com>
Matt Bolt 1 rok temu
rodzic
commit
d5a25cb43d
1 zmienionych plików z 20 dodań i 16 usunięć
  1. 20 16
      pkg/clustercache/clustercache2.go

+ 20 - 16
pkg/clustercache/clustercache2.go

@@ -3,6 +3,7 @@ package clustercache
 import (
 	"sync"
 
+	"github.com/opencost/opencost/pkg/env"
 	appsv1 "k8s.io/api/apps/v1"
 	batchv1 "k8s.io/api/batch/v1"
 	v1 "k8s.io/api/core/v1"
@@ -51,22 +52,25 @@ func NewKubernetesClusterCacheV2(clientset kubernetes.Interface) *KubernetesClus
 
 func (kcc *KubernetesClusterCacheV2) Run() {
 	var wg sync.WaitGroup
-	wg.Add(14)
-
-	kcc.namespaceStore.Watch(kcc.stopCh, wg.Done)
-	kcc.nodeStore.Watch(kcc.stopCh, wg.Done)
-	kcc.persistentVolumeClaimStore.Watch(kcc.stopCh, wg.Done)
-	kcc.persistentVolumeStore.Watch(kcc.stopCh, wg.Done)
-	kcc.podStore.Watch(kcc.stopCh, wg.Done)
-	kcc.replicationControllerStore.Watch(kcc.stopCh, wg.Done)
-	kcc.serviceStore.Watch(kcc.stopCh, wg.Done)
-	kcc.daemonSetStore.Watch(kcc.stopCh, wg.Done)
-	kcc.deploymentStore.Watch(kcc.stopCh, wg.Done)
-	kcc.replicaSetStore.Watch(kcc.stopCh, wg.Done)
-	kcc.statefulSetStore.Watch(kcc.stopCh, wg.Done)
-	kcc.storageClassStore.Watch(kcc.stopCh, wg.Done)
-	kcc.jobStore.Watch(kcc.stopCh, wg.Done)
-	kcc.pdbStore.Watch(kcc.stopCh, wg.Done)
+
+	if !env.IsETLReadOnlyMode() {
+		wg.Add(14)
+
+		kcc.namespaceStore.Watch(kcc.stopCh, wg.Done)
+		kcc.nodeStore.Watch(kcc.stopCh, wg.Done)
+		kcc.persistentVolumeClaimStore.Watch(kcc.stopCh, wg.Done)
+		kcc.persistentVolumeStore.Watch(kcc.stopCh, wg.Done)
+		kcc.podStore.Watch(kcc.stopCh, wg.Done)
+		kcc.replicationControllerStore.Watch(kcc.stopCh, wg.Done)
+		kcc.serviceStore.Watch(kcc.stopCh, wg.Done)
+		kcc.daemonSetStore.Watch(kcc.stopCh, wg.Done)
+		kcc.deploymentStore.Watch(kcc.stopCh, wg.Done)
+		kcc.replicaSetStore.Watch(kcc.stopCh, wg.Done)
+		kcc.statefulSetStore.Watch(kcc.stopCh, wg.Done)
+		kcc.storageClassStore.Watch(kcc.stopCh, wg.Done)
+		kcc.jobStore.Watch(kcc.stopCh, wg.Done)
+		kcc.pdbStore.Watch(kcc.stopCh, wg.Done)
+	}
 
 	wg.Wait()
 }