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

Module Deletion Inconsistency #3947

Closed
leigh-pointer opened this issue Mar 5, 2024 · 5 comments
Closed

Module Deletion Inconsistency #3947

leigh-pointer opened this issue Mar 5, 2024 · 5 comments

Comments

@leigh-pointer
Copy link
Contributor

Description:
Upon testing Oqtane in a real-world scenario on an IIS instance, I encountered an inconsistency in module deletion behavior. After installing a module, using it, deleting it from the page, and subsequently uninstalling it, the module remained listed within the system despite its assemblies being successfully removed from the file system. The removal of the module from the system's lists required manual intervention, specifically a manual restart of the framework.

Steps to Reproduce:

Package Oqtane and set up an IIS instance.
Install a module.
Utilize the installed module.
Delete the module from the page.
Uninstall the module.
Observe that the module remains listed within the system despite successful removal of its assemblies from the file system.
Expected Behavior:
Upon uninstallation, the module should be completely removed from the system, including its listing within system's modules without requiring manual intervention such as framework restart.

Actual Behavior:
The module remains listed within the system even after successful uninstallation. Manual intervention, specifically a framework restart, is necessary for the module to be removed from the system's lists.

Environment:

Operating System: Windows 11
Oqtane Version: 5.1
Web Server: IIS 10.0
Module: DynamicForm 2.0.3

@sbwalker
Copy link
Member

sbwalker commented Mar 5, 2024

@leigh-pointer I am running a default install using Static Rendering and I generated a new module with the Module Creator. I compiled the module and then ran Oqtane and the module appears in the Module Management UI. I clicked Uninstall and the module was removed from the list and the UI was refreshed. So I am unable to reproduce this issue. Can you please provide more details about the specific scenario so that I can reproduce the problem.

@leigh-pointer
Copy link
Contributor Author

@sbwalker I got the latest from GitHub built it using the Release.cmd and with the install.zip created an IIS website locally. I didn't change anything when setting up.
I download a module from the market place, installed it and restarted the framework. After using the module i deleted the instance and then deleted the module from the Module manager.
The files were removed but the module list was not updated. Restarting the framework reset the module list.

@leigh-pointer
Copy link
Contributor Author

@sbwalker I think i have found the problem. As we know deleting the module from a page actually marks it deleted and appears in the Recycle bin. If the module instances are not removed from the Recycle bin then the Remove Module procedure does not complete in full.

@sbwalker
Copy link
Member

sbwalker commented Mar 7, 2024

This issue is discussed in #3945 as well...

The ModuleDefinitionController Delete method contains logic to delete the Module/PageModule instances which may exist - however it is not going to work properly in a multi-tenant environment where site information could be stored in different isolated databases.

In fact, the "In Use" column in the main display is also not 100% accurate as it only displays if the module is in use in the current Site - not if it is in use in any site in the entire installation.

Iterating all of the tenants to remove module instances on all sites may be possible... but it becomes very complicated.

I think the Uninstall needs to be changed to not remove the module instances. Then if a module is uninstalled and there are instances which reference it, the framework will simply display the standard module error modal which still allows the instance to be removed by the administrator.

@sbwalker
Copy link
Member

#3945 resolves the issue by not attempting to cleanup page/module instances because, as I mentioned above, there may be page/module instances in multiple tenant database which reference the module. So basically what is expected to happen is that the module is deleted but any existing module references in any site will display the standard module error message on the page to indicate the module does not exist.

Note that in order for a module to be deleted when using EF Core migrations, the "Down" method must be implemented correctly and entities need to be removed in the correct order or else errors may occur due to foreign key references.

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            var projectActivityEntityBuilder = new ProjectActivityEntityBuilder(migrationBuilder, ActiveDatabase);
            projectActivityEntityBuilder.Drop();

            var projectEntityBuilder = new ProjectEntityBuilder(migrationBuilder, ActiveDatabase);
            projectEntityBuilder.Drop();
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants