Skip to content

Commit

Permalink
Merge branch 'main' into helm_login
Browse files Browse the repository at this point in the history
Goal is to bring c8a33c7 into helm_login
  • Loading branch information
yurnov committed Dec 14, 2024
2 parents f13429f + c8a33c7 commit a80fb34
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 18 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/798-drain-pdb-error-message.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- k8s_drain - Improve error message for pod disruption budget when draining a node (https://github.com/ansible-collections/kubernetes.core/issues/797).
14 changes: 13 additions & 1 deletion plugins/modules/k8s_drain.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"""

import copy
import json
import time
import traceback
from datetime import datetime
Expand Down Expand Up @@ -187,6 +188,17 @@
HAS_EVICTION_API = False


def format_dynamic_api_exc(exc):
if exc.body:
if exc.headers and exc.headers.get("Content-Type") == "application/json":
message = json.loads(exc.body).get("message")
if message:
return message
return exc.body
else:
return "%s Reason: %s" % (exc.status, exc.reason)


def filter_pods(pods, force, ignore_daemonset, delete_emptydir_data):
k8s_kind_mirror = "kubernetes.io/config.mirror"
daemonSet, unmanaged, mirror, localStorage, to_delete = [], [], [], [], []
Expand Down Expand Up @@ -338,7 +350,7 @@ def evict_pods(self, pods):
if exc.reason != "Not Found":
self._module.fail_json(
msg="Failed to delete pod {0}/{1} due to: {2}".format(
namespace, name, exc.reason
namespace, name, to_native(format_dynamic_api_exc(exc))
)
)
except Exception as exc:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/helm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
loop_control:
loop_var: helm_version
with_items:
- "v3.7.0"
- "v3.8.0"
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
- name: Initial chart installation
helm:
binary_path: "{{ helm_binary }}"
chart_ref: redis
chart_repo_url: https://charts.bitnami.com/bitnami
chart_ref: oci://registry-1.docker.io/bitnamicharts/redis
release_name: test-redis
release_namespace: "{{ helm_namespace }}"
create_namespace: true
Expand All @@ -42,8 +41,7 @@
- name: Upgrade chart using reuse_values=true
helm:
binary_path: "{{ helm_binary }}"
chart_ref: redis
chart_repo_url: https://charts.bitnami.com/bitnami
chart_ref: oci://registry-1.docker.io/bitnamicharts/redis
release_name: test-redis
release_namespace: "{{ helm_namespace }}"
reuse_values: true
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/targets/helm/tasks/tests_chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@
chart_ref: "{{ chart_source }}"
chart_version: "{{ chart_source_version | default(omit) }}"
disable_hook: True
release_name: "MyRelease"
release_namespace: "MyReleaseNamespace"
release_name: "myrelease"
release_namespace: "myreleasenamespace"
show_only:
- "templates/configmap.yaml"
release_values:
Expand All @@ -388,7 +388,7 @@
- result is changed
- result is not failed
- result.rc == 0
- result.command is match(helm_binary+" template MyRelease "+chart_source)
- result.command is match(helm_binary+" template myrelease "+chart_source)
- result.stdout is search("ThisValue")
when: chart_source is search("test-chart")
# limit assertion of test result to controlled (local) chart_source
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/targets/helm_pull/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@
- name: Download chart using untar_chart
helm_pull:
binary_path: "{{ helm_path }}"
chart_ref: redis
chart_ref: "oci://registry-1.docker.io/bitnamicharts/redis"
destination: "{{ destination }}"
repo_url: "https://charts.bitnami.com/bitnami"
untar_chart: true
register: _result

Expand Down
9 changes: 3 additions & 6 deletions tests/integration/targets/helm_set_values/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
- name: Install helm using set_values parameters
helm:
binary_path: "{{ helm_binary }}"
chart_ref: mariadb
chart_repo_url: https://charts.bitnami.com/bitnami
chart_ref: oci://registry-1.docker.io/bitnamicharts/mariadb
release_name: test-mariadb
release_namespace: "{{ helm_namespace }}"
create_namespace: true
Expand Down Expand Up @@ -36,8 +35,7 @@
- name: Install helm using set_values parameters
helm:
binary_path: "{{ helm_binary }}"
chart_ref: apache
chart_repo_url: https://charts.bitnami.com/bitnami
chart_ref: oci://registry-1.docker.io/bitnamicharts/apache
release_name: test-apache
release_namespace: "{{ helm_namespace }}"
create_namespace: true
Expand Down Expand Up @@ -79,8 +77,7 @@
- name: Install helm using set_values parameters
helm:
binary_path: "{{ helm_binary }}"
chart_ref: minio
chart_repo_url: https://charts.bitnami.com/bitnami
chart_ref: oci://registry-1.docker.io/bitnamicharts/minio
release_name: test-minio
release_namespace: "{{ helm_namespace }}"
create_namespace: true
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/install_helm/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
helm_version: v3.7.0
helm_version: v3.8.0
helm_install_path: /tmp/helm
helm_default_archive_name: "helm-{{ helm_version }}-{{ ansible_system | lower }}-amd64.tar.gz"

0 comments on commit a80fb34

Please sign in to comment.