From bd1cacc0cf2be23f170b015e5adad0435ee7bfb8 Mon Sep 17 00:00:00 2001 From: Bikouo Aubin <79859644+abikouo@users.noreply.github.com> Date: Wed, 14 Jan 2026 09:22:31 +0100 Subject: [PATCH] address sanity issues (#1056) SUMMARY helm/helm_info - Deprecate some parameters and add new ones to resolve sanity issues. k8s - the return block doc is not aligned with what the module returns ISSUE TYPE Bugfix Pull Request COMPONENT NAME helm, helm_info, k8s Fixes: #1046 Reviewed-by: Yuriy Novostavskiy Reviewed-by: Bianca Henderson --- .../20260108-fix-sanity-failures.yml | 11 ++ plugins/modules/helm.py | 25 +++- plugins/modules/helm_info.py | 16 ++- plugins/modules/k8s.py | 54 ++++++-- .../test_helm_reset_then_reuse_values.yml | 4 +- .../helm/tasks/test_helm_reuse_values.yml | 4 +- .../targets/helm/tasks/tests_chart.yml | 14 +- .../targets/helm_set_values/tasks/main.yml | 20 +-- .../targets/k8s_apply/defaults/main.yml | 38 ------ .../targets/k8s_apply/tasks/main.yml | 124 ++++++++---------- .../k8s_copy/tasks/test_copy_directory.yml | 80 +++++------ .../k8s_copy/tasks/test_copy_large_file.yml | 10 +- .../k8s_copy/templates/pods_definition.j2 | 10 +- .../targets/k8s_delete/files/deployments.yaml | 6 +- .../targets/k8s_delete/tasks/main.yml | 2 +- .../targets/k8s_scale/defaults/main.yml | 38 ------ .../targets/k8s_scale/tasks/main.yml | 66 +++++----- .../targets/k8s_waiter/tasks/main.yml | 39 +++--- tests/sanity/ignore-2.20.txt | 3 + tests/sanity/ignore-2.21.txt | 5 + 20 files changed, 285 insertions(+), 284 deletions(-) create mode 100644 changelogs/fragments/20260108-fix-sanity-failures.yml diff --git a/changelogs/fragments/20260108-fix-sanity-failures.yml b/changelogs/fragments/20260108-fix-sanity-failures.yml new file mode 100644 index 00000000..b7d0361d --- /dev/null +++ b/changelogs/fragments/20260108-fix-sanity-failures.yml @@ -0,0 +1,11 @@ +--- +bugfixes: + - k8s - Fix return block from the module documentation (https://github.com/ansible-collections/kubernetes.core/pull/1056). +deprecated_features: + - helm - the ``status.values`` return value has been deprecated and will be removed in a release after 2027-01-08. + Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/pull/1056). + - helm_info - the ``status.values`` return value has been deprecated and will be removed in a release after 2027-01-08. + Use ``status.release_values`` instead (https://github.com/ansible-collections/kubernetes.core/pull/1056). +minor_changes: + - helm - added ``release_values`` key to ``status`` return value that can be accessed using Jinja2 dot notation (https://github.com/ansible-collections/kubernetes.core/pull/1056). + - helm_info - added ``release_values`` key to ``status`` return value that can be accessed using Jinja2 dot notation (https://github.com/ansible-collections/kubernetes.core/pull/1056). diff --git a/plugins/modules/helm.py b/plugins/modules/helm.py index 681b24db..b4602847 100644 --- a/plugins/modules/helm.py +++ b/plugins/modules/helm.py @@ -419,9 +419,18 @@ status: returned: always description: The Date of last update values: - type: str + type: dict returned: always - description: Dict of Values used to deploy + description: + - Dict of Values used to deploy. + - This return value has been deprecated and will be removed in a release after + 2027-01-08. Use RV(status.release_values) instead. + release_values: + type: dict + returned: always + description: + - Dict of Values used to deploy. + version_added: 6.3.0 stdout: type: str description: Full `helm` command stdout, in case you want to display it or examine the event log @@ -501,7 +510,8 @@ def get_release_status(module, release_name, all_status=False): if release is None: # not install return None - release["values"] = module.get_values(release_name) + release["release_values"] = module.get_values(release_name) + release["values"] = release["release_values"] return release @@ -1153,10 +1163,15 @@ def main(): changed = True if module.check_mode: - check_status = {"values": {"current": {}, "declared": {}}} + check_status = { + "values": {"current": {}, "declared": {}}, + "release_values": {"current": {}, "declared": {}}, + } if release_status: - check_status["values"]["current"] = release_status["values"] + check_status["values"]["current"] = release_status["release_values"] check_status["values"]["declared"] = release_status + check_status["release_values"]["current"] = release_status["release_values"] + check_status["release_values"]["declared"] = release_status module.exit_json( changed=changed, diff --git a/plugins/modules/helm_info.py b/plugins/modules/helm_info.py index 2e3fe6e9..a0b94e32 100644 --- a/plugins/modules/helm_info.py +++ b/plugins/modules/helm_info.py @@ -115,9 +115,18 @@ status: returned: always description: The Date of last update values: - type: str + type: dict returned: always - description: Dict of Values used to deploy + description: + - Dict of Values used to deploy + - This return value has been deprecated and will be removed in a release after + 2027-01-08. Use RV(status.release_values) instead. + release_values: + type: dict + returned: always + description: + - Dict of Values used to deploy. + version_added: 6.3.0 hooks: type: list elements: dict @@ -202,7 +211,8 @@ def get_release_status(module, release_name, release_state, get_all_values=False if release is None: # not install return None - release["values"] = module.get_values(release_name, get_all_values) + release["release_values"] = module.get_values(release_name, get_all_values) + release["values"] = release["release_values"] release["manifest"] = module.get_manifest(release_name) release["notes"] = module.get_notes(release_name) release["hooks"] = module.get_hooks(release_name) diff --git a/plugins/modules/k8s.py b/plugins/modules/k8s.py index 67985b4d..b34f59dc 100644 --- a/plugins/modules/k8s.py +++ b/plugins/modules/k8s.py @@ -383,28 +383,24 @@ result: contains: api_version: description: The versioned schema of this representation of an object. - returned: success + returned: when O(resource_definition) or O(src) contains a single object. type: str kind: description: Represents the REST resource this object represents. - returned: success + returned: when O(resource_definition) or O(src) contains a single object. type: str metadata: description: Standard object metadata. Includes name, namespace, annotations, labels, etc. - returned: success + returned: when O(resource_definition) or O(src) contains a single object. type: complex spec: description: Specific attributes of the object. Will vary based on the I(api_version) and I(kind). - returned: success + returned: when O(resource_definition) or O(src) contains a single object. type: complex status: description: Current status details for the object. - returned: success + returned: when O(resource_definition) or O(src) contains a single object. type: complex - items: - description: Returned only when multiple yaml documents are passed to src or resource_definition - returned: when resource_definition or src contains list of objects - type: list duration: description: elapsed time of task in seconds returned: when C(wait) is true @@ -414,6 +410,46 @@ result: description: error while trying to create/delete the object. returned: error type: complex + results: + description: An array of created, patched, or otherwise present objects. + returned: when O(resource_definition) or O(src) contains a list of objects. + type: complex + contains: + api_version: + description: The versioned schema of this representation of an object. + returned: when O(resource_definition) or O(src) contains a single object. + type: str + kind: + description: Represents the REST resource this object represents. + returned: when O(resource_definition) or O(src) contains a single object. + type: str + metadata: + description: Standard object metadata. Includes name, namespace, annotations, labels, etc. + returned: when O(resource_definition) or O(src) contains a single object. + type: complex + spec: + description: Specific attributes of the object. Will vary based on the I(api_version) and I(kind). + returned: when O(resource_definition) or O(src) contains a single object. + type: complex + status: + description: Current status details for the object. + returned: when O(resource_definition) or O(src) contains a single object. + type: complex + duration: + description: elapsed time of task in seconds + returned: when C(wait) is true + type: int + sample: 48 + error: + description: error while trying to create/delete the object. + returned: error + type: complex +method: + description: + - The method used to deploy the resource. + returned: success + type: str + sample: create """ import copy diff --git a/tests/integration/targets/helm/tasks/test_helm_reset_then_reuse_values.yml b/tests/integration/targets/helm/tasks/test_helm_reset_then_reuse_values.yml index 61c281ef..13c67ac9 100644 --- a/tests/integration/targets/helm/tasks/test_helm_reset_then_reuse_values.yml +++ b/tests/integration/targets/helm/tasks/test_helm_reset_then_reuse_values.yml @@ -36,7 +36,7 @@ that: - install is changed - '"--reset-then-reuse-values" not in install.command' - - release_value["status"]["values"] == chart_release_values + - release_value["status"]["release_values"] == chart_release_values - name: Upgrade chart using reset_then_reuse_values=true helm: @@ -64,7 +64,7 @@ - '"--reset-then-reuse-values" in upgrade.command' - '"--reuse-values " not in upgrade.command' - '"--reset-values" not in upgrade.command' - - release_value["status"]["values"] == chart_release_values | combine(chart_reset_then_reuse_values, recursive=true) + - release_value["status"]["release_values"] == chart_release_values | combine(chart_reset_then_reuse_values, recursive=true) always: - name: Remove helm namespace diff --git a/tests/integration/targets/helm/tasks/test_helm_reuse_values.yml b/tests/integration/targets/helm/tasks/test_helm_reuse_values.yml index 7801b485..9571c8ab 100644 --- a/tests/integration/targets/helm/tasks/test_helm_reuse_values.yml +++ b/tests/integration/targets/helm/tasks/test_helm_reuse_values.yml @@ -36,7 +36,7 @@ that: - install is changed - '"--reuse-values=True" not in install.command' - - release_value["status"]["values"] == chart_release_values + - release_value["status"]["release_values"] == chart_release_values - name: Upgrade chart using reuse_values=true helm: @@ -62,7 +62,7 @@ - upgrade is changed - '"--reuse-values=True" in upgrade.command' - '"--reset-values" not in upgrade.command' - - release_value["status"]["values"] == chart_release_values | combine(chart_reuse_values, recursive=true) + - release_value["status"]["release_values"] == chart_release_values | combine(chart_reuse_values, recursive=true) always: - name: Remove helm namespace diff --git a/tests/integration/targets/helm/tasks/tests_chart.yml b/tests/integration/targets/helm/tasks/tests_chart.yml index fda5bf85..ceac0e47 100644 --- a/tests/integration/targets/helm/tasks/tests_chart.yml +++ b/tests/integration/targets/helm/tasks/tests_chart.yml @@ -57,7 +57,7 @@ that: - install_check_mode is changed - install_check_mode.status is defined - - install_check_mode.status.values is defined + - install_check_mode.status.release_values is defined - name: "Install {{ chart_test }} from {{ source }}" helm: @@ -131,7 +131,7 @@ - install is changed - install.status.status | lower == 'deployed' - install.status.chart == chart_test+"-"+chart_test_version - - "install.status['values'].revisionHistoryLimit == 0" + - "install.status['release_values'].revisionHistoryLimit == 0" - name: Check idempotency after adding vars helm: @@ -149,7 +149,7 @@ - install is not changed - install.status.status | lower == 'deployed' - install.status.chart == chart_test+"-"+chart_test_version - - "install.status['values'].revisionHistoryLimit == 0" + - "install.status['release_values'].revisionHistoryLimit == 0" - name: "Remove Vars to {{ chart_test }} from {{ source }}" helm: @@ -166,7 +166,7 @@ - install is changed - install.status.status | lower == 'deployed' - install.status.chart == chart_test+"-"+chart_test_version - - install.status['values'] == {} + - install.status['release_values'] == {} - name: Check idempotency after removing vars helm: @@ -183,7 +183,7 @@ - install is not changed - install.status.status | lower == 'deployed' - install.status.chart == chart_test+"-"+chart_test_version - - install.status['values'] == {} + - install.status['release_values'] == {} - name: "Upgrade {{ chart_test }} from {{ source }}" helm: @@ -317,7 +317,7 @@ - install is changed - install.status.status | lower == 'deployed' - install.status.chart == chart_test+"-"+chart_test_version - - "install.status['values'].revisionHistoryLimit == 0" + - "install.status['release_values'].revisionHistoryLimit == 0" - name: "Install {{ chart_test }} from {{ source }} with values_files (again)" helm: @@ -402,7 +402,7 @@ namespace: "{{ helm_namespace }}" create_namespace: true context: does-not-exist - ignore_errors: yes + ignore_errors: true register: result - name: Assert that release fails with non-existent context diff --git a/tests/integration/targets/helm_set_values/tasks/main.yml b/tests/integration/targets/helm_set_values/tasks/main.yml index 82fad37a..e22f6f8d 100644 --- a/tests/integration/targets/helm_set_values/tasks/main.yml +++ b/tests/integration/targets/helm_set_values/tasks/main.yml @@ -20,10 +20,10 @@ - name: Assert that release was created with user-defined variables assert: that: - - '"phase" in user_values.status["values"]' - - '"versioned" in user_values.status["values"]' - - user_values.status["values"]["phase"] == "integration" - - user_values.status["values"]["versioned"] is false + - '"phase" in user_values.status["release_values"]' + - '"versioned" in user_values.status["release_values"]' + - user_values.status["release_values"]["phase"] == "integration" + - user_values.status["release_values"]["versioned"] is false # install chart using set_values and release_values - name: Install helm binary (> 3.10.0) requires to use set-json @@ -55,10 +55,10 @@ - name: Assert that release was created with user-defined variables assert: that: - - values.status["values"].replicaCount == 3 - - values.status["values"].master.image.registry == "docker.io" - - values.status["values"].master.image.repository == "bitnami/apache" - - values.status["values"].master.image.tag == "2.4.54-debian-11-r74" + - values.status["release_values"].replicaCount == 3 + - values.status["release_values"].master.image.registry == "docker.io" + - values.status["release_values"].master.image.repository == "bitnami/apache" + - values.status["release_values"].master.image.tag == "2.4.54-debian-11-r74" # install chart using set_values and values_files - name: create temporary file to save values in @@ -96,8 +96,8 @@ - name: Assert that release was created with user-defined variables assert: that: - - values.status["values"].mode == "distributed" - - values.status["values"].disableWebUI is true + - values.status["release_values"].mode == "distributed" + - values.status["release_values"].disableWebUI is true always: - name: Delete temporary file diff --git a/tests/integration/targets/k8s_apply/defaults/main.yml b/tests/integration/targets/k8s_apply/defaults/main.yml index c45a18d8..0b5a723f 100644 --- a/tests/integration/targets/k8s_apply/defaults/main.yml +++ b/tests/integration/targets/k8s_apply/defaults/main.yml @@ -1,42 +1,4 @@ --- -k8s_pod_metadata: - labels: - app: "{{ k8s_pod_name }}" - -k8s_pod_spec: - serviceAccount: "{{ k8s_pod_service_account }}" - containers: - - image: "{{ k8s_pod_image }}" - imagePullPolicy: Always - name: "{{ k8s_pod_name }}" - command: "{{ k8s_pod_command }}" - readinessProbe: - initialDelaySeconds: 15 - exec: - command: - - /bin/true - resources: "{{ k8s_pod_resources }}" - ports: "{{ k8s_pod_ports }}" - env: "{{ k8s_pod_env }}" - - -k8s_pod_service_account: default - -k8s_pod_resources: - limits: - cpu: "100m" - memory: "100Mi" - -k8s_pod_command: [] - -k8s_pod_ports: [] - -k8s_pod_env: [] - -k8s_pod_template: - metadata: "{{ k8s_pod_metadata }}" - spec: "{{ k8s_pod_spec }}" - test_namespace: "apply" k8s_wait_timeout: 240 diff --git a/tests/integration/targets/k8s_apply/tasks/main.yml b/tests/integration/targets/k8s_apply/tasks/main.yml index fb5dc9b1..6245ff71 100644 --- a/tests/integration/targets/k8s_apply/tasks/main.yml +++ b/tests/integration/targets/k8s_apply/tasks/main.yml @@ -292,36 +292,34 @@ - name: Add a deployment k8s: + namespace: "{{ test_namespace }}" definition: + definition: apiVersion: apps/v1 kind: Deployment metadata: name: apply-deploy - namespace: "{{ test_namespace }}" + labels: + app: apply-deploy spec: replicas: 1 selector: matchLabels: - app: "{{ k8s_pod_name }}" - template: "{{ k8s_pod_template }}" + app: apply-deploy + template: + metadata: + labels: + app: apply-deploy + spec: + serviceAccount: apply-deploy + containers: + - name: nginx + image: nginx:latest + ports: + - containerPort: 80 wait: yes wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" apply: yes - vars: - k8s_pod_name: apply-deploy - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-green - k8s_pod_service_account: apply-deploy - k8s_pod_ports: - - containerPort: 8080 - name: http - protocol: TCP - k8s_pod_resources: - requests: - cpu: 100m - memory: 100Mi - limits: - cpu: 100m - memory: 100Mi - name: Update the earlier deployment in check mode k8s: @@ -335,33 +333,29 @@ replicas: 1 selector: matchLabels: - app: "{{ k8s_pod_name }}" - template: "{{ k8s_pod_template }}" + app: apply-deploy + template: + metadata: + labels: + app: apply-deploy + spec: + serviceAccount: apply-deploy + containers: + - name: nginx-2 + image: nginx:latest + ports: + - containerPort: 80 wait: yes wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" apply: yes check_mode: yes - vars: - k8s_pod_name: apply-deploy - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-purple - k8s_pod_service_account: apply-deploy - k8s_pod_ports: - - containerPort: 8080 - name: http - protocol: TCP - k8s_pod_resources: - requests: - cpu: 50m - limits: - cpu: 50m - memory: 50Mi register: update_deploy_check_mode - name: Ensure check mode change took assert: that: - update_deploy_check_mode is changed - - "update_deploy_check_mode.result.spec.template.spec.containers[0].image == 'gcr.io/kuar-demo/kuard-amd64:v0.10.0-purple'" + - "update_deploy_check_mode.result.spec.template.spec.containers[0].name == 'nginx-2'" - name: Update the earlier deployment k8s: @@ -375,32 +369,28 @@ replicas: 1 selector: matchLabels: - app: "{{ k8s_pod_name }}" - template: "{{ k8s_pod_template }}" + app: apply-deploy + template: + metadata: + labels: + app: apply-deploy + spec: + serviceAccount: apply-deploy + containers: + - name: nginx-2 + image: nginx:latest + ports: + - containerPort: 80 wait: yes wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" apply: yes - vars: - k8s_pod_name: apply-deploy - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-purple - k8s_pod_service_account: apply-deploy - k8s_pod_ports: - - containerPort: 8080 - name: http - protocol: TCP - k8s_pod_resources: - requests: - cpu: 50m - limits: - cpu: 50m - memory: 50Mi register: update_deploy_for_real - name: Ensure change took assert: that: - update_deploy_for_real is changed - - "update_deploy_for_real.result.spec.template.spec.containers[0].image == 'gcr.io/kuar-demo/kuard-amd64:v0.10.0-purple'" + - "update_deploy_for_real.result.spec.template.spec.containers[0].name == 'nginx-2'" - name: Remove the serviceaccount k8s: @@ -424,27 +414,23 @@ replicas: 1 selector: matchLabels: - app: "{{ k8s_pod_name }}" - template: "{{ k8s_pod_template }}" + app: apply-deploy + template: + metadata: + labels: + app: apply-deploy + spec: + serviceAccount: apply-deploy + containers: + - name: nginx-3 + image: nginx:latest + ports: + - containerPort: 80 wait: yes wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" apply: yes - vars: - k8s_pod_name: apply-deploy - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-green - k8s_pod_service_account: apply-deploy - k8s_pod_ports: - - containerPort: 8080 - name: http - protocol: TCP - k8s_pod_resources: - requests: - cpu: 50m - limits: - cpu: 50m - memory: 50Mi + ignore_errors: true register: deploy_after_serviceaccount_removal - ignore_errors: yes - name: Ensure that updating deployment after service account removal failed assert: diff --git a/tests/integration/targets/k8s_copy/tasks/test_copy_directory.yml b/tests/integration/targets/k8s_copy/tasks/test_copy_directory.yml index ed2ad85d..7aecf3f5 100644 --- a/tests/integration/targets/k8s_copy/tasks/test_copy_directory.yml +++ b/tests/integration/targets/k8s_copy/tasks/test_copy_directory.yml @@ -69,49 +69,51 @@ ignore_errors: true register: _result - - name: Validate that 'find' executable is missing from Pod - assert: - that: - - _result is failed - fail_msg: "Pod contains 'find' executable, therefore we cannot run the next tasks." + # - name: Validate that 'find' executable is missing from Pod + # assert: + # that: + # - _result is failed + # fail_msg: "Pod contains 'find' executable, therefore we cannot run the next tasks." - - name: Copy files into container - k8s_cp: - namespace: "{{ copy_namespace }}" - pod: '{{ pod_without_executable_find.name }}' - remote_path: '{{ item.path }}' - content: '{{ item.content }}' - state: to_pod - with_items: - - path: /ansible/root.txt - content: this file is located at the root directory - - path: /ansible/.hidden_root.txt - content: this hidden file is located at the root directory - - path: /ansible/.sudir/root.txt - content: this file is located at the root of the sub directory - - path: /ansible/.sudir/.hidden_root.txt - content: this hidden file is located at the root of the sub directory + - name: Copy directory into Pod without 'find' executable + block: + - name: Copy files into container + k8s_cp: + namespace: "{{ copy_namespace }}" + pod: '{{ pod_without_executable_find.name }}' + remote_path: '{{ item.path }}' + content: '{{ item.content }}' + state: to_pod + with_items: + - path: /ansible/root.txt + content: this file is located at the root directory + - path: /ansible/.hidden_root.txt + content: this hidden file is located at the root directory + - path: /ansible/.sudir/root.txt + content: this file is located at the root of the sub directory + - path: /ansible/.sudir/.hidden_root.txt + content: this hidden file is located at the root of the sub directory - - name: Delete existing directory - file: - path: /tmp/openjdk-files - state: absent - ignore_errors: true + - name: Delete existing directory + file: + path: /tmp/openjdk-files + state: absent + ignore_errors: true - - name: copy directory from Pod into local filesystem (new directory to create) - k8s_cp: - namespace: '{{ copy_namespace }}' - pod: '{{ pod_without_executable_find.name }}' - remote_path: /ansible - local_path: /tmp/openjdk-files - state: from_pod + - name: copy directory from Pod into local filesystem (new directory to create) + k8s_cp: + namespace: '{{ copy_namespace }}' + pod: '{{ pod_without_executable_find.name }}' + remote_path: /ansible + local_path: /tmp/openjdk-files + state: from_pod - - name: Compare directories - kubectl_file_compare: - namespace: '{{ copy_namespace }}' - pod: '{{ pod_without_executable_find.name }}' - remote_path: /ansible - local_path: /tmp/openjdk-files + - name: Compare directories + kubectl_file_compare: + namespace: '{{ copy_namespace }}' + pod: '{{ pod_without_executable_find.name }}' + remote_path: /ansible + local_path: /tmp/openjdk-files always: - name: Remove directories created into remote Pod diff --git a/tests/integration/targets/k8s_copy/tasks/test_copy_large_file.yml b/tests/integration/targets/k8s_copy/tasks/test_copy_large_file.yml index 27d4050a..99e81ee2 100644 --- a/tests/integration/targets/k8s_copy/tasks/test_copy_large_file.yml +++ b/tests/integration/targets/k8s_copy/tasks/test_copy_large_file.yml @@ -10,9 +10,13 @@ path: "{{ test_directory }}" state: directory - - name: Create a large text file - ansible.builtin.shell: - cmd: base64 /dev/random | head -c 150M > {{ test_directory }}/large_text_file.txt + - name: Create a text file with specific content + ansible.builtin.copy: + dest: "{{ test_directory }}/large_text_file.txt" + content: | + This is a large text file + {{ 'Repeat this line 1000 times\n' * 1000 }} + mode: '0644' - name: Create a large binary file ansible.builtin.command: diff --git a/tests/integration/targets/k8s_copy/templates/pods_definition.j2 b/tests/integration/targets/k8s_copy/templates/pods_definition.j2 index ee6c6f65..2105bf7a 100644 --- a/tests/integration/targets/k8s_copy/templates/pods_definition.j2 +++ b/tests/integration/targets/k8s_copy/templates/pods_definition.j2 @@ -6,7 +6,7 @@ metadata: spec: containers: - name: '{{ pod_with_one_container.container }}' - image: busybox + image: busybox:latest command: - /bin/sh - -c @@ -19,13 +19,13 @@ metadata: spec: containers: - name: '{{ pod_with_two_container.container[0] }}' - image: busybox:1.32.0 + image: busybox:latest command: - /bin/sh - -c - while true;do date;sleep 5; done - name: '{{ pod_with_two_container.container[1] }}' - image: busybox:1.33.0 + image: busybox:latest command: - /bin/sh - -c @@ -37,8 +37,8 @@ metadata: name: '{{ pod_without_executable_find.name }}' spec: containers: - - name: openjdk17 - image: openjdk:17 + - name: openjdk + image: openjdk:27-ea command: - /bin/sh - -c diff --git a/tests/integration/targets/k8s_delete/files/deployments.yaml b/tests/integration/targets/k8s_delete/files/deployments.yaml index 594d4522..230caa77 100644 --- a/tests/integration/targets/k8s_delete/files/deployments.yaml +++ b/tests/integration/targets/k8s_delete/files/deployments.yaml @@ -24,7 +24,7 @@ spec: apiVersion: apps/v1 kind: Deployment metadata: - name: openjdk-d + name: busybox-d labels: context: ansible spec: @@ -38,8 +38,8 @@ spec: context: ansible spec: containers: - - name: openjdk - image: openjdk:17 + - name: busybox + image: busybox:latest command: - /bin/sh - -c diff --git a/tests/integration/targets/k8s_delete/tasks/main.yml b/tests/integration/targets/k8s_delete/tasks/main.yml index a0bdafe1..1cbecc09 100644 --- a/tests/integration/targets/k8s_delete/tasks/main.yml +++ b/tests/integration/targets/k8s_delete/tasks/main.yml @@ -17,7 +17,7 @@ wait_timeout: 400 vars: k8s_pod_name: delete-ds - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1 + k8s_pod_image: docker.io/nginx:latest register: ds - name: Check that daemonset wait worked diff --git a/tests/integration/targets/k8s_scale/defaults/main.yml b/tests/integration/targets/k8s_scale/defaults/main.yml index 5089314b..2b77fbfd 100644 --- a/tests/integration/targets/k8s_scale/defaults/main.yml +++ b/tests/integration/targets/k8s_scale/defaults/main.yml @@ -1,42 +1,4 @@ --- -k8s_pod_metadata: - labels: - app: "{{ k8s_pod_name }}" - -k8s_pod_spec: - serviceAccount: "{{ k8s_pod_service_account }}" - containers: - - image: "{{ k8s_pod_image }}" - imagePullPolicy: Always - name: "{{ k8s_pod_name }}" - command: "{{ k8s_pod_command }}" - readinessProbe: - initialDelaySeconds: 15 - exec: - command: - - /bin/true - resources: "{{ k8s_pod_resources }}" - ports: "{{ k8s_pod_ports }}" - env: "{{ k8s_pod_env }}" - - -k8s_pod_service_account: default - -k8s_pod_resources: - limits: - cpu: "100m" - memory: "100Mi" - -k8s_pod_command: [] - -k8s_pod_ports: [] - -k8s_pod_env: [] - -k8s_pod_template: - metadata: "{{ k8s_pod_metadata }}" - spec: "{{ k8s_pod_spec }}" - test_namespace: "scale" k8s_wait_timeout: 400 diff --git a/tests/integration/targets/k8s_scale/tasks/main.yml b/tests/integration/targets/k8s_scale/tasks/main.yml index bce2e79b..bfcb90d9 100644 --- a/tests/integration/targets/k8s_scale/tasks/main.yml +++ b/tests/integration/targets/k8s_scale/tasks/main.yml @@ -5,28 +5,32 @@ - name: Add a deployment k8s: + namespace: "{{ scale_namespace }}" definition: apiVersion: apps/v1 kind: Deployment metadata: name: scale-deploy - namespace: "{{ scale_namespace }}" + labels: + app: scale-deploy spec: replicas: 1 selector: matchLabels: - app: "{{ k8s_pod_name }}" - template: "{{ k8s_pod_template }}" - wait: yes + app: scale-deploy + template: + metadata: + labels: + app: scale-deploy + spec: + containers: + - name: nginx + image: nginx:latest + ports: + - containerPort: 80 + wait: true wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" - apply: yes - vars: - k8s_pod_name: scale-deploy - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-green - k8s_pod_ports: - - containerPort: 8080 - name: http - protocol: TCP + apply: true - name: Get pods in scale-deploy k8s_info: @@ -44,7 +48,7 @@ name: scale-deploy namespace: "{{ scale_namespace }}" replicas: 0 - wait: yes + wait: true register: scale_down check_mode: true @@ -75,7 +79,7 @@ name: scale-deploy namespace: "{{ scale_namespace }}" replicas: 0 - wait: yes + wait: true register: scale_down check_mode: true @@ -106,7 +110,7 @@ name: scale-deploy namespace: "{{ scale_namespace }}" replicas: 0 - wait: yes + wait: true wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" register: scale_down diff: true @@ -138,7 +142,7 @@ name: scale-deploy namespace: "{{ scale_namespace }}" replicas: 0 - wait: yes + wait: true register: scale_down_idempotency diff: true @@ -159,18 +163,20 @@ replicas: 1 selector: matchLabels: - app: "{{ k8s_pod_name }}" - template: "{{ k8s_pod_template }}" - wait: yes + app: scale-deploy + template: + metadata: + labels: + app: scale-deploy + spec: + containers: + - name: nginx + image: nginx:latest + ports: + - containerPort: 80 + wait: true wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" - apply: yes - vars: - k8s_pod_name: scale-deploy - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:v0.10.0-green - k8s_pod_ports: - - containerPort: 8080 - name: http - protocol: TCP + apply: true register: reapply_after_scale - name: Get pods in scale-deploy @@ -199,7 +205,7 @@ wait: yes wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" register: scale_up - diff: no + diff: false - name: Get pods in scale-deploy k8s_info: @@ -228,7 +234,7 @@ replicas: 2 wait: yes register: scale_up_noop - diff: no + diff: false - name: Get pods in scale-deploy k8s_info: @@ -255,7 +261,7 @@ name: scale-deploy namespace: "{{ scale_namespace }}" replicas: 1 - wait: no + wait: false register: scale_down_no_wait diff: true diff --git a/tests/integration/targets/k8s_waiter/tasks/main.yml b/tests/integration/targets/k8s_waiter/tasks/main.yml index 3bfb668b..62dec76d 100644 --- a/tests/integration/targets/k8s_waiter/tasks/main.yml +++ b/tests/integration/targets/k8s_waiter/tasks/main.yml @@ -40,7 +40,7 @@ wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" vars: k8s_pod_name: wait-ds - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1 + k8s_pod_image: docker.io/busybox:latest k8s_pod_command: - sleep - "600" @@ -71,7 +71,7 @@ wait_timeout: 180 vars: k8s_pod_name: wait-ds - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2 + k8s_pod_image: docker.io/alpine:latest k8s_pod_command: - sleep - "600" @@ -82,7 +82,7 @@ assert: that: - update_ds_check_mode is changed - - "update_ds_check_mode.result.spec.template.spec.containers[0].image == 'gcr.io/kuar-demo/kuard-amd64:2'" + - "update_ds_check_mode.result.spec.template.spec.containers[0].image == 'docker.io/alpine:latest'" - name: Update a daemonset k8s: @@ -104,7 +104,7 @@ wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" vars: k8s_pod_name: wait-ds - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:3 + k8s_pod_image: docker.io/busybox:latest k8s_pod_command: - sleep - "600" @@ -125,7 +125,7 @@ assert: that: - ds.result.status.currentNumberScheduled == ds.result.status.desiredNumberScheduled - - updated_ds_pods.resources[0].spec.containers[0].image.endswith(":3") + - updated_ds_pods.resources[0].spec.containers[0].image == 'docker.io/busybox:latest' - name: Create daemonset with nodeSelector and not existing label k8s: @@ -145,7 +145,7 @@ wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" vars: k8s_pod_name: wait-daemonset-not-existing-label - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1 + k8s_pod_image: docker.io/busybox:latest k8s_pod_command: - sleep - "600" @@ -187,7 +187,7 @@ wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" vars: k8s_pod_name: wait-sts - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1 + k8s_pod_image: docker.io/busybox:latest k8s_pod_command: - sleep - "600" @@ -251,7 +251,7 @@ wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" vars: k8s_pod_name: wait-sts - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:3 + k8s_pod_image: docker.io/alpine:latest k8s_pod_command: - sleep - "600" @@ -272,7 +272,7 @@ assert: that: - sts.result.spec.replicas == sts.result.status.readyReplicas - - updated_sts_pods.resources[0].spec.containers[0].image.endswith(":3") + - updated_sts_pods.resources[0].spec.containers[0].image == 'docker.io/alpine:latest' - name: Add a crashing pod k8s: @@ -288,11 +288,11 @@ wait_timeout: 30 vars: k8s_pod_name: wait-crash-pod - k8s_pod_image: alpine:3.8 + k8s_pod_image: busybox:latest k8s_pod_command: - /bin/false register: crash_pod - ignore_errors: yes + ignore_errors: true - name: Check that task failed assert: @@ -315,7 +315,7 @@ k8s_pod_name: wait-no-image-pod k8s_pod_image: i_made_this_up:and_this_too register: no_image_pod - ignore_errors: yes + ignore_errors: true - name: Check that task failed assert: @@ -340,12 +340,11 @@ wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" vars: k8s_pod_name: wait-deploy - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1 + k8s_pod_image: docker.io/nginx:latest k8s_pod_ports: - containerPort: 8080 name: http protocol: TCP - register: deploy - name: Check that deployment wait worked @@ -371,7 +370,7 @@ wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" vars: k8s_pod_name: wait-deploy - k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2 + k8s_pod_image: docker.io/nginx:stable-alpine k8s_pod_ports: - containerPort: 8080 name: http @@ -394,7 +393,7 @@ field_selectors: - status.phase=Running register: updated_deploy_pods - until: updated_deploy_pods.resources[0].spec.containers[0].image.endswith(':2') + until: updated_deploy_pods.resources[0].spec.containers[0].image == 'docker.io/nginx:stable-alpine' retries: 6 delay: 5 @@ -474,11 +473,11 @@ wait_timeout: "{{ k8s_wait_timeout | default(omit) }}" vars: k8s_pod_name: wait-crash-deploy - k8s_pod_image: alpine:3.8 + k8s_pod_image: docker.io/nginx:latest k8s_pod_command: - /bin/false register: wait_crash_deploy - ignore_errors: yes + ignore_errors: true - name: Check that task failed assert: @@ -495,7 +494,7 @@ wait: yes wait_sleep: 2 wait_timeout: 5 - ignore_errors: yes + ignore_errors: true register: short_wait_remove_pod - name: Check that task failed @@ -509,4 +508,4 @@ kind: Namespace name: "{{ wait_namespace }}" state: absent - ignore_errors: yes + ignore_errors: true diff --git a/tests/sanity/ignore-2.20.txt b/tests/sanity/ignore-2.20.txt index d6216adf..2bd89903 100644 --- a/tests/sanity/ignore-2.20.txt +++ b/tests/sanity/ignore-2.20.txt @@ -1,12 +1,15 @@ plugins/module_utils/client/discovery.py import-3.11!skip plugins/module_utils/client/discovery.py import-3.12!skip plugins/module_utils/client/discovery.py import-3.13!skip +plugins/module_utils/client/discovery.py import-3.14!skip plugins/module_utils/client/resource.py import-3.11!skip plugins/module_utils/client/resource.py import-3.12!skip plugins/module_utils/client/resource.py import-3.13!skip +plugins/module_utils/client/resource.py import-3.14!skip plugins/module_utils/k8sdynamicclient.py import-3.11!skip plugins/module_utils/k8sdynamicclient.py import-3.12!skip plugins/module_utils/k8sdynamicclient.py import-3.13!skip +plugins/module_utils/k8sdynamicclient.py import-3.14!skip plugins/module_utils/version.py pylint!skip plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc diff --git a/tests/sanity/ignore-2.21.txt b/tests/sanity/ignore-2.21.txt index d6216adf..35967e23 100644 --- a/tests/sanity/ignore-2.21.txt +++ b/tests/sanity/ignore-2.21.txt @@ -1,12 +1,15 @@ plugins/module_utils/client/discovery.py import-3.11!skip plugins/module_utils/client/discovery.py import-3.12!skip plugins/module_utils/client/discovery.py import-3.13!skip +plugins/module_utils/client/discovery.py import-3.14!skip plugins/module_utils/client/resource.py import-3.11!skip plugins/module_utils/client/resource.py import-3.12!skip plugins/module_utils/client/resource.py import-3.13!skip +plugins/module_utils/client/resource.py import-3.14!skip plugins/module_utils/k8sdynamicclient.py import-3.11!skip plugins/module_utils/k8sdynamicclient.py import-3.12!skip plugins/module_utils/k8sdynamicclient.py import-3.13!skip +plugins/module_utils/k8sdynamicclient.py import-3.14!skip plugins/module_utils/version.py pylint!skip plugins/modules/k8s.py validate-modules:parameter-type-not-in-doc plugins/modules/k8s_scale.py validate-modules:parameter-type-not-in-doc @@ -29,3 +32,5 @@ plugins/modules/k8s_taint.py validate-modules:return-syntax-error tests/integration/targets/helm_diff/files/test-chart-reuse-values/templates/configmap.yaml yamllint!skip tests/integration/targets/helm_registry_auth/tasks/main.yaml yamllint!skip tests/integration/targets/helm_diff/files/test-chart-deployment-time/templates/configmap.yaml yamllint!skip +plugins/modules/helm.py validate-modules:bad-return-value-key +plugins/modules/helm_info.py validate-modules:bad-return-value-key