Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[addonservices] allow uninstalling of removed addons and fix other issues #2607

Merged
merged 6 commits into from
Feb 6, 2022

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented Dec 11, 2021

Fixes #2576
Fixes #2581
Fixes #2673
Fixes #2687

It stores a String representation of the addon in the storage service on installation and removes it when the addon is uninstalled. When compiling the list of available addons the information in the storage takes precedence over the information received from the remote so the displayed information (including version or links) stays correct for the installed addon.

@wborn WDYT? I can extend that for the other Addon-Service very quickly, so we can ship that with 3.2.0, which would be very beneficial for users.

Signed-off-by: Jan N. Klug jan.n.klug@rub.de

@J-N-K
Copy link
Member Author

J-N-K commented Dec 12, 2021

I rebased after the nullness annotations have merged and also added all necessary parts for the Community Marketplace Addonservice.

@J-N-K
Copy link
Member Author

J-N-K commented Dec 12, 2021

Jenkins failed unrelated in persistence tests.

@splatch
Copy link
Contributor

splatch commented Dec 14, 2021

While I see the goal, I wanted to note that there is a way to have multiple sources for config admin configuration files (see multiple fileinstall configurations). Current design of openhab distro does not promote that forcing people to use userdata and likely json as storage for everything, even if its suboptimal. This is exclusively because config admin files are being rolled over with system or package update and ConfigDispatcher, as far I can understand its mechanism, is working only from services.cfg to config admin, but not vice versa.
Why not adding another config source under userdata and letting config admin/fileinstall manage that?

I could miss something here.

@J-N-K
Copy link
Member Author

J-N-K commented Dec 15, 2021

I am not sure I understand your point. We need to store the full representation of the Addon to restore it if needed (i.e. the add-on is still installed but no longer present in the remote source). Therefore we need to serialize that data and the JSON representation is very easy and can be extended/adapted by a custom TypeAdapter if we need extensions. What is wrong with using the StorageService for that and what would be the benefit of using another service?

@splatch
Copy link
Contributor

splatch commented Dec 15, 2021

My point is rather basic, why pulling in json and whole storage stuff, which adds just layers of complexity, instead of using config admin for that?
As far I understand addons installed via marketplace form rather basic structure which is fairly similar to what openhab used to have in addons.cfg.

@J-N-K
Copy link
Member Author

J-N-K commented Dec 15, 2021

No, we need a full set of information (id, title, description, version, doc link, image, etc.) to show the add-on in the market place. If it was a single information (like the name), I would agree. But as I said before: we need all (or nearly all) the information in the Addon class and that requires some sort of serialization. Of course we could use custom serialization/deserialization code, but IMO using standard libraries is better here.

The problem is that this information is only available on the remote/cloud/whatever-you-call-it side. If the information is removed there (or not available), the add-on cannot be displayed in the UI, even if it is installed (and not uninstalled because of that). Therefore we need to store the information set for installed add-ons locally. This is different from the distribution add-ons, where this information can be derived from the Karaf feature.

@splatch
Copy link
Contributor

splatch commented Dec 15, 2021

The problem is that this information is only available on the remote/cloud/whatever-you-call-it side. If the information is removed there (or not available), the add-on cannot be displayed in the UI, even if it is installed (and not uninstalled because of that). Therefore we need to store the information set for installed add-ons locally. This is different from the distribution add-ons, where this information can be derived from the Karaf feature.

I see your point, however this makes your implementation more difficult to maintain, especially when remote contents change in more fields than you actually use for identification.

@J-N-K
Copy link
Member Author

J-N-K commented Dec 15, 2021

No. It just requires a custom TypeAdapter for de-/serialization.

Edit: Maybe I misread your comment. The identification is done by the source:id (e.g. marketplace:123456) only. The stored information stays the same as long as the add-on is installed. This is correct, because it's the valid information for the installed version of the add-on. It is removed when the add-on is uninstalled, so with re-installation the updated information from the remote is used.

For storage the openHAB representation of the add-on is used. This is independent of the source. The fields filled in that class depends on the source, though.

@cweitkamp cweitkamp added the enhancement An enhancement or new feature of the Core label Dec 22, 2021
@cweitkamp cweitkamp requested a review from wborn December 22, 2021 06:17
@J-N-K J-N-K changed the title [addonservices] allow uninstalling of removed addons [WIP][addonservices] allow uninstalling of removed addons Jan 1, 2022
@J-N-K
Copy link
Member Author

J-N-K commented Jan 1, 2022

I'll refactor common functionality to an abstract super class and add unit tests for that.

@J-N-K
Copy link
Member Author

J-N-K commented Jan 1, 2022

@openhab/core-maintainers If the overall design is fine with you, I'll add the test promised in #2633.

@cweitkamp cweitkamp linked an issue Jan 9, 2022 that may be closed by this pull request
@J-N-K J-N-K changed the title [WIP][addonservices] allow uninstalling of removed addons [WIP][addonservices] allow uninstalling of removed addons and fix other issues Jan 9, 2022
@J-N-K J-N-K changed the title [WIP][addonservices] allow uninstalling of removed addons and fix other issues [addonservices] allow uninstalling of removed addons and fix other issues Jan 10, 2022
@J-N-K
Copy link
Member Author

J-N-K commented Jan 10, 2022

IMO this adds a pretty good coverage for the common part of the add-on services, including install/uninstall, remote/local only logic and storage.

@J-N-K
Copy link
Member Author

J-N-K commented Jan 29, 2022

Is there anything blocking progress here?

@cweitkamp
Copy link
Contributor

In order to have small PR to fix bugs I submitted #2718 to fix #2687

@lolodomo
Copy link
Contributor

@J-N-K : #2687 was finally fixed by another PR. You will have to update this PR.

@J-N-K J-N-K closed this Jan 30, 2022
J-N-K and others added 5 commits January 30, 2022 14:05
Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Jan N. Klug <github@klug.nrw>
Signed-off-by: Jan N. Klug <github@klug.nrw>
Signed-off-by: Jan N. Klug <github@klug.nrw>
Signed-off-by: Jan N. Klug <github@klug.nrw>
@J-N-K
Copy link
Member Author

J-N-K commented Jan 30, 2022

This is definitely the last time I rebase this PR.

@J-N-K J-N-K reopened this Jan 30, 2022
Signed-off-by: Jan N. Klug <github@klug.nrw>
Copy link
Contributor

@cweitkamp cweitkamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for your work.

@cweitkamp cweitkamp merged commit c4e1b14 into openhab:main Feb 6, 2022
@J-N-K J-N-K deleted the addons-storage branch February 6, 2022 10:06
@wborn wborn added this to the 3.3 milestone Feb 13, 2022
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
…sues (openhab#2607)

* [addonservices] allow uninstalling of removed addons

Signed-off-by: Jan N. Klug <github@klug.nrw>
GitOrigin-RevId: c4e1b14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
5 participants