fix(k8s,service): Hide fields first before creating diffs (#915) (#963)

This is a backport of PR #915 as merged into main (6a0635a).
SUMMARY

By hiding fields first before creating a diff hidden fields will not be shown in the resulting diffs and therefore will also not trigger the changed condition.
The issue can only be reproduced when a mutating webhook changes the object while the kubernetes.core.k8s module is working with it.

kubevirt/kubevirt.core#145
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

kubernetes.core.module_utils.k8s.service
ADDITIONAL INFORMATION


Run kubernetes.core.k8s and create object with hidden fields. After run kubernetes.core.k8s again and let a webhook mutate the object that the module is working with. The module should return with changed: no.

Reviewed-by: Alina Buzachis
This commit is contained in:
patchback[bot]
2025-08-04 18:03:21 +00:00
committed by GitHub
parent 7f69aff0d6
commit 92e1f581fe
3 changed files with 8 additions and 8 deletions

View File

@@ -58,7 +58,7 @@
- "'managedFields' not in hf4.resources[0]['metadata']"
- name: Hiding a changed field should still result in a change
- name: Hiding a changed field should not result in a change
k8s:
definition: "{{ hide_fields_base_configmap | combine({'data':{'hello':'different'}}) }}"
hidden_fields:
@@ -67,10 +67,10 @@
register: hf5
diff: true
- name: Ensure that hidden changed field changed
- name: Ensure that hidden changed field not changed
assert:
that:
- hf5.changed
- not hf5.changed
- name: Apply works with hidden fields
k8s: