-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Bug 2072202: Check for api and api-int resolution during cluster install #5816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-robot
merged 3 commits into
openshift:master
from
sadasu:add-install-failure-check
Oct 13, 2022
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
data/data/bootstrap/files/usr/local/bin/bootstrap-verify-api-server-urls.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # shellcheck disable=SC1091 | ||
| . /usr/local/bin/bootstrap-service-record.sh | ||
|
|
||
| # This functions expects 2 arguments: | ||
| # 1. name of the URL | ||
| # 2. The value of the URL | ||
| function resolve_url() { | ||
| unset IPS | ||
| unset IP | ||
| IPS=$(dig "${2}" +short) | ||
| if [[ ! -z "${IPS}" ]] ; then | ||
| echo "Successfully resolved ${1} ${2}" | ||
| # dig returns multiple IPs. Check if the | ||
| # first IP is reachable. | ||
| ip_arr="" | ||
| readarray ip_arr -t <<<"${IPS}" | ||
| IP="$(echo "${ip_arr[0]}" | tr -d '\n')" | ||
| return 0 | ||
| else | ||
| echo "Unable to resolve ${1} ${2}" | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| # This functions expects 2 arguments: | ||
| # 1. name of the URL | ||
| # 2. URL to validate | ||
| function validate_url() { | ||
| if [[ $(curl --head -k --silent --fail --write-out "%{http_code}\\n" "${2}" -o /dev/null) == 200 ]]; then | ||
| echo "Success while trying to reach ${1}'s https endpoint at ${2}" | ||
| return 0 | ||
| else | ||
| echo "Unable to reach ${1}'s https endpoint at ${2}" | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| function check_url() { | ||
| if [[ -z "${1}" ]] || [[ -z "${2}" ]]; then | ||
| echo "Usage: check_url <API_URL or API_INT URL> <URL that needs to be verified>" | ||
| return | ||
| fi | ||
|
|
||
| local URL_TYPE=${1} | ||
| local SERVER_URL=${2} | ||
|
|
||
| if [[ ${URL_TYPE} != API_URL ]] && [[ ${URL_TYPE} != API_INT_URL ]]; then | ||
| echo "Usage: check_url <API_URL or API_INT URL> <URL that needs to be verified>" | ||
| return | ||
| fi | ||
|
|
||
| echo "Checking validity of ${SERVER_URL} of type ${URL_TYPE}" | ||
|
|
||
| if [[ "${URL_TYPE}" = "API_URL" ]]; then | ||
sadasu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| local URL_STAGE_NAME="check-api-url" | ||
| else | ||
| local URL_STAGE_NAME="check-api-int-url" | ||
| fi | ||
|
|
||
| echo "Starting stage ${URL_STAGE_NAME}" | ||
| record_service_stage_start ${URL_STAGE_NAME} | ||
| if resolve_url "$URL_TYPE" "$SERVER_URL"; then | ||
| record_service_stage_success | ||
| else | ||
| record_service_stage_failure | ||
| # We do not want to stop bootkube service due to this failure. | ||
| # So not returning failure at this point. | ||
| return | ||
| fi | ||
|
|
||
| CURL_URL="https://${IP}:6443/version" | ||
|
|
||
| record_service_stage_start ${URL_STAGE_NAME} | ||
| if validate_url "$URL_TYPE" "$CURL_URL"; then | ||
| record_service_stage_success | ||
| else | ||
| echo "It might be too early for the ${CURL_URL} to be available." | ||
| record_service_stage_failure | ||
| fi | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patrickdillon @jstuever I am unclear about whether kubeconfig needs to be specified here.
From my understanding, if this script is only run from
analyzewe don't have to but if output from this service is to be included in install-gather, then we would have to?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every instance of
ocI see in the bootstrap node specifies a kubeconfig explicitly so I think so.analyzedoes not execute anything on the bootstrap node.gatherwill execute commands to grab logs on the bootstrap node, but this service should just be running as part of the standard execution of bootkube.gatherwill not cause it to be run but will just collect its logs