Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
forselli-stratio opened this issue Dec 29, 2021 · 5 comments · Fixed by #589
Closed

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

forselli-stratio opened this issue Dec 29, 2021 · 5 comments · Fixed by #589
Labels
has_pr topic/helm Issues relating to helm plugins type/bug Something isn't working

Comments

@forselli-stratio
Copy link

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.


@zaqwer101
Copy link

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

list_command = command + " list --output=yaml --filter " + release_name

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

release_status = get_release_status(module, helm_cmd_common, release_name)
# keep helm_cmd_common for get_release_status in module_exit_json
helm_cmd = helm_cmd_common
opt_result = {}
if release_state == "absent" and release_status is not None:
if replace:
module.fail_json(msg="replace is not applicable when state is absent")
if wait:
helm_version = get_helm_version(module, helm_cmd_common)
if LooseVersion(helm_version) < LooseVersion("3.7.0"):
opt_result["warnings"] = []
opt_result["warnings"].append(
"helm uninstall support option --wait for helm release >= 3.7.0"
)
wait = False
helm_cmd = delete(
helm_cmd, release_name, purge, disable_hook, wait, wait_timeout
)
changed = True

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

@LuckySB
Copy link

LuckySB commented Feb 11, 2022

issue #377

Akasurde added a commit to Akasurde/kubernetes.core that referenced this issue Feb 15, 2022
While performing uninstall, list all releases to gather information
about them.

Fixes: ansible-collections#319

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/kubernetes.core that referenced this issue Feb 15, 2022
While performing uninstall, list all releases to gather information
about them.

Fixes: ansible-collections#319

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@LuckySB
Copy link

LuckySB commented Feb 18, 2022

I find PR from 2021 year #204

@LuckySB
Copy link

LuckySB commented Feb 18, 2022

@Akasurde Why did you close the #381 ?

I think to solve the problem #204 (comment)
it is enough to check the status of the release, and if it is uninstalled, then just do nothing

@gravesm gravesm added topic/helm Issues relating to helm plugins type/bug Something isn't working and removed needs_verify labels Feb 22, 2022
@abikouo abikouo added the has_pr label Feb 21, 2023
softwarefactory-project-zuul bot pushed a commit that referenced this issue Mar 6, 2023
…leases (#589)

[helm] add the ability for the module to uninstall pending-install releases

SUMMARY

closes #319

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

helm

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Bikouo Aubin
@julien235
Copy link

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has_pr topic/helm Issues relating to helm plugins type/bug Something isn't working
Projects
None yet
6 participants