Skip to content

Commit 7d714e9

Browse files
fhennigmaltesander
andauthored
Chore: bump operator rs 0.61 (#339)
* WIP * WIP * WIP * WIP * WIP * done? * Update rust/crd/src/lib.rs Co-authored-by: Malte Sander <[email protected]> * Update rust/crd/src/s3logdir.rs Co-authored-by: Malte Sander <[email protected]> --------- Co-authored-by: Malte Sander <[email protected]>
1 parent 1154fc8 commit 7d714e9

File tree

7 files changed

+174
-105
lines changed

7 files changed

+174
-105
lines changed

Cargo.lock

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ serde = { version = "1.0", features = ["derive"] }
2121
serde_json = "1.0"
2222
serde_yaml = "0.9"
2323
snafu = "0.7"
24-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.58.1" }
24+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.61.0" }
2525
strum = { version = "0.25", features = ["derive"] }
2626
tokio = { version = "1.29", features = ["full"] }
2727
tracing = "0.1"

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

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7044,37 +7044,6 @@ spec:
70447044
minimum: 0.0
70457045
nullable: true
70467046
type: integer
7047-
selector:
7048-
description: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
7049-
nullable: true
7050-
properties:
7051-
matchExpressions:
7052-
description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
7053-
items:
7054-
description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
7055-
properties:
7056-
key:
7057-
description: key is the label key that the selector applies to.
7058-
type: string
7059-
operator:
7060-
description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
7061-
type: string
7062-
values:
7063-
description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
7064-
items:
7065-
type: string
7066-
type: array
7067-
required:
7068-
- key
7069-
- operator
7070-
type: object
7071-
type: array
7072-
matchLabels:
7073-
additionalProperties:
7074-
type: string
7075-
description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
7076-
type: object
7077-
type: object
70787047
type: object
70797048
image:
70807049
description: User-supplied image containing spark-job dependencies that will be copied to the specified volume mount. See the [examples](https://docs.stackable.tech/home/nightly/spark-k8s/usage-guide/examples).
@@ -10038,7 +10007,7 @@ spec:
1003810007
s3:
1003910008
properties:
1004010009
bucket:
10041-
description: An S3 bucket definition, it can either be a reference to an explicit S3Bucket object, or it can be an inline defintion of a bucket. Read the [S3 resources concept documentation](https://docs.stackable.tech/home/nightly/concepts/s3) to learn more.
10010+
description: An S3 bucket definition, it can either be a reference to an explicit S3Bucket object, or it can be an inline definition of a bucket. Read the [S3 resources concept documentation](https://docs.stackable.tech/home/nightly/concepts/s3) to learn more.
1004210011
oneOf:
1004310012
- required:
1004410013
- inline
@@ -11542,7 +11511,7 @@ spec:
1154211511
s3:
1154311512
properties:
1154411513
bucket:
11545-
description: An S3 bucket definition, it can either be a reference to an explicit S3Bucket object, or it can be an inline defintion of a bucket. Read the [S3 resources concept documentation](https://docs.stackable.tech/home/nightly/concepts/s3) to learn more.
11514+
description: An S3 bucket definition, it can either be a reference to an explicit S3Bucket object, or it can be an inline definition of a bucket. Read the [S3 resources concept documentation](https://docs.stackable.tech/home/nightly/concepts/s3) to learn more.
1154611515
oneOf:
1154711516
- required:
1154811517
- inline
@@ -18548,37 +18517,6 @@ spec:
1854818517
minimum: 0.0
1854918518
nullable: true
1855018519
type: integer
18551-
selector:
18552-
description: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
18553-
nullable: true
18554-
properties:
18555-
matchExpressions:
18556-
description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
18557-
items:
18558-
description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
18559-
properties:
18560-
key:
18561-
description: key is the label key that the selector applies to.
18562-
type: string
18563-
operator:
18564-
description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
18565-
type: string
18566-
values:
18567-
description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
18568-
items:
18569-
type: string
18570-
type: array
18571-
required:
18572-
- key
18573-
- operator
18574-
type: object
18575-
type: array
18576-
matchLabels:
18577-
additionalProperties:
18578-
type: string
18579-
description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
18580-
type: object
18581-
type: object
1858218520
type: object
1858318521
type: object
1858418522
required:

rust/crd/src/lib.rs

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use stackable_operator::{
3333
apimachinery::pkg::api::resource::Quantity,
3434
},
3535
kube::{CustomResource, ResourceExt},
36-
labels::ObjectLabels,
36+
kvp::ObjectLabels,
3737
memory::{BinaryMultiple, MemoryQuantity},
3838
product_logging,
3939
role_utils::{CommonConfiguration, Role, RoleGroup},
@@ -48,31 +48,53 @@ use std::{
4848
pub enum Error {
4949
#[snafu(display("object has no namespace associated"))]
5050
NoNamespace,
51+
5152
#[snafu(display("object defines no deploy mode"))]
5253
ObjectHasNoDeployMode,
54+
5355
#[snafu(display("object defines no application artifact"))]
5456
ObjectHasNoArtifact,
57+
5558
#[snafu(display("object has no name"))]
5659
ObjectHasNoName,
60+
5761
#[snafu(display("application has no Spark image"))]
5862
NoSparkImage,
63+
5964
#[snafu(display("failed to convert java heap config to unit [{unit}]"))]
6065
FailedToConvertJavaHeap {
6166
source: stackable_operator::error::Error,
6267
unit: String,
6368
},
69+
6470
#[snafu(display("failed to parse value"))]
6571
FailedParseToFloatConversion,
72+
6673
#[snafu(display("fragment validation failure"))]
6774
FragmentValidationFailure { source: ValidationError },
75+
6876
#[snafu(display("failed to transform configs"))]
6977
ProductConfigTransform {
7078
source: stackable_operator::product_config_utils::ConfigError,
7179
},
80+
7281
#[snafu(display("invalid product config"))]
7382
InvalidProductConfig {
7483
source: stackable_operator::error::Error,
7584
},
85+
86+
#[snafu(display("failed to build TLS certificate SecretClass Volume"))]
87+
TlsCertSecretClassVolumeBuild {
88+
source: stackable_operator::builder::SecretOperatorVolumeSourceBuilderError,
89+
},
90+
91+
#[snafu(display("failed to build S3 credentials Volume"))]
92+
S3CredentialsVolumeBuild {
93+
source: stackable_operator::commons::secret_class::SecretClassVolumeError,
94+
},
95+
96+
#[snafu(display("failed to build S3 log directory credentials Volume"))]
97+
S3LogDirCredentialsVolumeBuild { source: s3logdir::Error },
7698
}
7799

78100
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
@@ -232,7 +254,7 @@ impl SparkApplication {
232254
s3conn: &Option<S3ConnectionSpec>,
233255
s3logdir: &Option<S3LogDir>,
234256
log_config_map: &str,
235-
) -> Vec<Volume> {
257+
) -> Result<Vec<Volume>, Error> {
236258
let mut result: Vec<Volume> = self.spec.volumes.clone();
237259

238260
if self.spec.image.is_some() {
@@ -256,11 +278,20 @@ impl SparkApplication {
256278
..
257279
}) = s3conn
258280
{
259-
result.push(secret_class_volume.to_volume(secret_class_volume.secret_class.as_ref()));
281+
result.push(
282+
secret_class_volume
283+
.to_volume(secret_class_volume.secret_class.as_ref())
284+
.context(S3CredentialsVolumeBuildSnafu)?,
285+
);
260286
}
261287

262-
if let Some(v) = s3logdir.as_ref().and_then(|o| o.credentials_volume()) {
263-
result.push(v);
288+
if let Some(log_dir) = s3logdir.as_ref() {
289+
if let Some(volume) = log_dir
290+
.credentials_volume()
291+
.context(S3LogDirCredentialsVolumeBuildSnafu)?
292+
{
293+
result.push(volume);
294+
}
264295
}
265296

266297
result.push(
@@ -299,14 +330,15 @@ impl SparkApplication {
299330
.ephemeral(
300331
SecretOperatorVolumeSourceBuilder::new(cert_secret)
301332
.with_format(SecretFormat::TlsPkcs12)
302-
.build(),
333+
.build()
334+
.context(TlsCertSecretClassVolumeBuildSnafu)?,
303335
)
304336
.build(),
305337
);
306338
}
307339
}
308340

309-
result
341+
Ok(result)
310342
}
311343

312344
pub fn spark_job_volume_mounts(
@@ -687,7 +719,6 @@ impl SparkApplication {
687719
config: RoleConfig::default_config(),
688720
..CommonConfiguration::default()
689721
},
690-
selector: None,
691722
}
692723
};
693724

@@ -707,7 +738,6 @@ impl SparkApplication {
707738
RoleGroup {
708739
config: submit_conf,
709740
replicas: Some(1),
710-
selector: None,
711741
},
712742
)]
713743
.into(),
@@ -730,7 +760,6 @@ impl SparkApplication {
730760
RoleGroup {
731761
config: driver_conf,
732762
replicas: Some(1),
733-
selector: None,
734763
},
735764
)]
736765
.into(),

rust/crd/src/s3logdir.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,25 @@ pub enum Error {
2929
S3Bucket {
3030
source: stackable_operator::error::Error,
3131
},
32+
3233
#[snafu(display("missing bucket name for history logs"))]
3334
BucketNameMissing,
35+
3436
#[snafu(display("tls non-verification not supported"))]
3537
S3TlsNoVerificationNotSupported,
38+
3639
#[snafu(display("ca-cert verification not supported"))]
3740
S3TlsCaVerificationNotSupported,
41+
42+
#[snafu(display("failed to build TLS certificate SecretClass Volume"))]
43+
TlsCertSecretClassVolumeBuild {
44+
source: stackable_operator::builder::SecretOperatorVolumeSourceBuilderError,
45+
},
46+
47+
#[snafu(display("failed to build credentials Volume"))]
48+
CredentialsVolumeBuild {
49+
source: stackable_operator::commons::secret_class::SecretClassVolumeError,
50+
},
3851
}
3952

4053
pub struct S3LogDir {
@@ -179,21 +192,22 @@ impl S3LogDir {
179192
)
180193
}
181194

182-
pub fn volumes(&self) -> Vec<Volume> {
183-
let mut volumes: Vec<Volume> = self.credentials_volume().into_iter().collect();
195+
pub fn volumes(&self) -> Result<Vec<Volume>, Error> {
196+
let mut volumes: Vec<Volume> = self.credentials_volume()?.into_iter().collect();
184197

185198
if let Some(secret_name) = tlscerts::tls_secret_name(&self.bucket.connection) {
186199
volumes.push(
187200
VolumeBuilder::new(secret_name)
188201
.ephemeral(
189202
SecretOperatorVolumeSourceBuilder::new(secret_name)
190203
.with_format(SecretFormat::TlsPkcs12)
191-
.build(),
204+
.build()
205+
.context(TlsCertSecretClassVolumeBuildSnafu)?,
192206
)
193207
.build(),
194208
);
195209
}
196-
volumes
210+
Ok(volumes)
197211
}
198212

199213
pub fn volume_mounts(&self) -> Vec<VolumeMount> {
@@ -212,9 +226,14 @@ impl S3LogDir {
212226
volume_mounts
213227
}
214228

215-
pub fn credentials_volume(&self) -> Option<Volume> {
229+
pub fn credentials_volume(&self) -> Result<Option<Volume>, Error> {
216230
self.credentials()
217-
.map(|credentials| credentials.to_volume(credentials.secret_class.as_ref()))
231+
.map(|credentials| {
232+
credentials
233+
.to_volume(credentials.secret_class.as_ref())
234+
.context(CredentialsVolumeBuildSnafu)
235+
})
236+
.transpose()
218237
}
219238

220239
pub fn credentials_volume_mount(&self) -> Option<VolumeMount> {

0 commit comments

Comments
 (0)