Failing to uninstall a feature marked as not required

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Failing to uninstall a feature marked as not required

paouelle
When trying to uninstall a feature that is installed, started, but not marked
as required, we get an error.

For example:

admin@root()> feature:list| grep platform-api
platform-api                                    │ 2.12.0.SNAPSHOT  │        
│ Started     │ platform-app-2.12.0-SNAPSHOT           │
admin@root()> feature:uninstall platform-api
Error executing command: Feature named 'platform-api/0.0.0' is not installed
admin@root()> feature:uninstall platform-api/2.12.0.SNAPSHOT
Error executing command: Feature named 'platform-api/2.12.0.SNAPSHOT' is not
installed

Even trying to uninstall this feature programmatically via the
FeaturesService.uninstallFeature() fails with the same error. That is true
even after verifying the feature is installed via
FeaturesService.isInstalled() and after having the feature returned to us
via FeaturesService.listInstalledFeatures().

Digging through the code in the class FeaturesServiceImpl, you can see that
it ends up checking the state.requirements table and if not defined in
there, it later reports the feature is not installed. This table seems to be
used to determine if a feature is required or not as per the implementation
for FeaturesServiceImpl.isRequired() whereas
FeaturesServiceImpl.isInstalled() checks the state.installedFeatures table.

Is this a known bug or should I open a ticket?

I was able to circumvent the problem by updating the requirements for the
feature and after having done that, the uninstall goes through successfully.

Regards,

Patrick



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html
Reply | Threaded
Open this post in threaded view
|

Re: Failing to uninstall a feature marked as not required

Guillaume Nodet-2
That's the expected behavior.
The feature:install really means "require this feature" while uninstall
means "do not require this feature anymore".
The features management commands won't allow you to let Karaf in an
"unstable" state, so if you want to perform such operations, you'd have to
do that using the bundle commands instead.
Given this was a bit confusing, please raise a JIRA issue so that we can
improve the user interaction and display better error messages.

2018-01-17 21:11 GMT+01:00 paouelle <[hidden email]>:

> When trying to uninstall a feature that is installed, started, but not
> marked
> as required, we get an error.
>
> For example:
>
> admin@root()> feature:list| grep platform-api
> platform-api                                    │ 2.12.0.SNAPSHOT  │
> │ Started     │ platform-app-2.12.0-SNAPSHOT           │
> admin@root()> feature:uninstall platform-api
> Error executing command: Feature named 'platform-api/0.0.0' is not
> installed
> admin@root()> feature:uninstall platform-api/2.12.0.SNAPSHOT
> Error executing command: Feature named 'platform-api/2.12.0.SNAPSHOT' is
> not
> installed
>
> Even trying to uninstall this feature programmatically via the
> FeaturesService.uninstallFeature() fails with the same error. That is true
> even after verifying the feature is installed via
> FeaturesService.isInstalled() and after having the feature returned to us
> via FeaturesService.listInstalledFeatures().
>
> Digging through the code in the class FeaturesServiceImpl, you can see that
> it ends up checking the state.requirements table and if not defined in
> there, it later reports the feature is not installed. This table seems to
> be
> used to determine if a feature is required or not as per the implementation
> for FeaturesServiceImpl.isRequired() whereas
> FeaturesServiceImpl.isInstalled() checks the state.installedFeatures
> table.
>
> Is this a known bug or should I open a ticket?
>
> I was able to circumvent the problem by updating the requirements for the
> feature and after having done that, the uninstall goes through
> successfully.
>
> Regards,
>
> Patrick
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html
>



--
------------------------
Guillaume Nodet
Reply | Threaded
Open this post in threaded view
|

Re: Failing to uninstall a feature marked as not required

paouelle
Thanks Guillaume for the explanation.

I will say that this is very confusing beyond the error message displayed
since a feature can still be "not required" and yet be reported as installed
via the isInstall() or listInstalledFeatures().

In addition, calling uninstallFeature() does more than simply mark the
feature as "not required" as it actually removes it from the internal
'state.installedFeatures' table at which point isInstall() will return false
and listInstalledFeature() will no longer report it (same for the cmd
shell).

There is definitely a difference in the implementation between
installed/not-installed vs required/not-required.

Maybe specific methods to mark a feature required or not beyond the
confusing use of addRequirements(),  removeRequirements() and
installFeature(), uninstallFeature() is in order.



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html
Reply | Threaded
Open this post in threaded view
|

Re: Failing to uninstall a feature marked as not required

Guillaume Nodet-2
I guess my explanation was not really clear.

A feature is required or not as the result of a user action:
"features:install" will flag the feature as "required" and
"features:uninstall" will unflag it.
A feature becomes installed or uninstalled as the result of a
FeaturesService's resolution. As a user, you don't have any direct way to
change if a feature is installed or not.
When the FeaturesService performs a resolution, it will look for all
required features and their dependencies, and find which features need to
be installed to solve those requirements.  If a feature was not installed
but the resolution computed it should be, it will be installed.  If a
feature was installed but the resolution indicates it's not needed anymore,
it will be uninstalled.
So in short, if you call "features:install", it will flag the feature as
"required", and perform a resolution : the outcome will always be that this
specific feature is installed.  Your first use case was to uninstall a
feature which was a dependency: you can't do that if the feature is needed
by another feature, because the output of the FeaturesService's resolution
will always be valid and applied.

For example, if you have a FeatureA that has a dependency on FeatureB.
Here is the outcome of the commands when run in sequence

feature:install FeatureA => FeatureA is required, FeatureA and FeatureB are
installed, bundles from both features are installed
feature:uninstall FeatureB => FeatureA is required, FeatureA and FeatureB
are installed, no changes in bundles
feature:install FeatureB => FeatureA and FeatureB are required, FeatureA
and FeatureB are installed, no changes in bundles
feature:uninstall FeatureB => FeatureA is required, FeatureA and FeatureB
are installed, no changes in bundles
feature:uninstall FeatureA => no features required, no features installed,
bundles from both features are uninstalled

Hope this clarify things a bit.

2018-01-23 18:43 GMT+01:00 paouelle <[hidden email]>:

> Thanks Guillaume for the explanation.
>
> I will say that this is very confusing beyond the error message displayed
> since a feature can still be "not required" and yet be reported as
> installed
> via the isInstall() or listInstalledFeatures().
>
> In addition, calling uninstallFeature() does more than simply mark the
> feature as "not required" as it actually removes it from the internal
> 'state.installedFeatures' table at which point isInstall() will return
> false
> and listInstalledFeature() will no longer report it (same for the cmd
> shell).
>
> There is definitely a difference in the implementation between
> installed/not-installed vs required/not-required.
>
> Maybe specific methods to mark a feature required or not beyond the
> confusing use of addRequirements(),  removeRequirements() and
> installFeature(), uninstallFeature() is in order.
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html
>



--
------------------------
Guillaume Nodet