Skip to content

Commit

Permalink
check for nil values before printing hpa current cpu utilization
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrie30 committed Apr 15, 2018
1 parent 71ad73c commit 998bc1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ Internal cluster monitoring
- $ docker build -t kubieous:v1 .
- $ kubectl run kubieous --image=kubieous:v1 --port=8080
- You'll also want to run an image that you can test on

## Testing HPA
- You need to enable heapster `$ minikube addons enable heapster`
10 changes: 7 additions & 3 deletions checks/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ func handleEventz(event watch.Event) {
if hpa.Status.CurrentReplicas > hpa.Status.DesiredReplicas {
fmt.Println(hpa.ObjectMeta.Namespace + " is scaling DOWN")
fmt.Println("Current VS Desired Replicas: ", hpa.Status.CurrentReplicas, hpa.Status.DesiredReplicas)
fmt.Println("Current CPU utilization: ", *hpa.Status.CurrentCPUUtilizationPercentage)
if hpa.Status.CurrentCPUUtilizationPercentage != nil {
fmt.Println("Current CPU utilization: ", *hpa.Status.CurrentCPUUtilizationPercentage)
}
} else if hpa.Status.CurrentReplicas < hpa.Status.DesiredReplicas {
fmt.Println(hpa.ObjectMeta.Namespace + " is scaling up")
fmt.Println(hpa.ObjectMeta.Namespace + " is scaling UP")
fmt.Println("Current VS Desired Replicas: ", hpa.Status.CurrentReplicas, hpa.Status.DesiredReplicas)
fmt.Println("Current CPU utilization: ", *hpa.Status.CurrentCPUUtilizationPercentage)
if hpa.Status.CurrentCPUUtilizationPercentage != nil {
fmt.Println("Current CPU utilization: ", *hpa.Status.CurrentCPUUtilizationPercentage)
}
}
}

0 comments on commit 998bc1e

Please sign in to comment.