Repository navigation
Description
Summary
An HTTPS listener whose configuration is rejected by the worker still gets recorded in the master's ConfigState. A subsequent reload with corrected configuration is then refused with StateError::Exists and never reaches the workers, so the listener stays down until it is explicitly removed or the process is restarted.
Why it happens
The master records the listener without validating it. ConfigState::add_https_listener only checks whether the address is already occupied, then inserts:
// command/src/state.rs (~535)
fn add_https_listener(&mut self, listener: &HttpsListenerConfig) -> Result<(), StateError> {
let address: SocketAddr = listener.address.into();
match self.https_listeners.entry(address) {
BTreeMapEntry::Vacant(vacant_entry) => vacant_entry.insert(listener.clone()),
BTreeMapEntry::Occupied(_) => return Err(StateError::Exists { .. }),
};
// ...
}Everything that can make a listener configuration unusable is only discovered later, worker-side, when the rustls context is built:
// lib/src/https.rs (~1355), reached from HttpsListener::add_listener
let server_config = Arc::new(Self::create_rustls_context(&config, resolver.to_owned())?);So the ordering is: master commits the state, then fan-out to the worker fails. The failed fan-out is not rolled back.
Reproduction
- Declare an HTTPS listener whose configuration cannot build a rustls context (for example an unparseable certificate or private key).
- Start sozu. The worker rejects the listener and logs the error; the listener does not serve.
- Fix the certificate on disk and reload.
AddHttpsListeneris rejected withStateError::Existsbecause the master still holds the address. The corrected configuration never reaches the worker, and the listener remains unavailable.
Recovering requires removing the listener explicitly or restarting the process.
Impact
Not a traffic-path or security problem: it only triggers on a configuration that was already invalid, and the failure is visible in the worker logs. The cost is operational. The natural fix-and-reload loop silently does nothing, and the reason (an address held by master state for a listener that never started) is not obvious from the error message.
Possible directions
- Validate the listener configuration before mutating master state, so an invalid listener never occupies an address.
- Or roll back the
ConfigStateentry when fan-out to the workers fails. - Or, at minimum, make
StateError::Existsdistinguish "a listener is running on this address" from "an address is reserved by a listener that failed to start", so the message points at the actual remedy.
I have no strong preference between these; happy to work on whichever direction you prefer.
Notes
This is long-standing behavior rather than a regression, and it is not specific to any one field: any configuration that fails in create_rustls_context reaches the worker the same way. Filing it separately so it can be prioritized on its own.
Activity
FlorentinDUBOIS commentedon Jul 24, 2026
Thanks you for the report, I will dig in
fix(command): forward timed_out and tag listener-validation failures …
fix(command): revert main-process state when every worker rejects a c…
fix(command): forward timed_out and tag listener-validation failures …
fix(command): validate listener config before committing to main-proc…
fix(command): validate http frontends before committing them to the m…