Skip to content

Commit

Permalink
Revert "Add API Server Reachability Check (#2959)"
Browse files Browse the repository at this point in the history
This reverts commit 629913b.
  • Loading branch information
s-amann committed Jul 11, 2023
1 parent f87f198 commit 42de202
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
12 changes: 6 additions & 6 deletions pkg/monitor/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,18 @@ func (mon *Monitor) Monitor(ctx context.Context) (errs []error) {
})
}

// If API Server is unreachable, don't need to run the next checks
statusCode, err := mon.getAPIServerPingCode(ctx)
if err != nil || statusCode != http.StatusOK {
// If API is not returning 200, don't need to run the next checks
statusCode, err := mon.emitAPIServerHealthzCode(ctx)
if err != nil {
errs = append(errs, err)
friendlyFuncName := steps.FriendlyName(mon.getAPIServerPingCode)
friendlyFuncName := steps.FriendlyName(mon.emitAPIServerHealthzCode)
mon.log.Printf("%s: %s", friendlyFuncName, err)
mon.emitGauge("monitor.clustererrors", 1, map[string]string{"monitor": friendlyFuncName})
}
if statusCode != http.StatusOK {
return
}

for _, f := range []func(context.Context) error{
mon.emitAPIServerHealthzCode,
mon.emitAroOperatorHeartbeat,
mon.emitAroOperatorConditions,
mon.emitNSGReconciliation,
Expand Down
18 changes: 1 addition & 17 deletions pkg/monitor/cluster/healthz.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
)

func (mon *Monitor) emitAPIServerHealthzCode(ctx context.Context) error {
func (mon *Monitor) emitAPIServerHealthzCode(ctx context.Context) (int, error) {
var statusCode int
err := mon.cli.Discovery().RESTClient().
Get().
Expand All @@ -21,21 +21,5 @@ func (mon *Monitor) emitAPIServerHealthzCode(ctx context.Context) error {
"code": strconv.FormatInt(int64(statusCode), 10),
})

return err
}

func (mon *Monitor) getAPIServerPingCode(ctx context.Context) (int, error) {
var statusCode int
err := mon.cli.Discovery().RESTClient().
Get().
AbsPath("/healthz/ping").
Do(ctx).
StatusCode(&statusCode).
Error()

mon.emitGauge("apiserver.healthz.ping.code", 1, map[string]string{
"code": strconv.FormatInt(int64(statusCode), 10),
})

return statusCode, err
}

0 comments on commit 42de202

Please sign in to comment.