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

fix: reload on resetting to defaults #159

Merged
merged 25 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
511690b
fix: reload on resetting to defaults
BrennanPaciorek Jul 18, 2023
ba943d7
test: reload on previous replaced quality test
BrennanPaciorek Jul 20, 2023
a79e91b
tests - fix linter issues
BrennanPaciorek Jul 20, 2023
0289da2
test: ignore ansible test shebang check
BrennanPaciorek Jul 20, 2023
e363271
Update tests/files/test_ping.sh
BrennanPaciorek Jul 20, 2023
3344e93
Update tests/files/test_ping.sh
BrennanPaciorek Jul 20, 2023
1262395
Update tests/files/test_ping.sh
BrennanPaciorek Jul 20, 2023
15dd90f
Update tests/files/test_ping.sh
BrennanPaciorek Jul 20, 2023
b4e21d2
Update .sanity-ansible-ignore-2.12.txt
BrennanPaciorek Jul 20, 2023
1517156
Update .sanity-ansible-ignore-2.13.txt
BrennanPaciorek Jul 20, 2023
68d20ab
Update .sanity-ansible-ignore-2.14.txt
BrennanPaciorek Jul 20, 2023
c2d7d22
Update .sanity-ansible-ignore-2.15.txt
BrennanPaciorek Jul 20, 2023
eea02b2
Update .sanity-ansible-ignore-2.12.txt
BrennanPaciorek Jul 20, 2023
2dd12c5
Update .sanity-ansible-ignore-2.13.txt
BrennanPaciorek Jul 20, 2023
233158e
Update .sanity-ansible-ignore-2.14.txt
BrennanPaciorek Jul 20, 2023
454c89c
Update .sanity-ansible-ignore-2.15.txt
BrennanPaciorek Jul 20, 2023
1e94a3d
Update .sanity-ansible-ignore-2.9.txt
BrennanPaciorek Jul 20, 2023
6513678
test: change order in which ping tests are run
BrennanPaciorek Jul 20, 2023
05fc94b
fix - change systemctl reload to firewall-cmd --reload
BrennanPaciorek Jul 20, 2023
e3cad3e
tests: make shellcheck not fail
BrennanPaciorek Jul 20, 2023
0098fa8
test - debug script, reduce pings and add timeout
BrennanPaciorek Jul 21, 2023
d6d80d2
files: remove unnecessary variable from reset script args
BrennanPaciorek Jul 21, 2023
cee01c7
ci: skip tests/tests_reload_on_reset.yml on EL7
BrennanPaciorek Jul 21, 2023
05b0bbd
test: modify tests/files/test_ping.sh parameters
BrennanPaciorek Jul 21, 2023
29a1126
test: remove trailing spaces (ansiblelint)
BrennanPaciorek Jul 21, 2023
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
1 change: 1 addition & 0 deletions .sanity-ansible-ignore-2.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ plugins/modules/firewall_lib.py validate-modules:missing-gplv3-license
plugins/modules/firewall_lib_facts.py validate-modules:missing-gplv3-license
plugins/modules/firewall_lib.py validate-modules:missing-examples
roles/firewall/files/get_files_checksums.sh shebang!skip
tests/firewall/files/test_ping.sh shebang!skip
1 change: 1 addition & 0 deletions .sanity-ansible-ignore-2.13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ plugins/modules/firewall_lib.py validate-modules:missing-gplv3-license
plugins/modules/firewall_lib_facts.py validate-modules:missing-gplv3-license
plugins/modules/firewall_lib.py validate-modules:missing-examples
roles/firewall/files/get_files_checksums.sh shebang!skip
tests/firewall/files/test_ping.sh shebang!skip
1 change: 1 addition & 0 deletions .sanity-ansible-ignore-2.14.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ plugins/modules/firewall_lib.py validate-modules:missing-gplv3-license
plugins/modules/firewall_lib_facts.py validate-modules:missing-gplv3-license
plugins/modules/firewall_lib.py validate-modules:missing-examples
roles/firewall/files/get_files_checksums.sh shebang!skip
tests/firewall/files/test_ping.sh shebang!skip
1 change: 1 addition & 0 deletions .sanity-ansible-ignore-2.15.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ plugins/modules/firewall_lib.py validate-modules:missing-gplv3-license
plugins/modules/firewall_lib_facts.py validate-modules:missing-gplv3-license
plugins/modules/firewall_lib.py validate-modules:missing-examples
roles/firewall/files/get_files_checksums.sh shebang!skip
tests/firewall/files/test_ping.sh shebang!skip
1 change: 1 addition & 0 deletions .sanity-ansible-ignore-2.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ plugins/modules/firewall_lib.py validate-modules:missing-gplv3-license
plugins/modules/firewall_lib_facts.py validate-modules:missing-gplv3-license
plugins/modules/firewall_lib.py validate-modules:missing-examples
roles/firewall/files/get_files_checksums.sh shebang!skip
tests/firewall/files/test_ping.sh shebang!skip
5 changes: 2 additions & 3 deletions files/get_files_checksums.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ set -euo pipefail

python_cmd="$1"
firewall_conf_root="${2:-/etc/firewalld}"
firewall_service="${3:-firewalld}"
remove="${4:-false}"
remove="${3:-false}"

listfile=$(mktemp)
firewallconf=$(mktemp)
Expand Down Expand Up @@ -33,7 +32,7 @@ if [ "${remove:-false}" = true ]; then
find "$firewall_conf_root" -name \*.xml -exec rm -f {} \;
rm -f "$firewall_conf_root/firewalld.conf"
if [ -s "$listfile" ] ; then
systemctl restart "$firewall_service"
firewall-cmd --reload > /dev/null
fi
fi

Expand Down
3 changes: 1 addition & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
script:
cmd: >
files/get_files_checksums.sh {{ __firewall_python_cmd | quote }}
{{ __firewall_firewalld_dir | quote }} {{ __firewall_service | quote }}
true
{{ __firewall_firewalld_dir | quote }} true
register: __firewall_config_files_before
changed_when: false
when: __firewall_previous_replaced | bool
Expand Down
60 changes: 60 additions & 0 deletions tests/files/test_ping.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
# Author - Brennan Paciorek <[email protected]>
# Description - Benchmark firewalld downtime while reloading and while restarting
# by measuring how many packets are dropped while firewalld is restarting/reloading
set -euo pipefail

cleanup() {
rm -f /tmp/ping0
rm -f /tmp/ping2
rm -f /tmp/ping1
rm -f /tmp/Containerfile
podman stop --all
podman rm --all
podman network rm podmanbr0 || :
}
trap "cleanup 1>/dev/null" EXIT

BrennanPaciorek marked this conversation as resolved.
Show resolved Hide resolved
cat > /tmp/Containerfile << EOF
FROM quay.io/centos/centos:stream8
RUN dnf -y install systemd
RUN dnf -y install firewalld nc
EXPOSE 31337
CMD /usr/lib/systemd/systemd
EOF

# Initial container setup #
{
podman network create --subnet 172.16.1.0/24 --gateway 172.16.1.1 --interface-name podmanbr0 podmanbr0
imageid=$(podman build -q /tmp)
podman run -d --rm --rmi --privileged --net podmanbr0 --ip 172.16.1.2 --name test-firewalld "$imageid" /usr/lib/systemd/systemd
sleep 5 # Wait reasonable amount of time for container to start services

# Firewall rule setup #
podman exec test-firewalld firewall-cmd --permanent --add-icmp-block "echo-request"
# firewall-cmd reload waits for dbus response, systemctl will not
podman exec test-firewalld firewall-cmd --reload
} > /dev/null 2>/dev/null

NUM_PINGS=50
TIMEOUT=2

# The following ping should have 100% packet loss
ping -c "$NUM_PINGS" -W "$TIMEOUT" -i 0.01 172.16.1.2 1>/tmp/ping0 || :

# Begin downtime comparision #
ping -c "$NUM_PINGS" -W "$TIMEOUT" -i 0.01 172.16.1.2 1>/tmp/ping1 || : &
pid="$!"
podman exec test-firewalld systemctl reload firewalld.service
wait "$pid"

ping -c "$NUM_PINGS" -W "$TIMEOUT" -i 0.01 172.16.1.2 1>/tmp/ping2 || : &
pid="$!"
podman exec test-firewalld systemctl restart firewalld.service
wait "$pid"

# Print Results
tail -2 /tmp/ping0 | head -1 | awk '{print $4}'
BrennanPaciorek marked this conversation as resolved.
Show resolved Hide resolved
tail -2 /tmp/ping1 | head -1 | awk '{print $4}'
tail -2 /tmp/ping2 | head -1 | awk '{print $4}'

31 changes: 31 additions & 0 deletions tests/tests_reload_on_reset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- name: Setup a vm with podman on it
hosts: all
BrennanPaciorek marked this conversation as resolved.
Show resolved Hide resolved
pre_tasks:
- name: Test not supported on EL7
meta: end_host
when:
- ansible_distribution in ['RedHat', 'CentOS']
- ansible_distribution_major_version | int < 8
tasks:
- name: Install podman
package:
name: podman
state: present

- name: Run test
script:
cmd: files/test_ping.sh
executable: /bin/bash
register: test_results

- name: Process test results
vars:
coherence_check: "{{ test_results.stdout_lines[0] }}"
restart_check: "{{ test_results.stdout_lines[2] }}"
reload_check: "{{ test_results.stdout_lines[1] }}"
fail:
msg: Either coherence check or benchmark failed
when: >-
coherence_check | int != 0
or restart_check | int < reload_check | int