fix(molecule): verify embedded flannel instead of a flannel DaemonSet

- K3s 1.36 runs flannel embedded in the k3s agent rather than as a
  kube-flannel-ds DaemonSet, so the flannel verifier queried a workload
  that no longer exists and failed the verify step
- For the flannel scenarios, assert every node is Ready and that neither
  the Calico nor the Cilium namespace exists
- Drop the now-invalid kube-flannel-ds DaemonSet assertion
This commit is contained in:
Timothy Stewart committed 2026-08-01 23:49:25 -05:00
1 parent 869a7ccbd3
commit 32139707ca
1 file changed
+24 -20
@@ -27,39 +27,43 @@
- name: Verify Flannel is the active CNI - name: Verify Flannel is the active CNI
when: verify_cni == 'flannel' when: verify_cni == 'flannel'
block: block:
- name: Get the Flannel DaemonSet - name: Assert every node reports Ready
kubernetes.core.k8s_info:
kind: DaemonSet
name: kube-flannel-ds
namespace: kube-flannel
kubeconfig: "{{ kubecfg_path }}"
register: flannel_ds
- name: Assert the Flannel DaemonSet is scheduled and Ready
ansible.builtin.assert: ansible.builtin.assert:
that: that: item.status.conditions
- flannel_ds.resources | length == 1 | selectattr('type', 'equalto', 'Ready')
- flannel_ds.resources[0].status.desiredNumberScheduled > 0 | map(attribute='status') | first | default('') == 'True'
- flannel_ds.resources[0].status.numberReady == flannel_ds.resources[0].status.desiredNumberScheduled success_msg: "{{ item.metadata.name }} is Ready"
success_msg: "Flannel DaemonSet is Ready" fail_msg: "{{ item.metadata.name }} is not Ready"
fail_msg: "Flannel DaemonSet is not fully Ready" loop: "{{ verify_nodes.resources }}"
loop_control:
label: "{{ item.metadata.name }} ready"
- name: Verify there is no incompatible CNI with Flannel
when: verify_cni == 'flannel'
block:
- name: Get any Calico namespaces with Flannel enabled - name: Get any Calico namespaces with Flannel enabled
kubernetes.core.k8s_info: kubernetes.core.k8s_info:
kind: Namespace kind: Namespace
name: calico-system name: calico-system
kubeconfig: "{{ kubecfg_path }}" kubeconfig: "{{ kubecfg_path }}"
register: calico_absent register: flannel_calico_absent
- name: Assert there is no Calico system namespace - name: Assert there is no Calico system namespace
ansible.builtin.assert: ansible.builtin.assert:
that: calico_absent.resources | length == 0 that: flannel_calico_absent.resources | length == 0
success_msg: "No Calico present with Flannel" success_msg: "No Calico present with Flannel"
fail_msg: "A Calico namespace exists alongside Flannel" fail_msg: "A Calico namespace exists alongside Flannel"
- name: Get the Cilium namespace with Flannel enabled
kubernetes.core.k8s_info:
kind: Namespace
name: cilium
kubeconfig: "{{ kubecfg_path }}"
register: flannel_cilium
- name: Assert the Cilium namespace is absent
ansible.builtin.assert:
that: flannel_cilium.resources | length == 0
success_msg: "No Cilium present with Flannel"
fail_msg: "A Cilium namespace exists alongside Flannel"
- name: Verify Calico is the active CNI - name: Verify Calico is the active CNI
when: verify_cni == 'calico' when: verify_cni == 'calico'
block: block: