Skip to content

Commit

Permalink
Merge pull request #15 from oscp/performance_fix
Browse files Browse the repository at this point in the history
Fix performance when getting node pod capacities
  • Loading branch information
c0desurfer authored Oct 18, 2018
2 parents 7d8b49e + 6f472af commit 0270a75
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions daemon/client/checks/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ func getTotalPods() (int, error) {
}

func getTotalPodCapacity(output string) (int, error) {
out, err := exec.Command("bash", "-c", "oc describe nodes "+getReadyWorkingNodeNames(output)+" | grep Capacity -A4 | grep pods | awk '{ print $2 }' | paste -sd+ | bc").Output()
out, err := exec.Command("bash", "-c", "oc get nodes "+getReadyWorkingNodeNames(output)+` -o=jsonpath='{range .items[*]}{.status.capacity.pods}{"\n"}{end}' | paste -sd+ | bc`).Output()
if err != nil {
return 0, errors.New("Could not parse oc describe nodes output: " + err.Error())
return 0, errors.New("Could not parse oc get nodes output: " + err.Error())
}
trimmed := strings.TrimSpace(string(out))
i, err := strconv.Atoi(trimmed)
if err != nil {
return 0, errors.New("Could not parse oc describe nodes output: " + err.Error())
return 0, errors.New("Could not parse oc get nodes output: " + err.Error())
}
return i, nil
}
Expand Down

0 comments on commit 0270a75

Please sign in to comment.