Skip to content

fix: Return an error instead of panicking on an invalid TrinoCluster name - #973

Merged
lfrancke merged 1 commit into
mainfrom
fix/invalid-cluster-name-panic
Nov 12, 2026
Merged

lfrancke merged 1 commit into
mainfrom
fix/invalid-cluster-name-panic

Conversation

@lfrancke

@lfrancke lfrancke commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Description

Found this by accident.
A TrinoCluster name longer than 40 characters crashloops the operator with a panic. That's worse than not reconciling an object I'd say.

This fixes it by using the "cleanup" methods from operator-rs everywhere to validate the name before anything toutches it.
This moves the coordinator_pods method because it worked on the custom resource (it parsed metadata.name directly which caused this issue) and we didn't validate the name before we handed it over. The method is now moved to where it's actually used and we hand it the already validated strings. Only the name was a problem right now, but the role group names no longer have expect either.

 2026-11-11T21:26:55.308044Z  INFO reconciling object{object.ref=TrinoCluster.v1alpha1.trino.stackable.tech/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.trino-panic object.reason=object updated}: stackable_trino_operator::trino_controller: Starting reconcile                                                                                                                                                                  │
│                                                                                                                                                                                                                                                                                                                                                                                                                                     │
│ thread 'tokio-rt-worker' (7) panicked at rust/operator-binary/src/crd/mod.rs:544:14:                                                                                                                                                                                                                                                                                                                                                │
│ a TrinoCluster name is a valid cluster name: LengthExceeded { length: 45, max_length: 40 }                                                                                                                                                                                                                                                                                                                                          │
│ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace                                                                                                                                                                                                                                                                                                                                                       │
│                                                                                                                                                                                                                                                                                                                                                                                                                                     │
│ thread 'main' (1) panicked at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/core/src/ops/function.rs:250:5:                                                                                                                                                                                                                                                                                                               │
│ called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(25), "a TrinoCluster name is a valid cluster name: LengthExceeded { length: 45, max_length: 40 }", ...)                                                                                                                                                                                                                                                            │
│ stream closed: EOF for stackable-operators/trino-operator-deployment-6978cb7874-jl9v2 (trino-operator)

Definition of Done Checklist

  • Not all of these items are applicable to all PRs, the author should update this template to only leave the boxes in that are relevant
  • Please make sure all these things are done and tick the boxes

Author

  • Release note snippet added

Reviewer

  • Code contains useful comments
  • Test cases added
  • Changelog updated
  • Cargo.toml only contains references to git tags (not specific commits or branches)

Acceptance

  • Proper release label has been added
  • Release note snippet added

…name

A TrinoCluster name that is valid for Kubernetes but not a valid cluster name, for
example longer than 40 characters, made the operator panic while predicting the
coordinator pods. The panic crash-looped the operator, so no TrinoCluster was
reconciled while the object existed.

The name is now validated before anything uses it, and the coordinator pods are
predicted from the already validated role groups, so neither the cluster name nor
the role group names are parsed with expect.
@lfrancke
lfrancke marked this pull request as ready for review November 11, 2026 22:00
@lfrancke lfrancke moved this to Development: Waiting for Review in Stackable Engineering Nov 11, 2026
@siegfriedweber
siegfriedweber self-requested a review November 12, 2026 08:19
@siegfriedweber siegfriedweber moved this from Development: Waiting for Review to Development: In Review in Stackable Engineering Nov 12, 2026

@siegfriedweber siegfriedweber left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

PASS: kuttl/harness/smoke_trino-483_hive-4.2.1_opa-latest-1.20.2_hdfs-3.5.0_zookeeper-3.9.6_openshift-false (583.12s)

I also checked the other operators and they are not affected by this bug. However, the airflow-operator has a similar shape as this one had, but the cluster name is checked before the call:

https://github.com/stackabletech/airflow-operator/blob/8352a601b9965789421a31903a3ea999e087836d/rust/operator-binary/src/crd/mod.rs#L449

https://github.com/stackabletech/airflow-operator/blob/8352a601b9965789421a31903a3ea999e087836d/rust/operator-binary/src/controller/validate.rs#L114-L117

However, it should be fixed nevertheless.

@lfrancke
lfrancke added this pull request to the merge queue Nov 12, 2026
@lfrancke lfrancke moved this from Development: In Review to Development: Done in Stackable Engineering Nov 12, 2026
Merged via the queue into main with commit e42ac40 Nov 12, 2026
13 checks passed
@lfrancke
lfrancke deleted the fix/invalid-cluster-name-panic branch November 12, 2026 09:37
@lfrancke lfrancke added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Nov 12, 2026
@lfrancke

Copy link
Copy Markdown
Member Author

Release note

Previously, a TrinoCluster whose name was not a valid cluster name, for example one longer than 40 characters, crashed the trino-operator, which then restarted in a loop and reconciled no TrinoCluster at all. With this release, such a TrinoCluster fails its own reconcile with an error and all other TrinoClusters are reconciled as usual.

@lfrancke lfrancke moved this from Development: Done to Done in Stackable Engineering Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/26.11.0 release-note Denotes a PR that will be considered when it comes time to generate release notes. type/bug

Projects

Development

Successfully merging this pull request may close these issues.

2 participants