Skip to content

Operator should tolerate missing optional CRDs instead of exiting at startup #166

Description

@pcholakov

Problem

The operator runs all three controllers (restatecluster, restatecloudenvironment, restatedeployment) in a single process via tokio::join! in src/main.rs. The restatecloudenvironment controller does a preflight list and hard-exits if it fails:

// src/controllers/restatecloudenvironment/controller.rs:172
if let Err(e) = rce.list(&ListParams::default().limit(1)).await {
    error!("RestateCloudEnvironment is not queryable; {e:?}. Is the CRD installed?");
    std::process::exit(1);
}

So if the RestateCloudEnvironment CRD is not installed, the entire operator process exits and crash-loops — even for a deployment that only uses RestateCluster and never touches RestateCloudEnvironment.

Impact

BYOC only uses RestateCluster, but must install all three CRDs (RestateCloudEnvironment and RestateDeployment included) purely so the operator can boot. As of restatedev/nuon-byoc#129 the chart's CRDs are gated off (installCrds: false, CRDs vendored out-of-band), so BYOC now vendors all three CRDs just to satisfy this startup requirement — carrying two CRDs it does not otherwise use.

Proposal

Make each controller tolerant of its CRD being absent: if the CRD/API isn't listable at startup, log a warning and skip starting that controller instead of exiting the process. The operator then runs whatever controllers have their CRDs present. (Optionally gate controllers behind explicit flags/values so an operator can be run in a "RestateCluster-only" mode deliberately.)

Once this lands, BYOC can vendor only restateclusters and drop the two unused CRDs.

Related cleanup

The restatedeployment controller's startup guard looks like a copy-paste bug — it lists services while the error message says "RestateDeployment is not queryable":

// src/controllers/restatedeployment/controller.rs (~line 1258)
if let Err(e) = services.list(&ListParams::default().limit(1)).await {
    error!("RestateDeployment is not queryable; {e:?}. Is the CRD installed?");
    std::process::exit(1);
}

Core Service objects are always listable, so this check never actually detects a missing RestateDeployment CRD. Worth fixing (or removing) as part of this work.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions