Sfoglia il codice sorgente

delete unused PodDisruptionBudget

Signed-off-by: r2k1 <yokree@gmail.com>
r2k1 2 anni fa
parent
commit
9caf2ec4a6
1 ha cambiato i file con 1 aggiunte e 19 eliminazioni
  1. 1 19
      pkg/clustercache/clustercache.go

+ 1 - 19
pkg/clustercache/clustercache.go

@@ -11,7 +11,6 @@ import (
 	appsv1 "k8s.io/api/apps/v1"
 	batchv1 "k8s.io/api/batch/v1"
 	v1 "k8s.io/api/core/v1"
-	policyv1 "k8s.io/api/policy/v1"
 	stv1 "k8s.io/api/storage/v1"
 	"k8s.io/apimachinery/pkg/fields"
 	"k8s.io/client-go/kubernetes"
@@ -293,9 +292,6 @@ type ClusterCache interface {
 
 	// GetAllJobs returns all the cached jobs
 	GetAllJobs() []*Job
-
-	// GetAllPodDisruptionBudgets returns all cached pod disruption budgets
-	GetAllPodDisruptionBudgets() []*policyv1.PodDisruptionBudget
 	// SetConfigMapUpdateFunc sets the configmap update function
 	SetConfigMapUpdateFunc(func(interface{}))
 }
@@ -316,7 +312,6 @@ type KubernetesClusterCache struct {
 	pvcWatch               WatchController
 	storageClassWatch      WatchController
 	jobsWatch              WatchController
-	pdbWatch               WatchController
 	stop                   chan struct{}
 }
 
@@ -330,7 +325,6 @@ func NewKubernetesClusterCache(client kubernetes.Interface) ClusterCache {
 	appsRestClient := client.AppsV1().RESTClient()
 	storageRestClient := client.StorageV1().RESTClient()
 	batchClient := client.BatchV1().RESTClient()
-	pdbClient := client.PolicyV1().RESTClient()
 
 	kubecostNamespace := env.GetKubecostNamespace()
 	log.Infof("NAMESPACE: %s", kubecostNamespace)
@@ -349,7 +343,6 @@ func NewKubernetesClusterCache(client kubernetes.Interface) ClusterCache {
 		pvcWatch:               NewCachingWatcher(coreRestClient, "persistentvolumeclaims", &v1.PersistentVolumeClaim{}, "", fields.Everything()),
 		storageClassWatch:      NewCachingWatcher(storageRestClient, "storageclasses", &stv1.StorageClass{}, "", fields.Everything()),
 		jobsWatch:              NewCachingWatcher(batchClient, "jobs", &batchv1.Job{}, "", fields.Everything()),
-		pdbWatch:               NewCachingWatcher(pdbClient, "poddisruptionbudgets", &policyv1.PodDisruptionBudget{}, "", fields.Everything()),
 	}
 
 	// Wait for each caching watcher to initialize
@@ -359,7 +352,7 @@ func NewKubernetesClusterCache(client kubernetes.Interface) ClusterCache {
 		wg.Add(1)
 		go initializeCache(kcc.kubecostConfigMapWatch, &wg, cancel)
 	} else {
-		wg.Add(13)
+		wg.Add(12)
 		go initializeCache(kcc.kubecostConfigMapWatch, &wg, cancel)
 		go initializeCache(kcc.namespaceWatch, &wg, cancel)
 		go initializeCache(kcc.nodeWatch, &wg, cancel)
@@ -372,7 +365,6 @@ func NewKubernetesClusterCache(client kubernetes.Interface) ClusterCache {
 		go initializeCache(kcc.pvcWatch, &wg, cancel)
 		go initializeCache(kcc.storageClassWatch, &wg, cancel)
 		go initializeCache(kcc.jobsWatch, &wg, cancel)
-		go initializeCache(kcc.pdbWatch, &wg, cancel)
 	}
 
 	wg.Wait()
@@ -400,7 +392,6 @@ func (kcc *KubernetesClusterCache) Run() {
 	go kcc.pvcWatch.Run(1, stopCh)
 	go kcc.storageClassWatch.Run(1, stopCh)
 	go kcc.jobsWatch.Run(1, stopCh)
-	go kcc.pdbWatch.Run(1, stopCh)
 
 	kcc.stop = stopCh
 }
@@ -513,15 +504,6 @@ func (kcc *KubernetesClusterCache) GetAllJobs() []*Job {
 	return jobs
 }
 
-func (kcc *KubernetesClusterCache) GetAllPodDisruptionBudgets() []*policyv1.PodDisruptionBudget {
-	var pdbs []*policyv1.PodDisruptionBudget
-	items := kcc.pdbWatch.GetAll()
-	for _, pdb := range items {
-		pdbs = append(pdbs, pdb.(*policyv1.PodDisruptionBudget))
-	}
-	return pdbs
-}
-
 func (kcc *KubernetesClusterCache) SetConfigMapUpdateFunc(f func(interface{})) {
 	kcc.kubecostConfigMapWatch.SetUpdateHandler(f)
 }