Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to remove an old HDP version

Solved Go to solution
Highlighted

How to remove an old HDP version

New 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

Accepted Solutions

Re: How to remove an old HDP version

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.

11 REPLIES 11

Re: How to remove an old HDP version

@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.

Re: How to remove an old HDP version

New 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.

Re: How to remove an old HDP version

New Contributor

Re: How to remove an old HDP version

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.

Re: How to remove an old HDP version

Contributor

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"

Re: How to remove an old HDP version

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

Re: How to remove an old HDP version

Contributor

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.

Re: How to remove an old HDP version

Contributor

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

Re: How to remove an old HDP version

New Contributor

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.