Skip to content

Cascade doesn't save state on SIGTERM. #573

Description

@ximon18

PR #512 tests that zone persistence works.

PR #550 implements a first draft version of zone persistence.

However the test added in #512 doesn't work. After updating it to save state now instead of mark it dirty to save after a delay it still didn't work. While investigating why I realized that the pkill issued by the test to stop Cascade doesn't cause Cascade to write its state to disk.

Looking in main.rs Cascade waits for CTRL-C but not for SIGTERM.

Replacing:

        let res = match tokio::signal::ctrl_c().await {
            Ok(_) => ExitCode::SUCCESS,
            Err(error) => {
                error!("Listening for CTRL-C (SIGINT) failed: {error}");
                ExitCode::FAILURE
            }
        };

With:

        info!("Running");
        sigterm::wait().await;
        info!("Shutting down");

Resolves the issue (using the sigterm crate), and also makes it clear when Cascade has started and when it is stopping, the latter wasn't recorded anywhere currently in the logs.

I understood that some thought had gone into ensuring state was persisted so I'm assuming I am missing something, and am not sure that we want a dependency on another crate, both of which are why this is being reported as an issue rather than as a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions