Skip to content

Commit

Permalink
Fix prometheus configmap update in case of delete
Browse files Browse the repository at this point in the history
  • Loading branch information
baluchicken authored and matyix committed Jan 30, 2018
1 parent f0039f6 commit 64a9130
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,14 @@ func DeleteCluster(c *gin.Context) {
// cluster delete success
banzaiUtils.LogInfof(banzaiConstants.TagDeleteCluster, "Cluster %s delete succeeded!", cl.Name)

// update Prometheus config
updatePrometheus()

// delete state store
cloud.DestroyStateStore(cl)

// delete from db
cloud.DeleteFromDb(cl, c)
if cloud.DeleteFromDb(cl, c) {
// update Prometheus config
updatePrometheus()
}
}

}
Expand Down
17 changes: 3 additions & 14 deletions monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)

type prometheusTarget struct {
Expand Down Expand Up @@ -76,19 +75,9 @@ func UpdatePrometheusConfig() error {
}
prometheusConfigRaw := GenerateConfig(prometheusConfig)

var kubeconfig = os.Getenv("KUBECONFIG")
banzaiUtils.LogDebug(banzaiConstants.TagPrometheus, "KUBECONFIG:", kubeconfig)

var (
config *rest.Config
err error
)
if kubeconfig != "" {
config, err = clientcmd.BuildConfigFromFlags("", kubeconfig)
} else {
banzaiUtils.LogInfo(banzaiConstants.TagPrometheus, "Use K8S InCluster Config.")
config, err = rest.InClusterConfig()
}
banzaiUtils.LogInfo(banzaiConstants.TagPrometheus, "Use K8S InCluster Config.")
config, err := rest.InClusterConfig()

if err != nil {
return fmt.Errorf("K8S Connection Failed: %v", err)
}
Expand Down

0 comments on commit 64a9130

Please sign in to comment.