core: Save app provisioning errors with context (#7070)

* fix(provisioning): remove app from apps map when its provision failed

* Clean up failed app provisioning with defer

* fix(provisioning): record apps that failed to provision with their error

* save the error when an app fails to initialize and return this error when this app is requested by a module

---------

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Co-authored-by: WeidiDeng <weidi_deng@icloud.com>
This commit is contained in:
Alexandre Daubois
2025-07-29 18:31:13 +02:00
committed by GitHub
parent b7ae39e906
commit fe41ff3c5b
2 changed files with 22 additions and 3 deletions

View File

@ -81,7 +81,10 @@ type Config struct {
// associated value.
AppsRaw ModuleMap `json:"apps,omitempty" caddy:"namespace="`
apps map[string]App
apps map[string]App
// failedApps is a map of apps that failed to provision with their underlying error.
failedApps map[string]error
storage certmagic.Storage
eventEmitter eventEmitter
@ -522,6 +525,7 @@ func provisionContext(newCfg *Config, replaceAdminServer bool) (Context, error)
// prepare the new config for use
newCfg.apps = make(map[string]App)
newCfg.failedApps = make(map[string]error)
// set up global storage and make it CertMagic's default storage, too
err = func() error {