Skip to content

Commit

Permalink
OPNET-629: Use HAProxy monitor endpoint instead of API
Browse files Browse the repository at this point in the history
This is the runtimecfg change corresponding to
openshift/machine-config-operator#4767
which switches the monitor call to the HAProxy endpoing rather than
call through to the API.
  • Loading branch information
cybertron committed Dec 18, 2024
1 parent 7fdf25f commit d4bd2f3
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
)

const kubeClientTimeout = 30 * time.Second
const haproxyHealthPort = 9454

func FletcherChecksum8(inp string) uint8 {
var ckA, ckB uint8
Expand Down Expand Up @@ -67,19 +68,14 @@ func IsKubernetesHealthy(port uint16) (bool, error) {
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: transport}
resp, err := client.Get(fmt.Sprintf("https://localhost:%d/readyz", port))
resp, err := client.Get(fmt.Sprintf("http://localhost:%d/haproxy_monitor", haproxyHealthPort))
if err != nil {
return false, err
}
defer client.CloseIdleConnections()
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return false, err
}

return string(body) == "ok", nil
return resp.StatusCode == 200, nil
}

func AlarmStabilization(cur_alrm bool, cur_defect bool, consecutive_ctr uint8, on_threshold uint8, off_threshold uint8) (bool, uint8) {
Expand Down

0 comments on commit d4bd2f3

Please sign in to comment.