Skip to content

Invalid HTTPS listener config is committed to master state before the worker rejects it, blocking a corrected reload #1301

Closed

Description

@Shine-neko

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

  1. Declare an HTTPS listener whose configuration cannot build a rustls context (for example an unparseable certificate or private key).
  2. Start sozu. The worker rejects the listener and logs the error; the listener does not serve.
  3. Fix the certificate on disk and reload.
  4. AddHttpsListener is rejected with StateError::Exists because 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 ConfigState entry when fan-out to the workers fails.
  • Or, at minimum, make StateError::Exists distinguish "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

  1. FlorentinDUBOIS commented on Jul 24, 2026

    @FlorentinDUBOIS
    Collaborator

    Thanks you for the report, I will dig in

  2. added a commit that references this issue on Aug 10, 2026
    967b3f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions