Skip to content

fix 503's when php runtime shuts down mid-incoming-request, hand them off to the new config runtime - #2709

Open
henderkes wants to merge 3 commits into
mainfrom
fix/worker-reload
Open

henderkes wants to merge 3 commits into
mainfrom
fix/worker-reload

Conversation

@henderkes

Copy link
Copy Markdown
Contributor

simplest approach I could think of.

when a request is still in flight when start() calls shutdown, close the done channel and drain all queued requests, returning ErrNotRunning.
frankenphp caddy module calls requestReload, waits for the new runtime, computes a reload key (to make sure we don't accidentally introduce any security issues) and then runs it through the full new replacement route chain. If no match for the key is found, 503

Comment thread caddy/module.go
Comment on lines +421 to +430
} else if auth, _ := h.(*caddyauth.Authentication); !slices.Contains(
[]string{"vars", "static_response", "invoke"}, caddy.GetModuleName(h),
) && (auth == nil || slices.ContainsFunc(
slices.Collect(maps.Keys(auth.Providers)),
func(name string) bool {
return name != "http_basic"
},
)) {
hdr, _ := h.(*headers.Handler)
inter, _ := h.(*intercept.Intercept)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm isn't there a way to just compare the json config of all the handlers? Naming all possible handlers like this feels a bit brittle

Comment thread threadregular.go
queuedRegularThreads.Add(-1)
metrics.DequeuedRequest()
metrics.StopRequest()
return ErrNotRunning

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably makes sense to return a custom error here

This branch has not been deployed

No deployments
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.

2 participants