Przeglądaj źródła

Merge pull request #1668 from wujunwei/bug-fix

fix bugs referred by issue
Ajay Tripathy 3 lat temu
rodzic
commit
42cfb925ed

+ 3 - 0
pkg/cloud/provider.go

@@ -619,6 +619,9 @@ func GetClusterMeta(cluster_id string) (string, string, error) {
 	address := env.GetSQLAddress()
 	address := env.GetSQLAddress()
 	connStr := fmt.Sprintf("postgres://postgres:%s@%s:5432?sslmode=disable", pw, address)
 	connStr := fmt.Sprintf("postgres://postgres:%s@%s:5432?sslmode=disable", pw, address)
 	db, err := sql.Open("postgres", connStr)
 	db, err := sql.Open("postgres", connStr)
+	if err != nil {
+		return "", "", err
+	}
 	defer db.Close()
 	defer db.Close()
 	query := `SELECT cluster_id, cluster_name
 	query := `SELECT cluster_id, cluster_name
 	FROM names
 	FROM names

+ 2 - 2
pkg/clustercache/clusterexporter.go

@@ -29,8 +29,8 @@ type clusterEncoding struct {
 	PersistentVolumeClaims []*v1.PersistentVolumeClaim    `json:"persistentVolumeClaims,omitempty"`
 	PersistentVolumeClaims []*v1.PersistentVolumeClaim    `json:"persistentVolumeClaims,omitempty"`
 	StorageClasses         []*stv1.StorageClass           `json:"storageClasses,omitempty"`
 	StorageClasses         []*stv1.StorageClass           `json:"storageClasses,omitempty"`
 	Jobs                   []*batchv1.Job                 `json:"jobs,omitempty"`
 	Jobs                   []*batchv1.Job                 `json:"jobs,omitempty"`
-	PodDisruptionBudgets   []*v1beta1.PodDisruptionBudget `json:"podDisruptionBudgets,omitEmpty"`
-	ReplicationControllers []*v1.ReplicationController    `json:"replicationController,omitEmpty"`
+	PodDisruptionBudgets   []*v1beta1.PodDisruptionBudget `json:"podDisruptionBudgets,omitempty"`
+	ReplicationControllers []*v1.ReplicationController    `json:"replicationController,omitempty"`
 }
 }
 
 
 // ClusterExporter manages and runs an file export process which dumps the local kubernetes cluster to a target location.
 // ClusterExporter manages and runs an file export process which dumps the local kubernetes cluster to a target location.

+ 1 - 1
pkg/costmodel/sql.go

@@ -95,10 +95,10 @@ func CostDataRangeFromSQL(field string, value string, window string, start strin
 	address := env.GetSQLAddress()
 	address := env.GetSQLAddress()
 	connStr := fmt.Sprintf("postgres://postgres:%s@%s:5432?sslmode=disable", pw, address)
 	connStr := fmt.Sprintf("postgres://postgres:%s@%s:5432?sslmode=disable", pw, address)
 	db, err := sql.Open("postgres", connStr)
 	db, err := sql.Open("postgres", connStr)
-	defer db.Close()
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
+	defer db.Close()
 	nodes, err := getNodeCosts(db)
 	nodes, err := getNodeCosts(db)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err

+ 1 - 1
pkg/kubecost/window.go

@@ -584,7 +584,7 @@ func (w Window) Minutes() float64 {
 // 	return true
 // 	return true
 // }
 // }
 
 
-func (w Window) Set(start, end *time.Time) {
+func (w *Window) Set(start, end *time.Time) {
 	w.start = start
 	w.start = start
 	w.end = end
 	w.end = end
 }
 }