Skip to content

Commit a1f0905

Browse files
committed
OCPBUGS-23022: Installer should not complain when API and API-INT are resolved.
** Removed the warning that API and/or API-Int cannot be resolved. ** Used the last errors to be alerted instead during failures. ** Used Warning rather than Info to alert users of errors.
1 parent 585a01a commit a1f0905

File tree

4 files changed

+38
-19
lines changed

4 files changed

+38
-19
lines changed

data/data/bootstrap/files/usr/local/bin/bootkube.sh.template

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,22 @@ then
416416
record_service_stage_success
417417
fi
418418

419-
# Check if the API and API_INT Server URLs can be resolved.
420-
echo "Check if API and API-Int URLs are resolvable during bootstrap"
421419
API_SERVER_URL="{{.APIServerURL}}"
422-
API_INT_SERVER_URL="{{.APIIntServerURL}}"
420+
API_INT_SERVER_URL="{{.APIIntServerURL}}"
421+
if [ ! -f api-dns-resolved.done ]; then
422+
echo "Check if API URL is resolvable during bootstrap"
423423

424-
resolve_url "API_URL" "${API_SERVER_URL}"
425-
resolve_url "API_INT_URL" "${API_INT_SERVER_URL}"
424+
if resolve_url "API_URL" "${API_SERVER_URL}"; then
425+
touch api-dns-resolved.done
426+
fi
427+
fi
428+
429+
if [ ! -f api-int-dns-resolved.done ]; then
430+
echo "Check if API-Int URL is resolvable during bootstrap"
431+
if resolve_url "API_INT_URL" "${API_INT_SERVER_URL}"; then
432+
touch api-int-dns-resolved.done
433+
fi
434+
fi
426435

427436
if [ ! -f cco-bootstrap.done ]
428437
then
@@ -535,11 +544,20 @@ else
535544
fi
536545
fi
537546

538-
# Check if the API and API_INT Server URLs can be reached.
539-
echo "Check if API and API-Int URLs are reachable during bootstrap"
547+
if [ ! -f api-dns-check.done ]; then
548+
echo "Check if API URL is reachable during bootstrap"
540549

541-
check_url "API_URL" "${API_SERVER_URL}"
542-
check_url "API_INT_URL" "${API_INT_SERVER_URL}"
550+
if check_url "API_URL" "${API_SERVER_URL}"; then
551+
touch api-dns-check.done
552+
fi
553+
fi
554+
555+
if [ ! -f api-int-dns-check.done ]; then
556+
echo "Check if API-Int URL is reachable during bootstrap"
557+
if check_url "API_INT_URL" "${API_INT_SERVER_URL}"; then
558+
touch api-int-dns-check.done
559+
fi
560+
fi
543561

544562
# Workaround for https://github.com/opencontainers/runc/pull/1807
545563
touch /opt/openshift/.bootkube.done

data/data/bootstrap/files/usr/local/bin/bootstrap-verify-api-server-urls.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ function validate_url() {
3535
function resolve_url() {
3636
if [[ -z "${1}" ]] || [[ -z "${2}" ]]; then
3737
echo "Usage: resolve_url <API_URL or API_INT URL> <URL that needs to be verified>"
38-
return
38+
return 1
3939
fi
4040

4141
local URL_TYPE=${1}
4242
local SERVER_URL=${2}
4343

4444
if [[ ${URL_TYPE} != API_URL ]] && [[ ${URL_TYPE} != API_INT_URL ]]; then
4545
echo "Usage: resolve_url <API_URL or API_INT URL> <URL that needs to be verified>"
46-
return
46+
return 1
4747
fi
4848

4949
echo "Checking if ${SERVER_URL} of type ${URL_TYPE} is resolvable"
@@ -58,26 +58,27 @@ function resolve_url() {
5858
record_service_stage_start ${URL_STAGE_NAME}
5959
if lookup_url "$URL_TYPE" "$SERVER_URL"; then
6060
record_service_stage_success
61+
return 0
6162
else
6263
record_service_stage_failure
6364
# We do not want to stop bootkube service due to this failure.
6465
# So not returning failure at this point.
65-
return
66+
return 1
6667
fi
6768
}
6869

6970
function check_url() {
7071
if [[ -z "${1}" ]] || [[ -z "${2}" ]]; then
7172
echo "Usage: check_url <API_URL or API_INT URL> <URL that needs to be verified>"
72-
return
73+
return 1
7374
fi
7475

7576
local URL_TYPE=${1}
7677
local SERVER_URL=${2}
7778

7879
if [[ ${URL_TYPE} != API_URL ]] && [[ ${URL_TYPE} != API_INT_URL ]]; then
7980
echo "Usage: check_url <API_URL or API_INT URL> <URL that needs to be verified>"
80-
return
81+
return 1
8182
fi
8283

8384
echo "Checking if ${SERVER_URL} of type ${URL_TYPE} reachable"
@@ -93,11 +94,13 @@ function check_url() {
9394
record_service_stage_start ${URL_STAGE_NAME}
9495
if validate_url "$URL_TYPE" "$CURL_URL"; then
9596
record_service_stage_success
97+
# Return the value from the validate_url- even on success
98+
return 0
9699
else
97100
echo "Unable to validate. ${CURL_URL} is currently unreachable."
98101
record_service_stage_failure
99102
# We do not want to stop bootkube service due to this failure.
100103
# So not returning failure at this point.
101-
return
104+
return 1
102105
fi
103106
}

pkg/gather/service/analyze.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func analyzeGatherBundle(bundleFile io.Reader) error {
7777
optional bool
7878
}{
7979
{name: "release-image", check: checkReleaseImageDownload, optional: false},
80-
{name: "bootkube", check: checkAPIURLs, optional: false},
80+
{name: "bootkube", check: checkBootkubeService, optional: false},
8181
}
8282
for _, check := range analysisChecks {
8383
a := serviceAnalyses[check.name]
@@ -112,13 +112,12 @@ func checkReleaseImageDownload(a analysis) bool {
112112
// failure to resolve either the API URL or API-Int URL or both. If that changes and if
113113
// any other stage in the bootkube service starts reporting a failure, we need to revisit
114114
// this. At that point verification of the URLs could be moved to its own service.
115-
func checkAPIURLs(a analysis) bool {
115+
func checkBootkubeService(a analysis) bool {
116116
if a.successful {
117117
return true
118118
}
119119
// Note: Even when there is a stage failure, we are not returning false here. That is
120120
// intentional because we donot want to report this as an error in the "analyze" output.
121-
logrus.Warn("The bootstrap machine is unable to resolve API and/or API-Int Server URLs")
122121
a.logLastError()
123122
return true
124123
}

pkg/gather/service/analyze_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func failedReleaseImage() []logrus.Entry {
3939

4040
func failedURLChecks() []logrus.Entry {
4141
return []logrus.Entry{
42-
{Level: logrus.WarnLevel, Message: "The bootstrap machine is unable to resolve API and/or API-Int Server URLs"},
4342
{Level: logrus.InfoLevel, Message: "Line 1"},
4443
{Level: logrus.InfoLevel, Message: "Line 2"},
4544
{Level: logrus.InfoLevel, Message: "Line 3"},

0 commit comments

Comments
 (0)