Skip to content

Conversation

@Compy
Copy link
Contributor

@Compy Compy commented May 7, 2025

…lizations in provisionContext()

Fixes #7001

Background

When Caddy starts, provisionContext calls replaceLocalAdminServer which calls provisionAdminRouters. Changes introduced in #6997 to make sure that module state is accurately reconstructed across module (re)loads makes the assumption that the config.apps member exists at the time the provisioner is called.

However in modules like caddypki/adminapi.go, the provisioner tries to access the pki app, which in many situations does have a configuration entry, which triggers the module loader. The module loader (LoadModuleByID()) then fails to assign the app to ctx.cfg.apps because it hasn't been initialized yet.

Solution proposed in this PR
This modification moves the local admin server replacement to the end of the context provisioning phase, which ensures that the Config.apps map is initialized, so that the module loader (which can be called from various provisioners via AppIfConfigured()) can work correctly.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thank you!

I think this should be alright, we will give it a shot and hopefully patch it up before any other releases if needed :) Thanks again!

@mholt mholt merged commit 051e73a into caddyserver:master May 8, 2025
20 checks passed
@mholt mholt added this to the v2.10.1 milestone May 8, 2025
@Compy Compy deleted the bugfix-7001-provisioner-init branch May 13, 2025 01:52
mohammed90 pushed a commit to cedricziel/caddy that referenced this pull request Aug 29, 2025
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

Successfully merging this pull request may close these issues.

Simple Caddyfile crashes after #6997

2 participants