Support Questions

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

How to remove an old HDP version

avatar
Contributor

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.

1 ACCEPTED SOLUTION

avatar

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.

View solution in original post

11 REPLIES 11

avatar
@Gonzalo Herreros

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.

avatar
Contributor

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.

avatar
New Contributor

avatar

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.

avatar
Rising Star

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"

avatar

It's possible that the feature has not been maintained in the version of Ambari that you are using.

avatar
Rising Star

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.

avatar
Rising Star

I tried adding the py script manually into the usual custom actions location but no cigar either...

avatar

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.