kubernetes.core icon indicating copy to clipboard operation
kubernetes.core copied to clipboard

kubernetes.core.helm does not uninstall charts in pending-install status

Open forselli-stratio opened this issue 3 years ago • 4 comments

SUMMARY

The module kubernetes.core.helm does not uninstall charts that are in a pending-install, pending-upgrade or similar STATUS

ISSUE TYPE
  • Bug Report
COMPONENT NAME

kubernetes.core.helm

ANSIBLE VERSION
ansible 2.10.11
  config file = /stratio/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.8.10 (default, May  6 2021, 00:05:59) [GCC 10.2.1 20201203]

COLLECTION VERSION
kubernetes.core    2.0.2  
community.kubernetes      1.1.1
CONFIGURATION
ANSIBLE_PIPELINING(/stratio/ansible/ansible.cfg) = True
ANSIBLE_SSH_ARGS(/stratio/ansible/ansible.cfg) = -o ControlMaster=auto -o ControlPersist=30m
ANSIBLE_SSH_RETRIES(/stratio/ansible/ansible.cfg) = 3
ANY_ERRORS_FATAL(/stratio/ansible/ansible.cfg) = True
CACHE_PLUGIN(/stratio/ansible/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/stratio/ansible/ansible.cfg) = /tmp/facts_cache
CACHE_PLUGIN_TIMEOUT(/stratio/ansible/ansible.cfg) = 7200
COLLECTIONS_PATHS(/stratio/ansible/ansible.cfg) = ['/stratio/ansible/collections']
DEFAULT_BECOME(/stratio/ansible/ansible.cfg) = True
DEFAULT_CALLBACK_PLUGIN_PATH(env: ANSIBLE_CALLBACK_PLUGINS) = ['/stratio/ansible/plugins/callback']
DEFAULT_CALLBACK_WHITELIST(/stratio/ansible/ansible.cfg) = ['keos_profile_roles', 'timer']
DEFAULT_FORKS(/stratio/ansible/ansible.cfg) = 30
DEFAULT_GATHERING(/stratio/ansible/ansible.cfg) = smart
DEFAULT_HOST_LIST(env: ANSIBLE_INVENTORY) = ['/stratio/ansible/inventory']
DEFAULT_ROLES_PATH(/stratio/ansible/ansible.cfg) = ['/stratio/ansible/roles', '/stratio/ansible/playbooks/kubespray/roles']
DEFAULT_STDOUT_CALLBACK(/stratio/ansible/ansible.cfg) = yaml
DEFAULT_TIMEOUT(/stratio/ansible/ansible.cfg) = 30
DEFAULT_VAULT_PASSWORD_FILE(env: ANSIBLE_VAULT_PASSWORD_FILE) = /root/.credentials
DEPRECATION_WARNINGS(/stratio/ansible/ansible.cfg) = False
TRANSFORM_INVALID_GROUP_CHARS(/stratio/ansible/ansible.cfg) = ignore

OS / ENVIRONMENT

NAME="Alpine Linux" ID=alpine VERSION_ID=3.13.7 PRETTY_NAME="Alpine Linux v3.13" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpinelinux.org/"

STEPS TO REPRODUCE
<15:05:15> [keos-installer:0.4.0-SNAPSHOT@keosdev2] [/workspace] # helm list -n keos-ops -a
NAME         	NAMESPACE	REVISION	UPDATED                                	STATUS         	CHART              	APP VERSION
keos-operator	keos-ops 	1       	2021-12-29 14:55:01.664330975 +0000 UTC	pending-install	keos-operator-0.4.0	0.4.0      
(reverse-i-search)`': ^C
<15:05:25> [keos-installer:0.4.0-SNAPSHOT@keosdev2] [/workspace] 130# cat /tmp/lala.yaml 
- hosts: localhost
  tasks:
  - name: "Uninstall keos-operator helm chart if its status is not deployed"
    kubernetes.core.helm:
      name: keos-operator
      release_namespace: keos-ops
      release_state: absent


  - name: Deploy keos-operator helm chart
    kubernetes.core.helm:
      name: "keos-operator"
      chart_ref: "/stratio/helm/keos-operator"
      release_namespace: "keos-ops"

<15:05:27> [keos-installer:0.4.0-SNAPSHOT@keosdev2] [/workspace] # ansible-playbook /tmp/lala.yaml 

PLAY [localhost] *****************************************************************************************************************************************************************************************************************************************************************

TASK [Uninstall keos-operator helm chart if its status is not deployed] **********************************************************************************************************************************************************************************************************
» Wednesday 29 December 2021  15:05:35 +0000 (0:00:00.197)       0:00:00.197 *** 
ok: [localhost]

TASK [Deploy keos-operator helm chart] *******************************************************************************************************************************************************************************************************************************************
» Wednesday 29 December 2021  15:05:35 +0000 (0:00:00.613)       0:00:00.810 *** 
fatal: [localhost]: FAILED! => changed=false 
  command: /usr/local/bin/helm upgrade -i --reset-values keos-operator /stratio/helm/keos-operator
  msg: |-
    Failure when executing Helm command. Exited 1.
    stdout:
    stderr: Error: UPGRADE FAILED: "keos-operator" has no deployed releases
  stderr: |-
    Error: UPGRADE FAILED: "keos-operator" has no deployed releases
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

NO MORE HOSTS LEFT ***************************************************************************************************************************************************************************************************************************************************************

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

» Wednesday 29 December 2021  15:05:36 +0000 (0:00:00.740)       0:00:01.550 *** 
=============================================================================== 
kubernetes.core.helm ---------------------------------------------------- 1.35s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
total ------------------------------------------------------------------- 1.35s
Playbook run took 0 days, 0 hours, 0 minutes, 1 seconds

EXPECTED RESULTS

Uninstall desired chart

ACTUAL RESULTS

Chart stays as pending-install, pending-upgrade or similar, and uninstall gives you and OK result.


forselli-stratio avatar Dec 29 '21 15:12 forselli-stratio

We have the same problem, chart in pending-install status will not be uninstalled, and kubernetes.core.helm_info will not show any info about this chart. Example task:

- name: "Check installed helm release"
  kubernetes.core.helm_info:
    release_name: "{{ chart_name }}"
    release_namespace: "{{ chart_namespace }}"
  register: __helm_release

Output for chart in pending-install status: ok: [localhost] => { "__helm_release": { "changed": false, "failed": false } }

I see that in get_release_status function helm list command runs without -a argument https://github.com/ansible-collections/kubernetes.core/blob/bf3fe91a5dfa6f398f74cf242836b0acc28173cf/plugins/modules/helm.py#L357 So it will not see any releases in pending status.

And in chart deletion code I see that it checks current chart status with get_release_status function https://github.com/ansible-collections/kubernetes.core/blob/bf3fe91a5dfa6f398f74cf242836b0acc28173cf/plugins/modules/helm.py#L681-L702

I suppose -a argument should be added to list_command variable to make it work as expected.

zaqwer101 avatar Feb 11 '22 10:02 zaqwer101

issue #377

LuckySB avatar Feb 11 '22 11:02 LuckySB

I find PR from 2021 year #204

LuckySB avatar Feb 18 '22 07:02 LuckySB

@Akasurde Why did you close the #381 ?

I think to solve the problem https://github.com/ansible-collections/kubernetes.core/pull/204#issuecomment-916193486 it is enough to check the status of the release, and if it is uninstalled, then just do nothing

LuckySB avatar Feb 18 '22 07:02 LuckySB

This function doesn't not seems to work with latest kubernetes.core (2.4.0) or I'm wrong ? My pending-install app was not removed when I specify release_state = absent. Is it possible to reopen this ticket ?

julien235 avatar Aug 17 '23 12:08 julien235