-
Notifications
You must be signed in to change notification settings - Fork 0
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
Restore triggers too early for 3rd party add-ons #91
Comments
Yes, I think I can see the issue here. We have a |
This is mentioned to be fixed in Deploy 4.4.2. Is it also fixed in v9, and if so in what release? Because I'm having the same issue on a v9 site. |
It's not in V9 no @MichaelNielsenDK, but only because I didn't think the issue was found there. It's possible I missed something though. If you can share a cut down example of the problem you are running into will be happy to look further. |
@AndyButland I've described it here And @mattbrailsford defined it to be the same issue as But let me know if you need more information. |
Thanks - I'll have a further look at this. |
Hi @MichaelNielsenDK and @mattbrailsford - have had another look at this with Deploy V9, and it does seem like we don't have the same issue as was the case in V8, and needed the recent patch update. Or at least and I can't see it my tests, and so wanted to replay what I've tried to see if you can see what I'm missing. In V8 we had the issue because Deploy was running it's first extraction based on finding a In V9 though, the disk file monitoring and extractions are set up in a handler of the To test this I've created a simple composer/component:
Via breakpoints I can see that the I suspect if you are still seeing a problem it's because of something I'm not replicating properly in my tests. I'm thinking perhaps if Vendr (or anything else) was doing setup in a |
So in Vendr v2 for v9 we do have a few |
Could be - are you able to share a cut down version of what's going on in your |
This is basically my start-up filter which I believe it'll be our |
Thanks. It does look as if this code will run after the I wonder though if you could avoid needing this filter. I assume it's there so you can statically access the If so, there's is a feature in V9 to do service location. It's not encouraged, but is available and justified to use for two reasons - avoiding breaking changes to signatures and to keep "friendly" extension methods available - both of which seem to apply here. It seems you could define
And then rather then setting it in the startup filter, you could just access this now read-only property and use the provider via service location. There's an example of Umbraco doing this here.
As I say I'll see if there's anything we can amend in Deploy here to still try to get these file triggers processed after everything has started up, but it could be this approach will allow you to fix the issue on the Vendr side. |
Hey @AndyButland, I could yea, but given some history, I'm basically trying to avoid as much Umbraco dependency as I can as then everything becomes out of my control. To be fair though, I only implemented it this way because that's the best way I could find to do it. If there is some other way to make sure this gets fired on application startup before my other code I'm sure that would be fine 👍 |
Have had a few discussions and some experiments, and seems we can move the Deploy trigger for initiating file triggered operations to it's own |
This is indeed the case, as you can see from the @mattbrailsford I think the main issue you're seeing is because Deploy 9 currently starts the triggers in the |
@ronaldbarendse but aren't |
They aren't obsoleted, but not required anymore to subscribe to events, as it's now possible to directly add notification handlers in your As the documentation states, an So if you want to setup something before the |
Ok, I've dropped my startup filter in favour of an Are we saying this should resolve the issue at hand though if I get my customers to upgrade? |
@mattbrailsford That should indeed fix the timing issue 😄 And @AndyButland already confirmed |
I've researched the application lifetime events a bit more and we can move the Deploy operations (watching for trigger/marker files) to the For completeness, the following code shows the order in which the events are executed for both starting and stopping an Umbraco application: Start:
Stop:
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
public class ApplicationComposer : ComponentComposer<ApplicationComponent>
{
public override void Compose(IUmbracoBuilder builder)
{
Console.WriteLine("IComposer.Compose");
builder.Services.AddTransient<IStartupFilter, ApplicationStartupFilter>();
builder.AddNotificationHandler<UmbracoApplicationStartingNotification, UmbracoApplicationStartingNotificationHandler>();
builder.AddNotificationHandler<UmbracoApplicationStoppingNotification, UmbracoApplicationStoppingNotificationHandler>();
base.Compose(builder);
}
}
public class ApplicationComponent : IComponent
{
private readonly IHostApplicationLifetime _hostApplicationLifetime;
public ApplicationComponent(IHostApplicationLifetime hostApplicationLifetime)
=> _hostApplicationLifetime = hostApplicationLifetime;
public void Initialize()
{
Console.WriteLine("IComponent.Initialize");
_hostApplicationLifetime.ApplicationStarted.Register(() =>
{
Console.WriteLine("IHostApplicationLifetime.ApplicationStarted");
});
_hostApplicationLifetime.ApplicationStopping.Register(() =>
{
Console.WriteLine("IHostApplicationLifetime.ApplicationStopping");
});
_hostApplicationLifetime.ApplicationStopped.Register(() =>
{
Console.WriteLine("IHostApplicationLifetime.ApplicationStopping");
});
}
public void Terminate()
{
Console.WriteLine("IComponent.Terminate");
}
}
public class UmbracoApplicationStartingNotificationHandler : INotificationHandler<UmbracoApplicationStartingNotification>
{
public void Handle(UmbracoApplicationStartingNotification notification)
{
Console.WriteLine("UmbracoApplicationStartingNotification");
}
}
public class UmbracoApplicationStoppingNotificationHandler : INotificationHandler<UmbracoApplicationStoppingNotification>
{
public void Handle(UmbracoApplicationStoppingNotification notification)
{
Console.WriteLine("UmbracoApplicationStoppingNotification");
}
}
public class ApplicationStartupFilter : IStartupFilter
{
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next) => (app) =>
{
Console.WriteLine("IStartupFilter.Configure (before)");
next(app);
Console.WriteLine("IStartupFilter.Configure (after)");
};
} |
There is an issue with Deploy triggering too early if there are third party add-ons that require their
IComponent
implementations to run before they can safely deploy artefacts.Reproduction
Bug summary
It appears that Umbraco.Deploy triggers a deploy from within it's
IComponent.Initialize
method, however because theDeployComposer
class is registered beforeIUserComposer
instances I believe this means that it is composed and thus initialized before all other composers / components of third parties.The issue is, Vendr requires it's
IComponent
to be initialized before it can safely execute as there are a number of setup steps that occur within that method that it relies upon. Because these aren't triggered though before Deploy attempts a restore the attempt fails with exceptions due to a number of resources beingnull
.Steps to reproduce
deploy
file in the data directory and then touch the web.configIComponent
was initialized which contains essential setup steps for Vendr to runExpected result
I would expect that Umbraco Deploy should wait until the application is fully initialized before it attempts a restore as it can't know what third party dependencies it has and whether those dependencies are ready yet or not.
Actual result
Deploy attempts a restore too early and so causes errors.
The text was updated successfully, but these errors were encountered: