Skip to content

Commit c523b61

Browse files
committed
add volume, volumeMount for listener
1 parent 38d5a55 commit c523b61

File tree

4 files changed

+131
-141
lines changed

4 files changed

+131
-141
lines changed

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,6 @@ spec:
129129
credentialsSecret:
130130
description: The name of the Secret object containing the admin user credentials and database connection details. Read the [getting started guide first steps](https://docs.stackable.tech/home/nightly/superset/getting_started/first_steps) to find out more.
131131
type: string
132-
listenerClass:
133-
default: cluster-internal
134-
description: |-
135-
This field controls which type of Service the Operator creates for this SupersetCluster:
136-
137-
* cluster-internal: Use a ClusterIP service
138-
139-
* external-unstable: Use a NodePort service
140-
141-
* external-stable: Use a LoadBalancer service
142-
143-
This is a temporary solution with the goal to keep yaml manifests forward compatible. In the future, this setting will control which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) will be used to expose the service, and ListenerClass names will stay the same, allowing for a non-breaking change.
144-
enum:
145-
- cluster-internal
146-
- external-unstable
147-
- external-stable
148-
type: string
149132
mapboxSecret:
150133
description: The name of a Secret object. The Secret should contain a key `connections.mapboxApiKey`. This is the API key required for map charts to work that use mapbox. The token should be in the JWT format.
151134
nullable: true
@@ -251,6 +234,14 @@ spec:
251234
description: Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the operator documentation for details.
252235
nullable: true
253236
type: string
237+
listenerClass:
238+
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose the webserver.
239+
enum:
240+
- cluster-internal
241+
- external-unstable
242+
- external-stable
243+
nullable: true
244+
type: string
254245
logging:
255246
default:
256247
containers: {}
@@ -479,6 +470,14 @@ spec:
479470
description: Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the operator documentation for details.
480471
nullable: true
481472
type: string
473+
listenerClass:
474+
description: This field controls which [ListenerClass](https://docs.stackable.tech/home/nightly/listener-operator/listenerclass.html) is used to expose the webserver.
475+
enum:
476+
- cluster-internal
477+
- external-unstable
478+
- external-stable
479+
nullable: true
480+
type: string
482481
logging:
483482
default:
484483
containers: {}

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

Lines changed: 75 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ use stackable_operator::{
1616
},
1717
},
1818
config::{
19-
fragment,
20-
fragment::{Fragment, ValidationError},
21-
merge::Merge,
19+
fragment::{self, Fragment, ValidationError},
20+
merge::{Atomic, Merge},
2221
},
2322
k8s_openapi::apimachinery::pkg::api::resource::Quantity,
2423
kube::{CustomResource, ResourceExt, runtime::reflector::ObjectRef},
@@ -48,6 +47,14 @@ pub const MAX_LOG_FILES_SIZE: MemoryQuantity = MemoryQuantity {
4847
unit: BinaryMultiple::Mebi,
4948
};
5049

50+
pub const LISTENER_VOLUME_NAME: &str = "listener";
51+
pub const LISTENER_VOLUME_DIR: &str = "/stackable/listener";
52+
53+
pub const APP_PORT_NAME: &str = "http";
54+
pub const APP_PORT: u16 = 8088;
55+
pub const METRICS_PORT_NAME: &str = "metrics";
56+
pub const METRICS_PORT: u16 = 9102;
57+
5158
const DEFAULT_NODE_GRACEFUL_SHUTDOWN_TIMEOUT: Duration = Duration::from_minutes_unchecked(2);
5259

5360
#[derive(Debug, Snafu)]
@@ -57,6 +64,12 @@ pub enum Error {
5764

5865
#[snafu(display("fragment validation failure"))]
5966
FragmentValidationFailure { source: ValidationError },
67+
68+
#[snafu(display("Configuration/Executor conflict!"))]
69+
NoRoleForExecutorFailure,
70+
71+
#[snafu(display("object has no associated namespace"))]
72+
NoNamespace,
6073
}
6174

6275
#[derive(Display, EnumIter, EnumString)]
@@ -157,20 +170,6 @@ pub mod versioned {
157170
#[serde(default)]
158171
pub cluster_operation: ClusterOperation,
159172

160-
/// This field controls which type of Service the Operator creates for this SupersetCluster:
161-
///
162-
/// * cluster-internal: Use a ClusterIP service
163-
///
164-
/// * external-unstable: Use a NodePort service
165-
///
166-
/// * external-stable: Use a LoadBalancer service
167-
///
168-
/// This is a temporary solution with the goal to keep yaml manifests forward compatible.
169-
/// In the future, this setting will control which [ListenerClass](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listenerclass.html)
170-
/// will be used to expose the service, and ListenerClass names will stay the same, allowing for a non-breaking change.
171-
#[serde(default)]
172-
pub listener_class: v1alpha1::CurrentlySupportedListenerClasses,
173-
174173
/// The name of a Secret object.
175174
/// The Secret should contain a key `connections.mapboxApiKey`.
176175
/// This is the API key required for map charts to work that use mapbox.
@@ -224,21 +223,10 @@ pub mod versioned {
224223
/// Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the operator documentation for details.
225224
#[fragment_attrs(serde(default))]
226225
pub graceful_shutdown_timeout: Option<Duration>,
227-
}
228226

229-
// TODO: Temporary solution until listener-operator is finished
230-
#[derive(Clone, Debug, Default, Display, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
231-
#[serde(rename_all = "PascalCase")]
232-
pub enum CurrentlySupportedListenerClasses {
233-
#[default]
234-
#[serde(rename = "cluster-internal")]
235-
ClusterInternal,
236-
237-
#[serde(rename = "external-unstable")]
238-
ExternalUnstable,
239-
240-
#[serde(rename = "external-stable")]
241-
ExternalStable,
227+
/// This field controls which [ListenerClass](DOCS_BASE_URL_PLACEHOLDER/listener-operator/listenerclass.html) is used to expose the webserver.
228+
#[serde(default)]
229+
pub listener_class: v1alpha1::SupportedListenerClasses,
242230
}
243231

244232
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
@@ -304,6 +292,35 @@ pub mod versioned {
304292
}
305293
}
306294

295+
#[derive(Clone, Debug, Default, Display, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
296+
#[serde(rename_all = "PascalCase")]
297+
pub enum SupportedListenerClasses {
298+
#[default]
299+
#[serde(rename = "cluster-internal")]
300+
#[strum(serialize = "cluster-internal")]
301+
ClusterInternal,
302+
303+
#[serde(rename = "external-unstable")]
304+
#[strum(serialize = "external-unstable")]
305+
ExternalUnstable,
306+
307+
#[serde(rename = "external-stable")]
308+
#[strum(serialize = "external-stable")]
309+
ExternalStable,
310+
}
311+
312+
impl Atomic for SupportedListenerClasses {}
313+
314+
impl SupportedListenerClasses {
315+
pub fn discoverable(&self) -> bool {
316+
match self {
317+
SupportedListenerClasses::ClusterInternal => false,
318+
SupportedListenerClasses::ExternalUnstable => true,
319+
SupportedListenerClasses::ExternalStable => true,
320+
}
321+
}
322+
}
323+
307324
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
308325
#[serde(rename_all = "camelCase")]
309326
pub struct SupersetCredentials {
@@ -406,18 +423,6 @@ impl FlaskAppConfigOptions for SupersetConfigOptions {
406423
}
407424
}
408425

409-
impl v1alpha1::CurrentlySupportedListenerClasses {
410-
pub fn k8s_service_type(&self) -> String {
411-
match self {
412-
v1alpha1::CurrentlySupportedListenerClasses::ClusterInternal => "ClusterIP".to_string(),
413-
v1alpha1::CurrentlySupportedListenerClasses::ExternalUnstable => "NodePort".to_string(),
414-
v1alpha1::CurrentlySupportedListenerClasses::ExternalStable => {
415-
"LoadBalancer".to_string()
416-
}
417-
}
418-
}
419-
}
420-
421426
impl v1alpha1::SupersetConfig {
422427
pub const CREDENTIALS_SECRET_PROPERTY: &'static str = "credentialsSecret";
423428
pub const MAPBOX_SECRET_PROPERTY: &'static str = "mapboxSecret";
@@ -440,6 +445,7 @@ impl v1alpha1::SupersetConfig {
440445
graceful_shutdown_timeout: Some(DEFAULT_NODE_GRACEFUL_SHUTDOWN_TIMEOUT),
441446
row_limit: None,
442447
webserver_timeout: None,
448+
listener_class: Some(SupportedListenerClasses::ClusterInternal),
443449
}
444450
}
445451
}
@@ -579,4 +585,30 @@ impl v1alpha1::SupersetCluster {
579585
tracing::debug!("Merged config: {:?}", conf_rolegroup);
580586
fragment::validate(conf_rolegroup).context(FragmentValidationFailureSnafu)
581587
}
588+
589+
pub fn merged_listener_class(
590+
&self,
591+
role: &SupersetRole,
592+
rolegroup_name: &String,
593+
) -> Result<Option<SupportedListenerClasses>, Error> {
594+
let listener_class_default = Some(SupportedListenerClasses::ClusterInternal);
595+
596+
let role = match role {
597+
SupersetRole::Node => self.spec.nodes.as_ref().context(UnknownSupersetRoleSnafu {
598+
role: role.to_string(),
599+
roles: vec![role.to_string()],
600+
})?,
601+
};
602+
603+
let mut listener_class_role = role.config.config.listener_class.to_owned();
604+
let mut listener_class_rolegroup = role
605+
.role_groups
606+
.get(rolegroup_name)
607+
.map(|rg| rg.config.config.listener_class.clone())
608+
.unwrap_or_default();
609+
listener_class_role.merge(&listener_class_default);
610+
listener_class_rolegroup.merge(&listener_class_role);
611+
tracing::debug!("Merged listener-class: {:?}", listener_class_rolegroup);
612+
Ok(listener_class_rolegroup)
613+
}
582614
}

rust/operator-binary/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ mod built_info {
5252
include!(concat!(env!("OUT_DIR"), "/built.rs"));
5353
}
5454

55-
pub const APP_PORT: u16 = 8088;
5655
pub const OPERATOR_NAME: &str = "superset.stackable.tech";
5756

5857
#[derive(Parser)]

0 commit comments

Comments
 (0)