fix multiple issues with dry_run logic (#561)

fix multiple issues with dry_run logic

SUMMARY

Fix multiple issues with dry_run logic

The parameter value passed to the client set to dry_run=All instead of dry_run=True.
Add conditional check for Kubernetes release for the dry_run to be set
Add integration test that checks to ensure server side dry run is being used during check mode.


ISSUE TYPE


Bugfix Pull Request

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Jill R <None>
This commit is contained in:
Bikouo Aubin
2023-01-11 08:57:39 +01:00
committed by GitHub
parent 0b4fda7585
commit 26cd550bc0
9 changed files with 89 additions and 22 deletions

View File

@@ -267,6 +267,8 @@ class K8SClient:
If there is a need for other methods or attributes to be proxied, they can be added here.
"""
K8S_SERVER_DRY_RUN = "All"
def __init__(self, configuration, client, dry_run: bool = False) -> None:
self.configuration = configuration
self.client = client
@@ -305,7 +307,7 @@ class K8SClient:
def _ensure_dry_run(self, params: Dict) -> Dict:
if self.dry_run:
params["dry_run"] = True
params["dry_run"] = self.K8S_SERVER_DRY_RUN
return params
def validate(
@@ -354,8 +356,8 @@ def get_api_client(module=None, **kwargs: Optional[Any]) -> K8SClient:
raise CoreException(msg) from e
dry_run = False
if module:
dry_run = module.params.get("dry_run", False)
if module and module.server_side_dry_run:
dry_run = True
k8s_client = K8SClient(
configuration=configuration,