Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Unable to remove older installations after upgrade to HDP 3.0.1

avatar
New Contributor

I've tried the procedure on this page:

https://community.hortonworks.com/articles/202904/how-to-remove-all-previous-version-hdp-directories...

on a freshly upgraded HDP setup (version 3.0.1). But when I launch the request it immediately errors out with this in the output:

stdout:

	2018-12-19 10:38:04,388 - call[('ambari-python-wrap', u'/usr/bin/hdp-select', 'versions')] {}<br>	2018-12-19 10:38:04,416 - call returned (0, '2.6.2.14-5\n2.6.5.0-292\n3.0.1.0-187')<br>	2018-12-19 10:38:04,416 - available versions: ['2.6.2.14-5', '2.6.5.0-292', '3.0.1.0-187']<br>	2018-12-19 10:38:04,417 - version 2.6.2.14-5 added to remove<br><br>	Command failed after 1 tries

stderr:

Traceback (most recent call last):<br>  File "/var/lib/ambari-agent/cache/custom_actions/scripts/remove_previous_stacks.py", line 119, in <module><br>  RemovePreviousStacks().execute()<br>  File "/usr/lib/ambari-agent/lib/resource_management/libraries/script/script.py", line 351, in execute<br>  method(env)<br>  File "/var/lib/ambari-agent/cache/custom_actions/scripts/remove_previous_stacks.py", line 49, in actionexecute<br>  self.remove_stack_version(structured_output, low_version)<br>  File "/var/lib/ambari-agent/cache/custom_actions/scripts/remove_previous_stacks.py", line 54, in remove_stack_version<br>  packages_to_remove = self.get_packages_to_remove(version)<br>  File "/var/lib/ambari-agent/cache/custom_actions/scripts/remove_previous_stacks.py", line 77, in get_packages_to_remove<br>  all_installed_packages = self.pkg_provider.all_installed_packages()<br>AttributeError: 'YumManager' object has no attribute 'all_installed_packages'

A quick google did not return anything usefull. But it looks like the some of the supporting code for this is missing or we are missing a extra library somewhere?

1 ACCEPTED SOLUTION

avatar

Hi @Tim Verhoeven,

Removing old stacks and versions is something i personally wont suggest you because at any point you want to downgrade your HDP you might need it. But as you facing the above error i would like to see if below changes help you or not :

I was facing the same issue and changing the below line helped me get past the abouve expection :

Steps

1) go to each ambari agents

[root@asn1 current]#vi /var/lib/ambari-agent/cache/custom_actions/scripts/remove_previous_stacks.py

2) go to line : 77

edit the line from :

all_installed_packages = self.pkg_provider.all_installed_packages()

to

all_installed_packages = self.pkg_provider.installed_packages()

retry the operation via curl again

curl 'http://asn1.openstacklocal:8080/api/v1/clusters/asnaik/requests' -u admin:admin -H "X-Requested-By: ambari" -X POST -d'{"RequestInfo":{"context":"remove_previous_stacks", "action" : "remove_previous_stacks", "parameters" : {"version":"3.0.1.1-84"}}, "Requests/resource_filters": [{"hosts":"asn1.openstacklocal"}]}'

The operation has to be success in UI.

I have created an article in this regard : https://community.hortonworks.com/articles/230893/remove-old-stack-versions-script-doesnt-work-in-am...

Please accept this answer and upvote the article if this helps you

View solution in original post

2 REPLIES 2

avatar

Hi @Tim Verhoeven,

Removing old stacks and versions is something i personally wont suggest you because at any point you want to downgrade your HDP you might need it. But as you facing the above error i would like to see if below changes help you or not :

I was facing the same issue and changing the below line helped me get past the abouve expection :

Steps

1) go to each ambari agents

[root@asn1 current]#vi /var/lib/ambari-agent/cache/custom_actions/scripts/remove_previous_stacks.py

2) go to line : 77

edit the line from :

all_installed_packages = self.pkg_provider.all_installed_packages()

to

all_installed_packages = self.pkg_provider.installed_packages()

retry the operation via curl again

curl 'http://asn1.openstacklocal:8080/api/v1/clusters/asnaik/requests' -u admin:admin -H "X-Requested-By: ambari" -X POST -d'{"RequestInfo":{"context":"remove_previous_stacks", "action" : "remove_previous_stacks", "parameters" : {"version":"3.0.1.1-84"}}, "Requests/resource_filters": [{"hosts":"asn1.openstacklocal"}]}'

The operation has to be success in UI.

I have created an article in this regard : https://community.hortonworks.com/articles/230893/remove-old-stack-versions-script-doesnt-work-in-am...

Please accept this answer and upvote the article if this helps you

avatar
New Contributor

I can confirm that this solution worked for me.

Thanks!