-
Notifications
You must be signed in to change notification settings - Fork 244
fix: regenerate localdns corefile if it goes missing #7604
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,9 +75,18 @@ verify_localdns_corefile() { | |
| return 1 | ||
| fi | ||
|
|
||
| # Check if corefile exists, is not empty, else attempt to regenerate it. | ||
| if [ ! -f "${LOCALDNS_CORE_FILE}" ] || [ ! -s "${LOCALDNS_CORE_FILE}" ]; then | ||
| echo "Localdns corefile either does not exist or is empty at ${LOCALDNS_CORE_FILE}." | ||
| return 1 | ||
|
|
||
| echo "Attempting to regenerate localdns corefile..." | ||
| if regenerate_localdns_corefile; then | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will localdns restart automatically when corefile is deleted?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, localdns systemd unit will not restart automatically when the corefile get deleted. If the corefile gets deleted for any reason, and if watchdog restarts systemd unit inside the node, then localdns systemd unit will never come up. So this PR will handle this case.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so, if the corefile is deleted, and the systemd unit is not restarted, will it still functioning?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, that is correct and that is what I have noticed on the node. |
||
| echo "Localdns corefile regenerated successfully." | ||
| return 0 | ||
| else | ||
| echo "Failed to regenerate localdns corefile." | ||
| return 1 | ||
| fi | ||
| fi | ||
| return 0 | ||
| } | ||
|
|
@@ -115,6 +124,31 @@ verify_localdns_binary() { | |
| return 0 | ||
| } | ||
|
|
||
| # Regenerate the localdns corefile from base64 encoded content. | ||
| # This is used when the corefile goes missing. | ||
| regenerate_localdns_corefile() { | ||
| if [ -z "${LOCALDNS_BASE64_ENCODED_COREFILE:-}" ]; then | ||
| echo "LOCALDNS_BASE64_ENCODED_COREFILE is not set. Cannot regenerate corefile." | ||
| return 1 | ||
| fi | ||
| echo "Regenerating localdns corefile at ${LOCALDNS_CORE_FILE}" | ||
|
|
||
| mkdir -p "$(dirname "${LOCALDNS_CORE_FILE}")" | ||
| # Decode base64 corefile content and write to corefile. | ||
| if ! echo "${LOCALDNS_BASE64_ENCODED_COREFILE}" | base64 -d > "${LOCALDNS_CORE_FILE}"; then | ||
| echo "Failed to decode and write corefile." | ||
| return 1 | ||
| fi | ||
|
|
||
| chmod 0644 "${LOCALDNS_CORE_FILE}" || { | ||
| echo "Failed to set permissions on ${LOCALDNS_CORE_FILE}" | ||
| return 1 | ||
| } | ||
|
|
||
| echo "Successfully regenerated localdns corefile." | ||
| return 0 | ||
| } | ||
|
|
||
| # Replace AzureDNSIP in corefile with VNET DNS ServerIPs if necessary. | ||
| replace_azurednsip_in_corefile() { | ||
| if [ -z "${RESOLV_CONF:-}" ]; then | ||
|
|
||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.