Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSGi feature uninstall works, but bundles are still installed

EDIT: updated this question with latest information...

I'm having issues running back-to-back "features:uninstall" commands for dependent features. OSGi responds back with "State change in progress...", but by accepting other requests, we run into issues.

Strangely, this results in successful feature uninstalls, but unsuccessful bundle uninstalls. We are addressing this by trying to order uninstall requests appropriately and adding a delay between steps, but I'm hoping for a more robust solution.

As suggested, I also tried adding "osgi:refresh" in between steps...same behavior. Is there another way to detect that "Refresh Packages" is still running to delay subsequent requests, etc?

Here are the details...

karaf@root> features:uninstall PolicyUtil  
karaf@root> features:uninstall Policy1  
karaf@root> features:uninstall Policy2    
State change in progress for bundle "file:/policy2.jar" by thread "Refresh Packages".  
karaf@root> features:uninstall Policy3  
State change in progress for bundle "file:/policy3.jar" by thread "Refresh Packages".  
karaf@root> features:uninstall Policy4  
karaf@root> features:uninstall Enabler1    
State change in progress for bundle "file:/enabler1.jar" by thread "Refresh Packages".    
karaf@root> features:uninstall Enabler2  
State change in progress for bundle "file:/enabler2.jar" by thread "Refresh Packages".  

afterwards...we end up with features uninstalled (correct), but some bundles still installed (incorrect)

osgi:list

[ 277] [Installed  ] [            ] [       ] [   60] Policy2  
[ 278] [Installed  ] [            ] [       ] [   60] Policy3  
[ 280] [Installed  ] [            ] [       ] [   60] Enabler1  
[ 281] [Installed  ] [            ] [       ] [   60] Enabler2  

features:list

[uninstalled] [1.0                 ] PolicyUtil                           repo-0  
[uninstalled] [1.0                 ] Policy1                              repo-0  
[uninstalled] [1.0                 ] Policy2                              repo-0  
[uninstalled] [1.0                 ] Policy3                              repo-0  
[uninstalled] [1.0                 ] Enabler1                             repo-0  
[uninstalled] [1.0                 ] Enabler2                             repo-0  
like image 201
Ben ODay Avatar asked Jan 21 '23 20:01

Ben ODay


1 Answers

I'm not sure what kind of exception you will get, but you should be aware of one thing: when you uninstall a bundle using a shell command like osgi:uninstall, you effectively call Bundle.uninstall(). As you can read in the Javadoc there, this is not the entire story.

The framework favors operations that have minimal impact on the rest of the framework, so it can uninstall a bundle without removing all related packages. If you really want to remove all of them, you should use a osgi:refresh command. For more information on this, see the Felix FAQ.

The best advice I can give is to not issue multiple uninstall requests that can cross each other. If you want to remove a set of bundles, I would fire off non-crossing uninstall() requests, followed by a single refreshPackages(). Also, I would not mix bundle management using the 'regular' console and Karaf in a single system.

You could also consider using an external manager for installing and removing bundles. If you want remote management, you could go for Apache ACE (disclosure: I'm an Apache ACE committer).

like image 105
Angelo van der Sijpt Avatar answered Feb 19 '23 08:02

Angelo van der Sijpt