mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-05-06 13:02:37 +00:00
This is a backport of PR #1033 as merged into main (3e32c12).
SUMMARY
Using exit_json or fail_json for warnings is deprecated in ansible-core>=2.19.0 and will be removed in ansible-core>=2.23.0
Tested with ansible-core 2.19.3 as the latest released version at the time of the start of this PR and with 2.16.0 as the lowest version supported by kubernetes.core 6.x
Resolves: #1031
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
k8s_drain
k8s_rollback
k8s_scale
ADDITIONAL INFORMATION
The initial version of this PR covers only the module k8s_drain, with the following commits extended to k8s_rollback
k8s_scale
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
Reviewed-by: Mike Graves <mgraves@redhat.com>
This commit is contained in:
@@ -441,7 +441,8 @@ class K8sDrainAnsible(object):
|
||||
warnings.append(warn)
|
||||
result.append("{0} Pod(s) deleted from node.".format(number_pod))
|
||||
if warnings:
|
||||
return dict(result=" ".join(result), warnings=warnings)
|
||||
for warning in warnings:
|
||||
self._module.warn(warning)
|
||||
return dict(result=" ".join(result))
|
||||
|
||||
def patch_node(self, unschedulable):
|
||||
|
||||
@@ -168,7 +168,9 @@ def perform_action(svc, resource):
|
||||
module.params["kind"],
|
||||
resource["metadata"]["name"],
|
||||
)
|
||||
result = {"changed": False, "warnings": [warn]}
|
||||
if warn:
|
||||
module.warn(warn)
|
||||
result = {"changed": False}
|
||||
return result
|
||||
|
||||
if module.params["kind"] == "Deployment":
|
||||
|
||||
@@ -243,10 +243,12 @@ def execute_module(client, module):
|
||||
module.fail_json(msg=error, **return_attributes)
|
||||
|
||||
def _continue_or_exit(warn):
|
||||
if warn:
|
||||
module.warn(warn)
|
||||
if multiple_scale:
|
||||
return_attributes["results"].append({"warning": warn, "changed": False})
|
||||
return_attributes["results"].append({"changed": False})
|
||||
else:
|
||||
module.exit_json(warning=warn, **return_attributes)
|
||||
module.exit_json(**return_attributes)
|
||||
|
||||
for existing in existing_items:
|
||||
if kind.lower() == "job":
|
||||
|
||||
Reference in New Issue
Block a user