Skip to content

Commit 7f7c54c

Browse files
Merge pull request #7701 from barbacbd/OCPBUGS-23022
OCPBUGS-23022: Installer should not complain when API and API-INT are resolved.
2 parents 7d51e80 + a1f0905 commit 7f7c54c

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
@@ -459,13 +459,22 @@ then
459459
record_service_stage_success
460460
fi
461461

462-
# Check if the API and API_INT Server URLs can be resolved.
463-
echo "Check if API and API-Int URLs are resolvable during bootstrap"
464462
API_SERVER_URL="{{.APIServerURL}}"
465-
API_INT_SERVER_URL="{{.APIIntServerURL}}"
463+
API_INT_SERVER_URL="{{.APIIntServerURL}}"
464+
if [ ! -f api-dns-resolved.done ]; then
465+
echo "Check if API URL is resolvable during bootstrap"
466466

467-
resolve_url "API_URL" "${API_SERVER_URL}"
468-
resolve_url "API_INT_URL" "${API_INT_SERVER_URL}"
467+
if resolve_url "API_URL" "${API_SERVER_URL}"; then
468+
touch api-dns-resolved.done
469+
fi
470+
fi
471+
472+
if [ ! -f api-int-dns-resolved.done ]; then
473+
echo "Check if API-Int URL is resolvable during bootstrap"
474+
if resolve_url "API_INT_URL" "${API_INT_SERVER_URL}"; then
475+
touch api-int-dns-resolved.done
476+
fi
477+
fi
469478

470479
if [ ! -f cco-bootstrap.done ]
471480
then
@@ -578,11 +587,20 @@ else
578587
fi
579588
fi
580589

581-
# Check if the API and API_INT Server URLs can be reached.
582-
echo "Check if API and API-Int URLs are reachable during bootstrap"
590+
if [ ! -f api-dns-check.done ]; then
591+
echo "Check if API URL is reachable during bootstrap"
583592

584-
check_url "API_URL" "${API_SERVER_URL}"
585-
check_url "API_INT_URL" "${API_INT_SERVER_URL}"
593+
if check_url "API_URL" "${API_SERVER_URL}"; then
594+
touch api-dns-check.done
595+
fi
596+
fi
597+
598+
if [ ! -f api-int-dns-check.done ]; then
599+
echo "Check if API-Int URL is reachable during bootstrap"
600+
if check_url "API_INT_URL" "${API_INT_SERVER_URL}"; then
601+
touch api-int-dns-check.done
602+
fi
603+
fi
586604

587605
# Workaround for https://github.com/opencontainers/runc/pull/1807
588606
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)