From 94c2bc9488699e225b767cf339c773a1a78841e2 Mon Sep 17 00:00:00 2001 From: sayedppqq Date: Wed, 31 Jan 2024 14:46:26 +0600 Subject: [PATCH] tunnel fix Signed-off-by: sayedppqq --- pkg/monitor/connection/db.go | 2 +- pkg/monitor/connection/helper.go | 3 --- pkg/monitor/prometheus_setup.go | 1 - pkg/monitor/util.go | 4 ++-- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/monitor/connection/db.go b/pkg/monitor/connection/db.go index c45721308..ed41cfa05 100644 --- a/pkg/monitor/connection/db.go +++ b/pkg/monitor/connection/db.go @@ -42,7 +42,7 @@ func Run(f cmdutil.Factory, args []string, prom monitor.PromSvc) { log.Fatal("Enter database and specific database name as argument") } - database := args[0] + database := monitor.ConvertedResource(args[0]) databaseName := args[1] namespace, _, err := f.ToRawKubeConfigLoader().Namespace() if err != nil { diff --git a/pkg/monitor/connection/helper.go b/pkg/monitor/connection/helper.go index b4f39c70d..19ef165c9 100644 --- a/pkg/monitor/connection/helper.go +++ b/pkg/monitor/connection/helper.go @@ -19,8 +19,6 @@ package connection import ( "fmt" "log" - - "kubedb.dev/cli/pkg/monitor" ) const ( @@ -45,7 +43,6 @@ func getIdenticalMetrics(database, databaseName string) map[string]*metrics { func getDBMetrics(database, name string, queries map[string]*metrics) map[string]*metrics { label := "service" labelValue := fmt.Sprintf("%s-stats", name) - database = monitor.ConvertedResource(database) switch database { case "mongodb": queries[database] = &metrics{ diff --git a/pkg/monitor/prometheus_setup.go b/pkg/monitor/prometheus_setup.go index 7bfbbdd92..e1f70fcb3 100644 --- a/pkg/monitor/prometheus_setup.go +++ b/pkg/monitor/prometheus_setup.go @@ -40,7 +40,6 @@ func GetPromClientAndTunnel(config *rest.Config, prom PromSvc) (promv1.API, *por if err != nil { log.Fatal(err) } - defer tunnel.Close() promClient := getPromClient(strconv.Itoa(tunnel.Local)) return promClient, tunnel diff --git a/pkg/monitor/util.go b/pkg/monitor/util.go index d88930fb8..ddefaf652 100644 --- a/pkg/monitor/util.go +++ b/pkg/monitor/util.go @@ -17,7 +17,7 @@ limitations under the License. package monitor import ( - "fmt" + "log" "strings" ) @@ -44,7 +44,7 @@ func ConvertedResource(resource string) string { case "rd", "redis", "redises": res = "redis" default: - fmt.Printf("%s is not a valid resource type \n", resource) + log.Fatalf("%s is not a valid resource type \n", resource) } return res }