mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-26 21:33:02 +00:00
This is a backport of PR #905 as merged into main (d329e7e).
This PR is a rebase of #898 for CI to pass
Thanks @efussi for your collaboration.
Closes #892
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Bikouo Aubin
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
---
|
||||
bugfixes:
|
||||
- module_utils/k8s/service - fix issue when trying to delete resource using `delete_options` and `check_mode=true` (https://github.com/ansible-collections/kubernetes.core/issues/892).
|
||||
@@ -476,7 +476,7 @@ class K8sService:
|
||||
if label_selectors:
|
||||
params["label_selector"] = ",".join(label_selectors)
|
||||
|
||||
if delete_options:
|
||||
if delete_options and not self.module.check_mode:
|
||||
body = {
|
||||
"apiVersion": "v1",
|
||||
"kind": "DeleteOptions",
|
||||
|
||||
@@ -152,6 +152,27 @@
|
||||
register: _deployment
|
||||
failed_when: _deployment.resources | length == 0
|
||||
|
||||
- name: Trying to delete nginx deployment in check mode and with deleteOptions set
|
||||
k8s:
|
||||
kind: Deployment
|
||||
api_version: apps/v1
|
||||
namespace: "{{ test_namespace }}"
|
||||
name: nginx-d
|
||||
state: absent
|
||||
delete_options:
|
||||
propagationPolicy: Foreground
|
||||
check_mode: true
|
||||
register: _delete
|
||||
|
||||
- name: Validate that Deployment nginx-d still exists
|
||||
k8s_info:
|
||||
kind: Deployment
|
||||
api_version: apps/v1
|
||||
namespace: "{{ test_namespace }}"
|
||||
name: nginx-d
|
||||
register: _deployment
|
||||
failed_when: _deployment.resources | length != 1
|
||||
|
||||
- name: Trying to delete using delete_all=true but missing kind option
|
||||
k8s:
|
||||
api_version: apps/v1
|
||||
|
||||
Reference in New Issue
Block a user