Skip to content

Commit aee4fc2

Browse files
committed
use pvcs for externally-reachable endpoints
1 parent 80adf71 commit aee4fc2

File tree

10 files changed

+199
-92
lines changed

10 files changed

+199
-92
lines changed

deploy/helm/hbase-operator/crds/crds.yaml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ spec:
197197
nullable: true
198198
type: string
199199
listenerClass:
200-
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup. All roles should have a direct ListenerClass, such as `cluster-internal` or `external-unstable`.
200+
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup.
201+
enum:
202+
- cluster-internal
203+
- external-unstable
204+
- external-stable
201205
nullable: true
202206
type: string
203207
logging:
@@ -451,7 +455,11 @@ spec:
451455
nullable: true
452456
type: string
453457
listenerClass:
454-
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup. All roles should have a direct ListenerClass, such as `cluster-internal` or `external-unstable`.
458+
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup.
459+
enum:
460+
- cluster-internal
461+
- external-unstable
462+
- external-stable
455463
nullable: true
456464
type: string
457465
logging:
@@ -686,7 +694,11 @@ spec:
686694
nullable: true
687695
type: string
688696
listenerClass:
689-
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup. All roles should have a direct ListenerClass, such as `cluster-internal` or `external-unstable`.
697+
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup.
698+
enum:
699+
- cluster-internal
700+
- external-unstable
701+
- external-stable
690702
nullable: true
691703
type: string
692704
logging:
@@ -968,7 +980,11 @@ spec:
968980
nullable: true
969981
type: string
970982
listenerClass:
971-
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup. All roles should have a direct ListenerClass, such as `cluster-internal` or `external-unstable`.
983+
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup.
984+
enum:
985+
- cluster-internal
986+
- external-unstable
987+
- external-stable
972988
nullable: true
973989
type: string
974990
logging:
@@ -1231,7 +1247,11 @@ spec:
12311247
nullable: true
12321248
type: string
12331249
listenerClass:
1234-
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup. All roles should have a direct ListenerClass, such as `cluster-internal` or `external-unstable`.
1250+
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup.
1251+
enum:
1252+
- cluster-internal
1253+
- external-unstable
1254+
- external-stable
12351255
nullable: true
12361256
type: string
12371257
logging:
@@ -1485,7 +1505,11 @@ spec:
14851505
nullable: true
14861506
type: string
14871507
listenerClass:
1488-
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup. All roles should have a direct ListenerClass, such as `cluster-internal` or `external-unstable`.
1508+
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose this rolegroup.
1509+
enum:
1510+
- cluster-internal
1511+
- external-unstable
1512+
- external-stable
14891513
nullable: true
14901514
type: string
14911515
logging:

rust/operator-binary/src/crd/mod.rs

Lines changed: 84 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ pub const HBASE_REST_UI_PORT: u16 = 8085;
8888
// Newer versions use the same port as the UI because Hbase provides it's own metrics API
8989
pub const METRICS_PORT: u16 = 9100;
9090

91-
pub const DEFAULT_LISTENER_CLASS: &str = "cluster-internal";
91+
pub const DEFAULT_LISTENER_CLASS: SupportedListenerClasses =
92+
SupportedListenerClasses::ClusterInternal;
9293
pub const LISTENER_VOLUME_NAME: &str = "listener";
9394
pub const LISTENER_VOLUME_DIR: &str = "/stackable/listener";
9495

@@ -666,46 +667,54 @@ impl v1alpha1::HbaseCluster {
666667
&self,
667668
client: &stackable_operator::client::Client,
668669
role: &HbaseRole,
670+
merged_config: &AnyServiceConfig,
669671
hbase_version: &str,
670672
) -> Result<Vec<HbasePodRef>, Error> {
671-
let pod_refs = self.pod_refs(role, hbase_version)?;
672-
try_join_all(pod_refs.into_iter().map(|pod_ref| async {
673-
let listener_name = format!("{}-{LISTENER_VOLUME_NAME}", pod_ref.pod_name);
674-
let listener_ref =
675-
|| ObjectRef::<Listener>::new(&listener_name).within(&pod_ref.namespace);
676-
let pod_obj_ref =
677-
|| ObjectRef::<Pod>::new(&pod_ref.pod_name).within(&pod_ref.namespace);
678-
let listener = client
679-
.get::<Listener>(&listener_name, &pod_ref.namespace)
680-
.await
681-
.context(GetPodListenerSnafu {
682-
listener: listener_ref(),
683-
pod: pod_obj_ref(),
684-
})?;
685-
let listener_address = listener
686-
.status
687-
.and_then(|s| s.ingress_addresses?.into_iter().next())
688-
.context(PodListenerHasNoAddressSnafu {
689-
listener: listener_ref(),
690-
pod: pod_obj_ref(),
691-
})?;
692-
Ok(HbasePodRef {
693-
fqdn_override: Some(listener_address.address),
694-
ports: listener_address
695-
.ports
696-
.into_iter()
697-
.map(|(port_name, port)| {
698-
let port = u16::try_from(port).context(PortOutOfBoundsSnafu {
699-
port_name: &port_name,
700-
port,
701-
})?;
702-
Ok((port_name, port))
703-
})
704-
.collect::<Result<_, _>>()?,
705-
..pod_ref
706-
})
707-
}))
708-
.await
673+
// only externally-reachable listeners are relevant
674+
if merged_config.listener_class().discoverable() {
675+
let pod_refs = self.pod_refs(role, hbase_version)?;
676+
try_join_all(pod_refs.into_iter().map(|pod_ref| async {
677+
// N.B. use the naming convention for persistent listener volumes as we
678+
// have specified above that we only want externally-reachable endpoints.
679+
let listener_name = format!("{LISTENER_VOLUME_NAME}-{}", pod_ref.pod_name);
680+
let listener_ref =
681+
|| ObjectRef::<Listener>::new(&listener_name).within(&pod_ref.namespace);
682+
let pod_obj_ref =
683+
|| ObjectRef::<Pod>::new(&pod_ref.pod_name).within(&pod_ref.namespace);
684+
let listener = client
685+
.get::<Listener>(&listener_name, &pod_ref.namespace)
686+
.await
687+
.context(GetPodListenerSnafu {
688+
listener: listener_ref(),
689+
pod: pod_obj_ref(),
690+
})?;
691+
let listener_address = listener
692+
.status
693+
.and_then(|s| s.ingress_addresses?.into_iter().next())
694+
.context(PodListenerHasNoAddressSnafu {
695+
listener: listener_ref(),
696+
pod: pod_obj_ref(),
697+
})?;
698+
Ok(HbasePodRef {
699+
fqdn_override: Some(listener_address.address),
700+
ports: listener_address
701+
.ports
702+
.into_iter()
703+
.map(|(port_name, port)| {
704+
let port = u16::try_from(port).context(PortOutOfBoundsSnafu {
705+
port_name: &port_name,
706+
port,
707+
})?;
708+
Ok((port_name, port))
709+
})
710+
.collect::<Result<_, _>>()?,
711+
..pod_ref
712+
})
713+
}))
714+
.await
715+
} else {
716+
Ok(vec![])
717+
}
709718
}
710719
}
711720

@@ -878,7 +887,7 @@ impl HbaseRole {
878887
affinity: get_affinity(cluster_name, self, hdfs_discovery_cm_name),
879888
graceful_shutdown_timeout: Some(graceful_shutdown_timeout),
880889
requested_secret_lifetime: Some(requested_secret_lifetime),
881-
listener_class: Some(DEFAULT_LISTENER_CLASS.to_string()),
890+
listener_class: Some(DEFAULT_LISTENER_CLASS),
882891
}
883892
}
884893

@@ -979,7 +988,7 @@ impl AnyConfigFragment {
979988
cli_opts: None,
980989
},
981990
requested_secret_lifetime: Some(HbaseRole::DEFAULT_REGION_SECRET_LIFETIME),
982-
listener_class: Some(DEFAULT_LISTENER_CLASS.to_string()),
991+
listener_class: Some(DEFAULT_LISTENER_CLASS),
983992
})
984993
}
985994
HbaseRole::RestServer => AnyConfigFragment::RestServer(HbaseConfigFragment {
@@ -991,7 +1000,7 @@ impl AnyConfigFragment {
9911000
HbaseRole::DEFAULT_REST_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT,
9921001
),
9931002
requested_secret_lifetime: Some(HbaseRole::DEFAULT_REST_SECRET_LIFETIME),
994-
listener_class: Some(DEFAULT_LISTENER_CLASS.to_string()),
1003+
listener_class: Some(DEFAULT_LISTENER_CLASS),
9951004
}),
9961005
HbaseRole::Master => AnyConfigFragment::Master(HbaseConfigFragment {
9971006
hbase_rootdir: None,
@@ -1002,7 +1011,7 @@ impl AnyConfigFragment {
10021011
HbaseRole::DEFAULT_MASTER_GRACEFUL_SHUTDOWN_TIMEOUT,
10031012
),
10041013
requested_secret_lifetime: Some(HbaseRole::DEFAULT_MASTER_SECRET_LIFETIME),
1005-
listener_class: Some(DEFAULT_LISTENER_CLASS.to_string()),
1014+
listener_class: Some(DEFAULT_LISTENER_CLASS),
10061015
}),
10071016
}
10081017
}
@@ -1082,8 +1091,7 @@ pub struct HbaseConfig {
10821091
pub requested_secret_lifetime: Option<Duration>,
10831092

10841093
/// This field controls which [ListenerClass](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listenerclass.html) is used to expose this rolegroup.
1085-
/// All roles should have a direct ListenerClass, such as `cluster-internal` or `external-unstable`.
1086-
pub listener_class: String,
1094+
pub listener_class: SupportedListenerClasses,
10871095
}
10881096

10891097
impl Configuration for HbaseConfigFragment {
@@ -1239,8 +1247,7 @@ pub struct RegionServerConfig {
12391247
pub region_mover: RegionMover,
12401248

12411249
/// This field controls which [ListenerClass](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listenerclass.html) is used to expose this rolegroup.
1242-
/// All roles should have a direct ListenerClass, such as `cluster-internal` or `external-unstable`.
1243-
pub listener_class: String,
1250+
pub listener_class: SupportedListenerClasses,
12441251
}
12451252

12461253
impl Configuration for RegionServerConfigFragment {
@@ -1312,6 +1319,35 @@ impl Configuration for RegionServerConfigFragment {
13121319
}
13131320
}
13141321

1322+
#[derive(Clone, Debug, Default, Display, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
1323+
#[serde(rename_all = "PascalCase")]
1324+
pub enum SupportedListenerClasses {
1325+
#[default]
1326+
#[serde(rename = "cluster-internal")]
1327+
#[strum(serialize = "cluster-internal")]
1328+
ClusterInternal,
1329+
1330+
#[serde(rename = "external-unstable")]
1331+
#[strum(serialize = "external-unstable")]
1332+
ExternalUnstable,
1333+
1334+
#[serde(rename = "external-stable")]
1335+
#[strum(serialize = "external-stable")]
1336+
ExternalStable,
1337+
}
1338+
1339+
impl Atomic for SupportedListenerClasses {}
1340+
1341+
impl SupportedListenerClasses {
1342+
pub fn discoverable(&self) -> bool {
1343+
match self {
1344+
SupportedListenerClasses::ClusterInternal => false,
1345+
SupportedListenerClasses::ExternalUnstable => true,
1346+
SupportedListenerClasses::ExternalStable => true,
1347+
}
1348+
}
1349+
}
1350+
13151351
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
13161352
#[serde(rename_all = "camelCase")]
13171353
pub struct HbaseClusterStatus {
@@ -1361,7 +1397,7 @@ impl AnyServiceConfig {
13611397
AnyServiceConfig::RestServer(config) => config.requested_secret_lifetime,
13621398
}
13631399
}
1364-
pub fn listener_class(&self) -> String {
1400+
pub fn listener_class(&self) -> SupportedListenerClasses {
13651401
match self {
13661402
AnyServiceConfig::Master(config) => config.listener_class.clone(),
13671403
AnyServiceConfig::RegionServer(config) => config.listener_class.clone(),

0 commit comments

Comments
 (0)