Skip to content

Commit 471197e

Browse files
authored
Use verifycortex endpoint when checking operator readiness (#1430)
1 parent 5945eac commit 471197e

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

cli/cmd/lib_cli_config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,18 +499,17 @@ func validateOperatorEndpoint(endpoint string) (string, error) {
499499
if err != nil {
500500
return "", errors.Wrap(err, "verifying operator endpoint", url)
501501
}
502-
req.Header.Set("Content-Type", "application/json")
503502

504503
client := http.Client{
505504
Transport: &http.Transport{
506505
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
507506
},
508507
}
508+
509509
response, err := client.Do(req)
510510
if err != nil {
511511
return "", ErrorInvalidOperatorEndpoint(url)
512512
}
513-
514513
if response.StatusCode != 200 {
515514
return "", ErrorInvalidOperatorEndpoint(url)
516515
}

manager/install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ function validate_cortex() {
442442
echo "operator endpoint reachable: $operator_endpoint_reachable"
443443
fi
444444
if [ "$operator_endpoint" != "" ]; then
445-
echo "operator curl response (404 is expected):"
446-
curl --max-time 3 $operator_endpoint
445+
echo "operator curl response:"
446+
curl --max-time 3 "${operator_endpoint}/verifycortex"
447447
fi
448448
echo
449449
exit 1
@@ -493,7 +493,7 @@ function validate_cortex() {
493493

494494
if [ "$CORTEX_OPERATOR_LOAD_BALANCER_SCHEME" == "internet-facing" ]; then
495495
if [ "$operator_endpoint_reachable" != "true" ]; then
496-
if ! curl --max-time 3 $operator_endpoint >/dev/null 2>&1; then
496+
if ! curl --max-time 3 "${operator_endpoint}/verifycortex" >/dev/null 2>&1; then
497497
continue
498498
fi
499499
operator_endpoint_reachable="true"

pkg/operator/endpoints/respond.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ func respond(w http.ResponseWriter, response interface{}) {
3131
json.NewEncoder(w).Encode(response)
3232
}
3333

34+
func respondPlainText(w http.ResponseWriter, response string) {
35+
w.Header().Set("Content-Type", "text/plain")
36+
w.WriteHeader(http.StatusOK)
37+
w.Write([]byte(response))
38+
}
39+
3440
func respondError(w http.ResponseWriter, r *http.Request, err error, strs ...string) {
3541
respondErrorCode(w, r, http.StatusBadRequest, err, strs...)
3642
}

pkg/operator/endpoints/verify_cortex.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ import (
2121
)
2222

2323
func VerifyCortex(w http.ResponseWriter, r *http.Request) {
24-
respond(w, "ok")
24+
respondPlainText(w, "ok")
2525
}

0 commit comments

Comments
 (0)