umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.45k stars 2.68k forks source link

UnattendedInstaller broken #14110

Open netcompany-runeviumsondergaard opened 1 year ago

netcompany-runeviumsondergaard commented 1 year ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

11.3.0

Bug summary

In 11.2.2 everything is working as it should. On an empty database Umbraco tries to find the relevant database from the umbracoDbDSN env variable and when it isn't found the database is created, no problem. In 11.3.0 something is now broken and I just get an error. The only thing I changed is the version.

I know for sure the env variable is still used and is valid, as the error I get when changing it to something invalid is different.

Specifics

Output in terminal: 2023-04-17 15:22:23 Error Number:4060,State:1,Class:11 2023-04-17 15:22:23 Unhandled exception. Umbraco.Cms.Core.Exceptions.BootFailedException: A connection string is configured but Umbraco could not connect to the database. 2023-04-17 15:22:23 at Umbraco.Cms.Infrastructure.Runtime.RuntimeState.DetermineRuntimeLevel() 2023-04-17 15:22:23 at Umbraco.Cms.Infrastructure.Install.UnattendedInstaller.HandleAsync(RuntimeUnattendedInstallNotification notification, CancellationToken cancellationToken) 2023-04-17 15:22:23 at Umbraco.Cms.Core.Events.NotificationAsyncHandlerWrapperImpl1.<>c__DisplayClass0_0.<HandleAsync>b__1(INotification theNotification, CancellationToken theToken) 2023-04-17 15:22:23 at Umbraco.Cms.Core.Events.EventAggregator.PublishCoreAsync(IEnumerable1 allHandlers, INotification notification, CancellationToken cancellationToken) 2023-04-17 15:22:23 at Umbraco.Cms.Infrastructure.Runtime.CoreRuntime.StartAsync(CancellationToken cancellationToken, Boolean isRestarting) 2023-04-17 15:22:23 at Umbraco.Cms.Infrastructure.Runtime.CoreRuntime.StartAsync(CancellationToken cancellationToken) 2023-04-17 15:22:23 at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) 2023-04-17 15:22:23 at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) 2023-04-17 15:22:23 at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) 2023-04-17 15:22:23 at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) 2023-04-17 15:22:23 at UmbracoPOC.Program.Main(String[] args) in /src/UmbracoPOC/Program.cs:line 8 2023-04-17 15:22:23 [13:22:23 ERR] Unhandled exception in AppDomain (terminating). 2023-04-17 15:22:23 Umbraco.Cms.Core.Exceptions.BootFailedException: A connection string is configured but Umbraco could not connect to the database. 2023-04-17 15:22:23 at Umbraco.Cms.Infrastructure.Runtime.RuntimeState.DetermineRuntimeLevel() 2023-04-17 15:22:23 at Umbraco.Cms.Infrastructure.Install.UnattendedInstaller.HandleAsync(RuntimeUnattendedInstallNotification notification, CancellationToken cancellationToken) 2023-04-17 15:22:23 at Umbraco.Cms.Core.Events.NotificationAsyncHandlerWrapperImpl1.<>c__DisplayClass0_0.<HandleAsync>b__1(INotification theNotification, CancellationToken theToken) 2023-04-17 15:22:23 at Umbraco.Cms.Core.Events.EventAggregator.PublishCoreAsync(IEnumerable1 allHandlers, INotification notification, CancellationToken cancellationToken) 2023-04-17 15:22:23 at Umbraco.Cms.Infrastructure.Runtime.CoreRuntime.StartAsync(CancellationToken cancellationToken, Boolean isRestarting) 2023-04-17 15:22:23 at Umbraco.Cms.Infrastructure.Runtime.CoreRuntime.StartAsync(CancellationToken cancellationToken) 2023-04-17 15:22:23 at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) 2023-04-17 15:22:23 at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) 2023-04-17 15:22:23 at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token) 2023-04-17 15:22:23 at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) 2023-04-17 15:22:23 at UmbracoPOC.Program.Main(String[] args) in /src/UmbracoPOC/Program.cs:line 8

Steps to reproduce

Run Umbraco from scratch and use a MSSQL database. I run it in docker and my docker compose state: ConnectionStringsumbracoDbDSN: "Server=umbraco-db;Database=umbracoDb;User Id=sa;Password=yourStrong(!)Password;" ConnectionStringsumbracoDbDSN_ProviderName: "Microsoft.Data.SqlClient"

Expected result / actual result

Umbraco should recreate a new empty database allowing Usync to add content.


_This item has been added to our backlog AB#28820_

github-actions[bot] commented 1 year ago

Hi there @NC-RVSO!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

Zeegaan commented 1 year ago

Question here, is the database running on docker, or your Umbraco solution ? 😁

netcompany-runeviumsondergaard commented 1 year ago

I am running it with these: ConnectionStringsumbracoDbDSN: "Server=umbraco-db;Database=umbracoDb;User Id=sa;Password=yourStrong(!)Password;" ConnectionStringsumbracoDbDSN_ProviderName: "Microsoft.Data.SqlClient" And the database is running in another docker container :)

Zeegaan commented 1 year ago

Thanks for the info! I can definitely reproduce this, seems like a regression to me!

To anyone wondering how to setup SqlServer on docker i followed this article: https://www.sqlservercentral.com/articles/docker-desktop-on-windows-10-for-sql-server-step-by-step

ronaldbarendse commented 1 year ago

@NC-RVSO If the database doesn't exist yet on the SQL Server instance and you want it to be automatically created, you need to explicitly enable the InstallMissingDatabase setting, as is documented in the unattended install steps: https://docs.umbraco.com/umbraco-cms/fundamentals/setup/install/unattended-install#configure-your-database.

Production environments shouldn't have this setting enabled though, since a misconfigured connection string could then result in installing an empty Umbraco instance, instead of throwing an exception about this misconfiguration (the exact exception you posted above). It's also not recommended to configure a connection string with credentials that have the CREATE DATABASE permission, as that user will very likely have too many permissions (possibly to other databases as well).

netcompany-runeviumsondergaard commented 1 year ago

@ronaldbarendse I agree the new behavior is more correct. Maybe the error message should be more informative? It could mention the InstallMissingDatabase property.