Skip to content

Commit 5423c26

Browse files
committed
chore: Version SparkHistoryServer
1 parent ecf0c81 commit 5423c26

File tree

6 files changed

+52
-42
lines changed

6 files changed

+52
-42
lines changed

deploy/helm/spark-k8s-operator/crds/crds.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ spec:
998998
kind: SparkHistoryServer
999999
plural: sparkhistoryservers
10001000
shortNames:
1001-
- shs
1001+
- sparkhist
10021002
singular: sparkhistoryserver
10031003
scope: Namespaced
10041004
versions:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ mod test {
3636
role_utils::RoleGroupRef,
3737
};
3838

39-
use crate::crd::{constants::HISTORY_ROLE_NAME, history::SparkHistoryServer};
39+
use crate::crd::{constants::HISTORY_ROLE_NAME, history::v1alpha1};
4040

4141
#[test]
4242
pub fn test_history_affinity_defaults() {
@@ -62,7 +62,7 @@ mod test {
6262
"#;
6363

6464
let deserializer = serde_yaml::Deserializer::from_str(input);
65-
let history: SparkHistoryServer =
65+
let history: v1alpha1::SparkHistoryServer =
6666
serde_yaml::with::singleton_map_recursive::deserialize(deserializer).unwrap();
6767
let expected: StackableAffinity = StackableAffinity {
6868
node_affinity: None,

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use stackable_operator::{
2828
schemars::{self, JsonSchema},
2929
time::Duration,
3030
};
31+
use stackable_versioned::versioned;
3132
use strum::{Display, EnumIter};
3233

3334
use crate::crd::{affinity::history_affinity, constants::*, logdir::ResolvedLogDir};
@@ -51,19 +52,21 @@ pub enum Error {
5152
/// A Spark cluster history server component. This resource is managed by the Stackable operator
5253
/// for Apache Spark. Find more information on how to use it in the
5354
/// [operator documentation](DOCS_BASE_URL_PLACEHOLDER/spark-k8s/usage-guide/history-server).
54-
#[derive(Clone, CustomResource, Debug, Deserialize, JsonSchema, Serialize)]
55-
#[kube(
56-
group = "spark.stackable.tech",
57-
version = "v1alpha1",
58-
kind = "SparkHistoryServer",
59-
shortname = "shs",
60-
namespaced,
61-
crates(
62-
kube_core = "stackable_operator::kube::core",
63-
k8s_openapi = "stackable_operator::k8s_openapi",
64-
schemars = "stackable_operator::schemars"
55+
#[versioned(
56+
version(name = "v1alpha1"),
57+
k8s(
58+
group = "spark.stackable.tech",
59+
kind = "SparkHistoryServer",
60+
shortname = "sparkhist",
61+
namespaced,
62+
crates(
63+
kube_core = "stackable_operator::kube::core",
64+
k8s_openapi = "stackable_operator::k8s_openapi",
65+
schemars = "stackable_operator::schemars"
66+
)
6567
)
6668
)]
69+
#[derive(Clone, CustomResource, Debug, Deserialize, JsonSchema, Serialize)]
6770
#[serde(rename_all = "camelCase")]
6871
pub struct SparkHistoryServerSpec {
6972
pub image: ProductImage,
@@ -129,7 +132,7 @@ impl CurrentlySupportedListenerClasses {
129132
}
130133
}
131134

132-
impl SparkHistoryServer {
135+
impl v1alpha1::SparkHistoryServer {
133136
/// Returns a reference to the role. Raises an error if the role is not defined.
134137
pub fn role(&self) -> &Role<HistoryConfigFragment> {
135138
&self.spec.nodes
@@ -138,7 +141,7 @@ impl SparkHistoryServer {
138141
/// Returns a reference to the role group. Raises an error if the role or role group are not defined.
139142
pub fn rolegroup(
140143
&self,
141-
rolegroup_ref: &RoleGroupRef<SparkHistoryServer>,
144+
rolegroup_ref: &RoleGroupRef<Self>,
142145
) -> Result<RoleGroup<HistoryConfigFragment, GenericProductSpecificCommonConfig>, Error> {
143146
self.spec
144147
.nodes
@@ -152,7 +155,7 @@ impl SparkHistoryServer {
152155

153156
pub fn merged_config(
154157
&self,
155-
rolegroup_ref: &RoleGroupRef<SparkHistoryServer>,
158+
rolegroup_ref: &RoleGroupRef<Self>,
156159
) -> Result<HistoryConfig, Error> {
157160
// Initialize the result with all default values as baseline
158161
let conf_defaults = HistoryConfig::default_config(&self.name_any());
@@ -184,7 +187,7 @@ impl SparkHistoryServer {
184187
.map(i32::from)
185188
}
186189

187-
pub fn cleaner_rolegroups(&self) -> Vec<RoleGroupRef<SparkHistoryServer>> {
190+
pub fn cleaner_rolegroups(&self) -> Vec<RoleGroupRef<Self>> {
188191
let mut rgs = vec![];
189192
for (rg_name, rg_config) in &self.spec.nodes.role_groups {
190193
if let Some(true) = rg_config.config.config.cleaner {
@@ -444,7 +447,7 @@ impl HistoryConfig {
444447
}
445448

446449
impl Configuration for HistoryConfigFragment {
447-
type Configurable = SparkHistoryServer;
450+
type Configurable = v1alpha1::SparkHistoryServer;
448451

449452
fn compute_env(
450453
&self,
@@ -515,7 +518,7 @@ mod test {
515518
"#};
516519

517520
let deserializer = serde_yaml::Deserializer::from_str(input);
518-
let history: SparkHistoryServer =
521+
let history: v1alpha1::SparkHistoryServer =
519522
serde_yaml::with::singleton_map_recursive::deserialize(deserializer).unwrap();
520523

521524
let log_dir = ResolvedLogDir::S3(S3LogDir {

rust/operator-binary/src/history/history_controller.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ use crate::{
5757
VOLUME_MOUNT_NAME_CONFIG, VOLUME_MOUNT_NAME_LOG, VOLUME_MOUNT_NAME_LOG_CONFIG,
5858
VOLUME_MOUNT_PATH_CONFIG, VOLUME_MOUNT_PATH_LOG, VOLUME_MOUNT_PATH_LOG_CONFIG,
5959
},
60-
history,
61-
history::{HistoryConfig, SparkHistoryServer, SparkHistoryServerContainer},
60+
history::{self, v1alpha1, HistoryConfig, SparkHistoryServerContainer},
6261
logdir::ResolvedLogDir,
6362
tlscerts, to_spark_env_sh_string,
6463
},
@@ -214,7 +213,7 @@ impl ReconcilerError for Error {
214213
}
215214
/// Updates the status of the SparkApplication that started the pod.
216215
pub async fn reconcile(
217-
shs: Arc<DeserializeGuard<SparkHistoryServer>>,
216+
shs: Arc<DeserializeGuard<v1alpha1::SparkHistoryServer>>,
218217
ctx: Arc<Ctx>,
219218
) -> Result<Action> {
220219
tracing::info!("Starting reconcile history server");
@@ -357,7 +356,7 @@ pub async fn reconcile(
357356
}
358357

359358
pub fn error_policy(
360-
_obj: Arc<DeserializeGuard<SparkHistoryServer>>,
359+
_obj: Arc<DeserializeGuard<v1alpha1::SparkHistoryServer>>,
361360
error: &Error,
362361
_ctx: Arc<Ctx>,
363362
) -> Action {
@@ -369,11 +368,11 @@ pub fn error_policy(
369368

370369
#[allow(clippy::result_large_err)]
371370
fn build_config_map(
372-
shs: &SparkHistoryServer,
371+
shs: &v1alpha1::SparkHistoryServer,
373372
config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
374373
merged_config: &HistoryConfig,
375374
app_version_label: &str,
376-
rolegroupref: &RoleGroupRef<SparkHistoryServer>,
375+
rolegroupref: &RoleGroupRef<v1alpha1::SparkHistoryServer>,
377376
log_dir: &ResolvedLogDir,
378377
vector_aggregator_address: Option<&str>,
379378
) -> Result<ConfigMap, Error> {
@@ -441,9 +440,9 @@ fn build_config_map(
441440

442441
#[allow(clippy::result_large_err)]
443442
fn build_stateful_set(
444-
shs: &SparkHistoryServer,
443+
shs: &v1alpha1::SparkHistoryServer,
445444
resolved_product_image: &ResolvedProductImage,
446-
rolegroupref: &RoleGroupRef<SparkHistoryServer>,
445+
rolegroupref: &RoleGroupRef<v1alpha1::SparkHistoryServer>,
447446
log_dir: &ResolvedLogDir,
448447
merged_config: &HistoryConfig,
449448
serviceaccount: &ServiceAccount,
@@ -609,10 +608,10 @@ fn build_stateful_set(
609608

610609
#[allow(clippy::result_large_err)]
611610
fn build_service(
612-
shs: &SparkHistoryServer,
611+
shs: &v1alpha1::SparkHistoryServer,
613612
app_version_label: &str,
614613
role: &str,
615-
group: Option<&RoleGroupRef<SparkHistoryServer>>,
614+
group: Option<&RoleGroupRef<v1alpha1::SparkHistoryServer>>,
616615
) -> Result<Service, Error> {
617616
let group_name = match group {
618617
Some(rgr) => rgr.role_group.clone(),
@@ -677,7 +676,7 @@ fn build_service(
677676
// See: https://github.com/stackabletech/spark-k8s-operator/issues/499
678677
#[allow(clippy::result_large_err)]
679678
fn build_history_role_serviceaccount(
680-
shs: &SparkHistoryServer,
679+
shs: &v1alpha1::SparkHistoryServer,
681680
app_version_label: &str,
682681
) -> Result<(ServiceAccount, RoleBinding)> {
683682
let sa = ServiceAccount {
@@ -718,9 +717,9 @@ fn build_history_role_serviceaccount(
718717

719718
#[allow(clippy::result_large_err)]
720719
fn spark_defaults(
721-
shs: &SparkHistoryServer,
720+
shs: &v1alpha1::SparkHistoryServer,
722721
log_dir: &ResolvedLogDir,
723-
rolegroupref: &RoleGroupRef<SparkHistoryServer>,
722+
rolegroupref: &RoleGroupRef<v1alpha1::SparkHistoryServer>,
724723
) -> Result<String, Error> {
725724
let mut log_dir_settings = log_dir.history_server_spark_config().context(LogDirSnafu)?;
726725

@@ -782,8 +781,8 @@ fn labels<'a, T>(
782781
/// group should have a replica count of 0 or 1.
783782
#[allow(clippy::result_large_err)]
784783
fn cleaner_config(
785-
shs: &SparkHistoryServer,
786-
rolegroup_ref: &RoleGroupRef<SparkHistoryServer>,
784+
shs: &v1alpha1::SparkHistoryServer,
785+
rolegroup_ref: &RoleGroupRef<v1alpha1::SparkHistoryServer>,
787786
) -> Result<BTreeMap<String, String>, Error> {
788787
let mut result = BTreeMap::new();
789788

rust/operator-binary/src/history/operations/pdb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use stackable_operator::{
66

77
use crate::crd::{
88
constants::{APP_NAME, HISTORY_CONTROLLER_NAME, HISTORY_ROLE_NAME, OPERATOR_NAME},
9-
history::SparkHistoryServer,
9+
history::v1alpha1,
1010
};
1111

1212
#[derive(Snafu, Debug)]
@@ -25,7 +25,7 @@ pub enum Error {
2525

2626
pub async fn add_pdbs(
2727
pdb: &PdbConfig,
28-
history: &SparkHistoryServer,
28+
history: &v1alpha1::SparkHistoryServer,
2929
client: &Client,
3030
cluster_resources: &mut ClusterResources,
3131
) -> Result<(), Error> {

rust/operator-binary/src/main.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::crd::{
3030
SPARK_CONTROLLER_NAME, SPARK_FULL_CONTROLLER_NAME,
3131
},
3232
history::SparkHistoryServer,
33-
v1alpha1, SparkApplication,
33+
SparkApplication,
3434
};
3535

3636
mod crd;
@@ -66,7 +66,8 @@ async fn main() -> anyhow::Result<()> {
6666
Command::Crd => {
6767
SparkApplication::merged_crd(SparkApplication::V1Alpha1)?
6868
.print_yaml_schema(built_info::PKG_VERSION, SerializeOptions::default())?;
69-
// SparkHistoryServer::print_yaml_schema(built_info::PKG_VERSION)?;
69+
SparkHistoryServer::merged_crd(SparkHistoryServer::V1Alpha1)?
70+
.print_yaml_schema(built_info::PKG_VERSION, SerializeOptions::default())?;
7071
}
7172
Command::Run(ProductOperatorRun {
7273
product_config,
@@ -106,7 +107,8 @@ async fn main() -> anyhow::Result<()> {
106107
},
107108
));
108109
let app_controller = Controller::new(
109-
watch_namespace.get_api::<DeserializeGuard<v1alpha1::SparkApplication>>(&client),
110+
watch_namespace
111+
.get_api::<DeserializeGuard<crd::v1alpha1::SparkApplication>>(&client),
110112
watcher::Config::default(),
111113
)
112114
.owns(
@@ -192,11 +194,17 @@ async fn main() -> anyhow::Result<()> {
192194
},
193195
));
194196
let history_controller = Controller::new(
195-
watch_namespace.get_api::<DeserializeGuard<SparkHistoryServer>>(&client),
197+
watch_namespace
198+
.get_api::<DeserializeGuard<crd::history::v1alpha1::SparkHistoryServer>>(
199+
&client,
200+
),
196201
watcher::Config::default(),
197202
)
198203
.owns(
199-
watch_namespace.get_api::<DeserializeGuard<SparkHistoryServer>>(&client),
204+
watch_namespace
205+
.get_api::<DeserializeGuard<crd::history::v1alpha1::SparkHistoryServer>>(
206+
&client,
207+
),
200208
watcher::Config::default(),
201209
)
202210
.owns(

0 commit comments

Comments
 (0)