mirror of
https://github.com/techno-tim/k3s-ansible.git
synced 2026-10-23 04:12:03 +02:00
fix(k3s_server): skip k3s-init log collection when the destination is unset (#721)
* fix(k3s_server): skip k3s-init log collection when the destination is unset
The guard on the k3s-init diagnostics include used a boolean default for
the ANSIBLE_K3S_LOG_DIR lookup so that the when conditional would be a real
boolean. That is unnecessary: `log_destination | default('') != ''` is a
comparison and always evaluates to a bool, so ansible-core 2.19 never sees
a non-boolean conditional here.
The boolean default also defeats the guard. With ANSIBLE_K3S_LOG_DIR unset,
log_destination is the bool False, and `False != ''` is True in Python
because False == 0. The include therefore runs on every provisioning run,
executing the journalctl, systemctl, ip, ss, iptables, service_facts, ping
and wait_for diagnostics in fetch_k3s_init_logs.yml, then creating a
directory literally named "False" in the operator's working directory.
Use an empty-string default so the unset case renders "" and the guard
skips. CI did not catch this because .github/workflows/test.yml always
exports ANSIBLE_K3S_LOG_DIR.
Add a regression test that parses the role, renders the real log_destination
expression for both the unset and set cases, and asserts that no boolean
default has been reintroduced.
* chore(site): wrap the over-long kubeconfig fetch conditional
This commit is contained in:
1 parent
1b994f7479
commit
377687cbbe
4 files changed
+129
-6
No files matched your search
@@ -64,6 +64,12 @@ repos:
|
||||
language: system
|
||||
pass_filenames: false
|
||||
files: ^roles/k3s_server/tasks/(main|join_master)\.yml$|^\.github/scripts/test-k3s-server-bootstrap\.sh$
|
||||
- id: k3s-init-log-destination-test
|
||||
name: K3s init log destination test
|
||||
entry: .github/scripts/test-k3s-init-log-destination.py
|
||||
language: system
|
||||
pass_filenames: false
|
||||
files: ^roles/k3s_server/tasks/main\.yml$|^\.github/scripts/test-k3s-init-log-destination\.py$
|
||||
- id: unique-hostname-precheck-test
|
||||
name: Unique hostname precheck test
|
||||
entry: .github/scripts/test-unique-hostname-precheck.sh
|
||||
|
||||
Reference in new issue
Block a user