/
healthcheck.go
37 lines (30 loc) · 1.35 KB
/
healthcheck.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package cluster
import (
"context"
"net/http"
"time"
"github.com/openshift/openshift-azure/pkg/api"
"github.com/openshift/openshift-azure/pkg/util/healthcheck"
"github.com/openshift/openshift-azure/pkg/util/wait"
)
func getConsoleClient(cs *api.OpenShiftManagedCluster) wait.SimpleHTTPClient {
cert := cs.Config.Certificates.OpenShiftConsole.Certs
return &http.Client{Transport: healthcheck.RoundTripper(cs.Properties.FQDN, cert[len(cert)-1]), Timeout: 10 * time.Second}
}
// HealthCheck function to verify cluster health
func (u *Upgrade) HealthCheck(ctx context.Context) *api.PluginError {
u.Log.Info("checking developer console health")
_, err := wait.ForHTTPStatusOk(ctx, u.Log, u.GetConsoleClient(u.Cs), "https://"+u.Cs.Properties.PublicHostname+"/console/", time.Second)
if err != nil {
return &api.PluginError{Err: err, Step: api.PluginStepWaitForConsoleHealth}
}
return nil
}
func getAPIServerClient(cs *api.OpenShiftManagedCluster) wait.SimpleHTTPClient {
return &http.Client{Transport: healthcheck.RoundTripper(cs.Properties.FQDN, cs.Config.Certificates.Ca.Cert), Timeout: 10 * time.Second}
}
func (u *Upgrade) WaitForHealthzStatusOk(ctx context.Context) error {
u.Log.Infof("waiting for API server healthz")
_, err := wait.ForHTTPStatusOk(ctx, u.Log, u.GetAPIServerClient(u.Cs), "https://"+u.Cs.Properties.FQDN+"/healthz", time.Second)
return err
}