Skip to content

Commit

Permalink
Merge pull request #73 from natron-io/logger
Browse files Browse the repository at this point in the history
set discount default 0
  • Loading branch information
janlauber authored Feb 8, 2022
2 parents a5abac1 + 26b3ce6 commit 63bd353
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions util/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func GetCPURequestsSumByTenant(tenants []string) (map[string]int64, error) {

// get DISCOUNT_REQUEST by DISCOUNT_LABEL
discount := pod.Labels[DISCOUNT_LABEL]
if discount == "" {
discount = "0"
}
// convert to float64
discountFloat, err := strconv.ParseFloat(discount, 64)
if err != nil || discountFloat < 0 || discountFloat > 1 {
Expand Down Expand Up @@ -74,6 +77,9 @@ func GetMemoryRequestsSumByTenant(tenants []string) (map[string]int64, error) {

// get DISCOUNT_REQUEST by DISCOUNT_LABEL
discount := pod.Labels[DISCOUNT_LABEL]
if discount == "" {
discount = "0"
}
// convert to float64
discountFloat, err := strconv.ParseFloat(discount, 64)
if err != nil || discountFloat < 0 || discountFloat > 1 {
Expand Down Expand Up @@ -103,6 +109,9 @@ func GetStorageRequestsSumByTenant(tenants []string) (map[string]map[string]int6
for _, pvc := range pvcList.Items {
// get DISCOUNT_REQUEST by DISCOUNT_LABEL
discount := pvc.Labels[DISCOUNT_LABEL]
if discount == "" {
discount = "0"
}
// convert to float64
discountFloat, err := strconv.ParseFloat(discount, 64)
if err != nil || discountFloat < 0 || discountFloat > 1 {
Expand Down Expand Up @@ -136,6 +145,9 @@ func GetIngressRequestsSumByTenant(tenants []string) (map[string][]string, error
for _, ingress := range ingressList.Items {
// get DISCOUNT_REQUEST by DISCOUNT_LABEL
discount := ingress.Labels[DISCOUNT_LABEL]
if discount == "" {
discount = "0"
}
// convert to float64
discountFloat, err := strconv.ParseFloat(discount, 64)
if err != nil || discountFloat < 0 || discountFloat > 1 {
Expand Down

0 comments on commit 63bd353

Please sign in to comment.