Skip to content
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

Allow update-ips to finish when no DNS records exists #2375

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/update-ips.bash
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ get_dns_ips() {
local -a ips
mapfile -t ips < <(dig +short "${domain}" | grep '^[.0-9]*$')
if [ ${#ips[@]} -eq 0 ]; then
log_error "No IPs for ${domain} was found"
exit 1
log_error "No IPs for ${domain} was found. Will block all IPs"
echo "0.0.0.0"
fi
echo "${ips[@]}"
}
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/general/bin-update-ips.bats
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ _apply_normalise() {
update_ips.assert_minimal
}

@test "ck8s update-ips blocks all without domain records" {
run ck8s update-ips both apply

assert_equal "$(yq.dig wc '.networkPolicies.global.scIngress.ips | . style="flow"')" "[0.0.0.0/32]"
assert_equal "$(yq.dig wc '.networkPolicies.global.wcIngress.ips | . style="flow"')" "[0.0.0.0/32]"
assert_equal "$(yq.dig sc '.networkPolicies.global.scIngress.ips | . style="flow"')" "[0.0.0.0/32]"
assert_equal "$(yq.dig sc '.networkPolicies.global.wcIngress.ips | . style="flow"')" "[0.0.0.0/32]"
}

@test "ck8s update-ips performs minimal run with zero diff" {
update_ips.mock_minimal
update_ips.populate_minimal
Expand Down
Loading