-
Notifications
You must be signed in to change notification settings - Fork 3
chore: Initial draft for WarmupService/check #2250
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
base: main
Are you sure you want to change the base?
Conversation
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords (3)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
@@ -24,6 +24,8 @@ | |||
<PackageReference Include="ZiggyCreatures.FusionCache" Version="2.2.0"/> | |||
<PackageReference Include="ZiggyCreatures.FusionCache.Backplane.StackExchangeRedis" Version="2.2.0"/> | |||
<PackageReference Include="ZiggyCreatures.FusionCache.Serialization.NeueccMessagePack" Version="2.2.0"/> | |||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.0"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ikke optimalt å måtte dra i disse dependenciene i Infrastruktur, men trenger dem for å kunne konstruere en httpcontext slik at man får sendt requests.
|
||
public class WarmupService : IHostedService | ||
{ | ||
// Should exist in all environments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er muligens ikke strengt nødvendig at disse faktisk finnes, det kan hende det gir nok oppvarming selv om vi ikke får kjørt requestene helt (ikke testet). Men vi skal ha testdata også i prod, så i teorien skal det være mulig å finne noen som lever i alle miljø. Alternativt får vi gjøre dette til config.
/* | ||
// Wait for Kestrel to initialize and then perform local HTTP requests | ||
await Task.Delay(TimeSpan.FromSeconds(3), cancellationToken); | ||
await PerformLocalHttpRequests(cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annen approach - rett og slett sende en HTTP request til presentasjonslagene. Vil da ikke (med mindre vi gjør tilgjengelig noen ekstremt langlevde tokens) kunne komme like "dypt", siden vi ikke får autentisert. Men vil muligens kunne får JIT-a noe kode i presentasjonslagene, og fått lasta inn og cacha JWKs fra well-knowns selv med et ugyldig token.
En utfordring er at hosted services kjører før Kestrel begynner å lytte på portene. Vi kjører dette i en bakgrunns-task, så vi kan delaye en periode slik at vi er temmelig sikre på at vi ikke bare får connection refused.
// Don't bother with other runtimes (service, janitor) | ||
} | ||
|
||
private static Uri? GetLocalKestrelAdress() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hacky, men ASPNETCORE_URLS blir satt også for container apps og under lokal kjøring, så det burde kunne fungere.
_ = Task.Run(() => PerformWarmupAsync(warmupToken), warmupToken); | ||
|
||
// Return immediately so the host startup is not blocked so that health endpoints can be called | ||
return Task.CompletedTask; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inntil alt av hosted services er kjørt vil alle endpoints bare gi connection refused (det at Kestrel begynner å lytte på portene ser ut til å være det absolutt siste som skjer). Dette må vi hensynta i initial_delay
på startup-proben.
Description
Warmup service that performs a few serviceowner and end user requests via ISender
Related Issue(s)
Verification
Documentation
docs
-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)