Created 03-08-2016 09:11 AM
How are you supposed to remove an old version of HDP once you have successfully upgraded to a new version?
The old version is still listed as installed and the "Deregister" button is disabled because "it is installed".
It would be easy to delete the /usr/hdp/[old version] folder but all the packages would still be considered installed by the OS. On the other hand trying to remove the old packages manually on each node is cumbersome and risky.
Leaving behing GBs of data and lots of packages will easily buildup as you upgrade to new versions over the years.
Created 12-09-2016 07:53 PM
There's an API to remove older versions from the hosts. Take a look at https://issues.apache.org/jira/browse/AMBARI-18435
E.g.,
curl 'http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/requests' -u admin:admin -H "X-Requested-By: ambari" -X POST -d'{"RequestInfo":{"context":"remove_previous_stacks", "action" : "remove_previous_stacks", "parameters" : {"version":"2.5.0.0-1245"}}, "Requests/resource_filters": [{"hosts":"c6403.ambari.apache.org, c6402.ambari.apache.org"}]}'
That removes all versions older than "2.5.0.0-1245"; the version mentioned in request remains intact. We also have checks that prevent removing the current version and the operation is idempotent.
That will not remove the version from Ambari's database, but will free up space.
Created 03-08-2016 09:45 AM
Yes - for now, it has to be done manually. You could list all the packages for a given repo [older repo] and remove them manually in all the nodes. Typically the folders are well demarcated and hence chances of losing a current version file is rare. May be you could post this in 'Post idea' section.
Created 03-08-2016 11:06 AM
Thanks. That's really disappointing. Ambari knows the packages installed by the stack so it should be easy to implement that feature. Even better if it moved away from packages altogether, as Cloudera did
Somebody mentioned the Ambari cleanup script in an idea proposed. Will check it out but I believe that script will remove everything not just old versions.
Created 11-22-2016 09:40 PM
Created 12-09-2016 07:53 PM
There's an API to remove older versions from the hosts. Take a look at https://issues.apache.org/jira/browse/AMBARI-18435
E.g.,
curl 'http://c6401.ambari.apache.org:8080/api/v1/clusters/cl1/requests' -u admin:admin -H "X-Requested-By: ambari" -X POST -d'{"RequestInfo":{"context":"remove_previous_stacks", "action" : "remove_previous_stacks", "parameters" : {"version":"2.5.0.0-1245"}}, "Requests/resource_filters": [{"hosts":"c6403.ambari.apache.org, c6402.ambari.apache.org"}]}'
That removes all versions older than "2.5.0.0-1245"; the version mentioned in request remains intact. We also have checks that prevent removing the current version and the operation is idempotent.
That will not remove the version from Ambari's database, but will free up space.
Created 03-14-2017 03:06 PM
I'm on the latest HDP/Ambari and I get the following error:
"status" : 500, "message" : "An internal system exception occurred: Action remove_previous_stacks does not exist"
Created 03-14-2017 04:49 PM
It's possible that the feature has not been maintained in the version of Ambari that you are using.
Created 03-14-2017 07:09 PM
Ugh that'd be highly annoying.
Is there no other known way(s) to remove the old version?
I pretty much cssh'd myself to all the worker nodes and did rpm -qa | grep 2.4 and went ahead and remove all the packages with 2.4 HDP.
Somehow when I go to deregister the old distribution under ambari it still reports the nodes has having the software installed even though it's been obliterated.
Created 03-14-2017 03:07 PM
I tried adding the py script manually into the usual custom actions location but no cigar either...
Created 02-22-2018 11:18 PM
Did the mentioned script work for someone? I tried this today on Ambari 2.6.1 to remove HDP versions older than 2.3.4.0-3485. The command responded as "Accepted" and finished within a second. But, it didn't remove any packages from the nodes. Do I need to recycle the agents or something to trigger it?
UPDATE:- It deleted the directory /usr/hdp/2.2.8.0-3150/ from all nodes and freed up disc space but, it didn't uninstall the rpm packages' entries. I had to do that manually. So, it kind of defeats the purpose. I guess manual rpm uninstall method is better than running this curl command to do a cleaner uninstall.