change: make extension versions immutable#1983
Conversation
|
Supersedes #1866 |
|
The UI changes include various fixes that were existing, for example from the namespace admin page you were redirected to the user settings of the extension where you could not delete them as an admin. Another things was that it was not visible whether a version is active or not, so this is now also included so that as an admin you immediately see that without needing to query the DB. The refactoring also make sure components that are used from the admin dashboard and user settings are now shared in |
|
I decided against an additional enum for the state to keep things as simple as possible as to focus on correctness and making sure we do not add any regression and fix the UI accordingly which was pretty much broken in this regard. In a follow up step we should cleanup the different states an extension can be in, but this will take some time and we need to have the soft-delete as a basis for other work. |
|
re Backend changes: LGTM, one observation: re Frontend changes: Ponytail remark: |
Yes, I wanted exactly to ask this, as perso, I liked more the "enum way" @gnugomez started with. Right now, we have two related boolean columns (there is clearly a logical dependency between the two; maybe even more) but are implemented as independent from each other. |
|
The reason against an enum with state is that you need to have a state machine that ensures what transitions are possible or allowed. We certainly want a state for an extension to also cover cases like:
but this is not something I would do light-heartily so I would like to postpone that to get the immutable version stuff in. |
|
I know that 39 columns is bad, also considering that we use jooq and we need to explicitly select the columns we want to retrieve which is easy to miss. This is certainly an area that needs improvements and the reason why I am afraid to touch that code. |
autumnfound
left a comment
There was a problem hiding this comment.
Java code generally LGTM, can't speak on the React code and I don't have capacity to test immediately. I don't love that we're as light as we are on tests since this is such an impactful change.
…deprecated test container
| public boolean isDeleteAllVersions( | ||
| @Nullable UserData user, | ||
| String namespaceName, | ||
| String extensionName, | ||
| TargetPlatformVersion... targetVersions | ||
| ) { | ||
| if (targetVersions.length == 0) { | ||
| return true; | ||
| } | ||
|
|
||
| var all = dsl.select(DSL.count(EXTENSION_VERSION.ID).as("all")) | ||
| .from(EXTENSION_VERSION) | ||
| .join(EXTENSION).on(EXTENSION.ID.eq(EXTENSION_VERSION.EXTENSION_ID)) | ||
| .join(NAMESPACE).on(NAMESPACE.ID.eq(EXTENSION.NAMESPACE_ID)) | ||
| .and(NAMESPACE.NAME.equalIgnoreCase(namespaceName)) | ||
| .and(EXTENSION.NAME.equalIgnoreCase(extensionName)) | ||
| .fetchOne("all", Integer.class); |
There was a problem hiding this comment.
issue: I believe we have a bug here, basically when a user asks to delete all versions we run this query, but I see no modifications from you here, we need to make sure that the count we run here is skipping versions that have a remove = true tombstone
otherwise the the extension that bundles the versions trying to be removed will never be removed right?
is this intentional?
There was a problem hiding this comment.
that was missed, ty for spotting.
There was a problem hiding this comment.
It took me a while but I understand the problem now. The bug is that we need to check if this operation (either delete or purge) would remove all active versions of the extension which we would need to additionally check (are there other extensions depending on it).
There was a problem hiding this comment.
at the same time I will also fix #1956 as we actually check if this extension is declared in a bundle and then prevent it from being deleted. Now this is not synchronous with publication as you can publish an extension that declares bundled extensions that do not exist also the IDEs usually handle that gracefully: if you install a bundle with non-existing extensions, they are just skipped.
…xtension should be purged, they are prohibited from uploaded again separately

This PR modifies the default behavior of the registry such that extension versions are immutable.
Deleting an extension version does not remove it from the database, but instead marks is as deleted so that the same version can not be published again. Extension files uploaded to the cloud storage are deleted, so it is not possible to
undeletea version again.Additionally, there is now a purge mechanism for admins to be able to remove extension versions completely from the database as well.
The UI has also been refactored to better display the status of extension versions.
This fixes #1805, #1956.