chore: Consolidate error enums and use expect where possible - #1084
Open
adwk67 wants to merge 3 commits into
Open
chore: Consolidate error enums and use expect where possible#1084adwk67 wants to merge 3 commits into
adwk67 wants to merge 3 commits into
Conversation
12 tasks
adwk67
marked this pull request as ready for review
September 8, 2026 09:58
maltesander
requested changes
Sep 8, 2026
| /// The resulting volume will contain TLS certificates with the FQDN reported in the applicable [ListenerStatus]. | ||
| /// | ||
| /// [ListenerStatus]: ::stackable_operator::crd::listener::v1alpha1::ListenerStatus | ||
| fn create_server_tls_volume( |
Member
There was a problem hiding this comment.
This one can panic now and should have a comment saying so?
| /// Creates ephemeral volumes to mount the `SecretClass` with the pod scope into the Pods. | ||
| /// | ||
| /// The resulting volume will contain TLS certificates with the FQDN of the Pod in relation to the StatefulSet's headless service. | ||
| fn create_quorum_tls_volume( |
Member
There was a problem hiding this comment.
This one can panic now and should have a comment saying so?
| "The string `<cluster_name>-<role_name>` must not exceed the limit of Listener names." | ||
| ); | ||
| // Both halves are RFC 1123 labels joined by a dash, which is a valid RFC 1123 subdomain. | ||
| let _ = ClusterName::IS_RFC_1123_SUBDOMAIN_NAME; |
Member
There was a problem hiding this comment.
This is also used as a service name and as the first label of the FQDN, so it shouldbe a label with max 63 chars and no dots? This would affect the check above.
Suggested change
| let _ = ClusterName::IS_RFC_1123_SUBDOMAIN_NAME; | |
| let _ = ClusterName::IS_RFC_1035_LABEL_NAME; |
Member
There was a problem hiding this comment.
I would just document that the returned ListenerName is an RFC 1035 label name and create a unit test:
diff --git a/rust/operator-binary/src/crd/mod.rs b/rust/operator-binary/src/crd/mod.rs
index d2df7a1..fc81e09 100644
--- a/rust/operator-binary/src/crd/mod.rs
+++ b/rust/operator-binary/src/crd/mod.rs
@@ -50,6 +50,8 @@ pub mod tls;
///
/// Lives in the `crd` module (rather than the controller build tree) because it is shared by both
/// controllers and by [`role_listener_fqdn`].
+///
+/// The returned ListenerName is a lowercase RFC 1035 label name (checked by a unit test).
pub fn role_listener_name(cluster_name: &ClusterName, zk_role: &ZookeeperRole) -> ListenerName {
const _: () = assert!(
ClusterName::MAX_LENGTH + 1 /* dash */ + RoleName::MAX_LENGTH <= ListenerName::MAX_LENGTH,
@@ -340,7 +342,7 @@ pub mod versioned {
}
}
-#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
+#[derive(Clone, Debug, Eq, EnumIter, Hash, Ord, PartialEq, PartialOrd)]
pub enum ZookeeperRole {
Server,
}
@@ -478,6 +480,7 @@ mod tests {
use stackable_operator::{
commons::networking::DomainName, versioned::test_utils::RoundtripTestData,
};
+ use strum::IntoEnumIterator;
use super::*;
@@ -774,4 +777,22 @@ mod tests {
.expect("Failed to parse ZookeeperZnodeSpec YAML")
}
}
+
+ #[test]
+ fn role_listener_name_is_rfc_1035_label_name() {
+ // Every ClusterName is a valid RFC 1035 label name, so we use just some string with maximum
+ // length.
+ let _ = ClusterName::IS_RFC_1035_LABEL_NAME;
+ let cluster_name = ClusterName::from_str_unsafe(&"a".repeat(ClusterName::MAX_LENGTH));
+
+ for role in ZookeeperRole::iter() {
+ let role_listener_name = role_listener_name(&cluster_name, &role);
+ assert!(
+ stackable_operator::validation::is_lowercase_rfc_1035_label(
+ role_listener_name.as_ref()
+ )
+ .is_ok()
+ );
+ }
+ }
}
maltesander
reviewed
Sep 8, 2026
maltesander
left a comment
Member
There was a problem hiding this comment.
Just nits, Changelog is missing.
Co-authored-by: maltesander <contact@maltesander.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of stackabletech/issues#883
Definition of Done Checklist
Author
Reviewer
Acceptance
type/deprecationlabel & add to the deprecation scheduletype/experimentallabel & add to the experimental features tracker