Skip to content

Commit

Permalink
Also address volumeMounts
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed Aug 12, 2024
1 parent 3295feb commit d6fb2ea
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 116 deletions.
111 changes: 3 additions & 108 deletions deploy/helm/spark-k8s-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,43 +238,8 @@ spec:
volumeMounts:
description: Volume mounts for the spark-submit, driver and executor pods.
items:
description: VolumeMount describes a mounting of a Volume within a container.
properties:
mountPath:
description: Path within the container at which the volume should be mounted. Must not contain ':'.
type: string
mountPropagation:
description: mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10. When RecursiveReadOnly is set to IfPossible or to Enabled, MountPropagation must be None or unspecified (which defaults to None).
type: string
name:
description: This must match the Name of a Volume.
type: string
readOnly:
description: Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
type: boolean
recursiveReadOnly:
description: |-
RecursiveReadOnly specifies whether read-only mounts should be handled recursively.
If ReadOnly is false, this field has no meaning and must be unspecified.
If ReadOnly is true, and this field is set to Disabled, the mount is not made recursively read-only. If this field is set to IfPossible, the mount is made recursively read-only, if it is supported by the container runtime. If this field is set to Enabled, the mount is made recursively read-only if it is supported by the container runtime, otherwise the pod will not be started and an error will be generated to indicate the reason.
If this field is set to IfPossible or Enabled, MountPropagation must be set to None (or be unspecified, which defaults to None).
If this field is not specified, it is treated as an equivalent of Disabled.
type: string
subPath:
description: Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
type: string
subPathExpr:
description: Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). SubPathExpr and SubPath are mutually exclusive.
type: string
required:
- mountPath
- name
type: object
nullable: true
x-kubernetes-preserve-unknown-fields: true
type: array
type: object
configOverrides:
Expand Down Expand Up @@ -545,43 +510,8 @@ spec:
volumeMounts:
description: Volume mounts for the spark-submit, driver and executor pods.
items:
description: VolumeMount describes a mounting of a Volume within a container.
properties:
mountPath:
description: Path within the container at which the volume should be mounted. Must not contain ':'.
type: string
mountPropagation:
description: mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10. When RecursiveReadOnly is set to IfPossible or to Enabled, MountPropagation must be None or unspecified (which defaults to None).
type: string
name:
description: This must match the Name of a Volume.
type: string
readOnly:
description: Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
type: boolean
recursiveReadOnly:
description: |-
RecursiveReadOnly specifies whether read-only mounts should be handled recursively.
If ReadOnly is false, this field has no meaning and must be unspecified.
If ReadOnly is true, and this field is set to Disabled, the mount is not made recursively read-only. If this field is set to IfPossible, the mount is made recursively read-only, if it is supported by the container runtime. If this field is set to Enabled, the mount is made recursively read-only if it is supported by the container runtime, otherwise the pod will not be started and an error will be generated to indicate the reason.
If this field is set to IfPossible or Enabled, MountPropagation must be set to None (or be unspecified, which defaults to None).
If this field is not specified, it is treated as an equivalent of Disabled.
type: string
subPath:
description: Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
type: string
subPathExpr:
description: Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). SubPathExpr and SubPath are mutually exclusive.
type: string
required:
- mountPath
- name
type: object
nullable: true
x-kubernetes-preserve-unknown-fields: true
type: array
type: object
configOverrides:
Expand Down Expand Up @@ -666,43 +596,8 @@ spec:
volumeMounts:
description: Volume mounts for the spark-submit, driver and executor pods.
items:
description: VolumeMount describes a mounting of a Volume within a container.
properties:
mountPath:
description: Path within the container at which the volume should be mounted. Must not contain ':'.
type: string
mountPropagation:
description: mountPropagation determines how mounts are propagated from the host to container and the other way around. When not set, MountPropagationNone is used. This field is beta in 1.10. When RecursiveReadOnly is set to IfPossible or to Enabled, MountPropagation must be None or unspecified (which defaults to None).
type: string
name:
description: This must match the Name of a Volume.
type: string
readOnly:
description: Mounted read-only if true, read-write otherwise (false or unspecified). Defaults to false.
type: boolean
recursiveReadOnly:
description: |-
RecursiveReadOnly specifies whether read-only mounts should be handled recursively.
If ReadOnly is false, this field has no meaning and must be unspecified.
If ReadOnly is true, and this field is set to Disabled, the mount is not made recursively read-only. If this field is set to IfPossible, the mount is made recursively read-only, if it is supported by the container runtime. If this field is set to Enabled, the mount is made recursively read-only if it is supported by the container runtime, otherwise the pod will not be started and an error will be generated to indicate the reason.
If this field is set to IfPossible or Enabled, MountPropagation must be set to None (or be unspecified, which defaults to None).
If this field is not specified, it is treated as an equivalent of Disabled.
type: string
subPath:
description: Path within the volume from which the container's volume should be mounted. Defaults to "" (volume's root).
type: string
subPathExpr:
description: Expanded path within the volume from which the container's volume should be mounted. Behaves similarly to SubPath but environment variable references $(VAR_NAME) are expanded using the container's environment. Defaults to "" (volume's root). SubPathExpr and SubPath are mutually exclusive.
type: string
required:
- mountPath
- name
type: object
nullable: true
x-kubernetes-preserve-unknown-fields: true
type: array
type: object
configOverrides:
Expand Down
6 changes: 3 additions & 3 deletions rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ impl SparkApplication {
SubmitConfigFragment {
volume_mounts:
Some(VolumeMounts {
volume_mounts: Some(job_vm),
volume_mounts: job_vm,
}),
..
},
Expand Down Expand Up @@ -1140,7 +1140,7 @@ mod tests {
enable_vector_agent: false,
containers: BTreeMap::new(),
},
volume_mounts: None,
volume_mounts: Default::default(),
affinity: StackableAffinity::default(),
};

Expand Down Expand Up @@ -1184,7 +1184,7 @@ mod tests {
enable_vector_agent: false,
containers: BTreeMap::new(),
},
volume_mounts: None,
volume_mounts: Default::default(),
affinity: StackableAffinity::default(),
};

Expand Down
15 changes: 10 additions & 5 deletions rust/crd/src/roles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use stackable_operator::{
product_config_utils::Configuration,
product_logging::{self, spec::Logging},
schemars::{self, JsonSchema},
utils::crds::raw_object_list_schema,
};
use strum::{Display, EnumIter};

Expand Down Expand Up @@ -113,10 +114,13 @@ pub enum SparkMode {
pub struct RoleConfig {
#[fragment_attrs(serde(default))]
pub resources: Resources<SparkStorageConfig, NoRuntimeLimits>,

#[fragment_attrs(serde(default))]
pub logging: Logging<SparkContainer>,

#[fragment_attrs(serde(default, flatten))]
pub volume_mounts: Option<VolumeMounts>,
pub volume_mounts: VolumeMounts,

#[fragment_attrs(serde(default))]
pub affinity: StackableAffinity,
}
Expand Down Expand Up @@ -146,7 +150,7 @@ impl RoleConfig {
s3conn: &Option<S3ConnectionSpec>,
s3logdir: &Option<S3LogDir>,
) -> Vec<VolumeMount> {
let volume_mounts = self.volume_mounts.clone().unwrap_or_default().into();
let volume_mounts = self.volume_mounts.clone().into();
spark_application.add_common_volume_mounts(volume_mounts, s3conn, s3logdir, true)
}
}
Expand Down Expand Up @@ -260,7 +264,8 @@ impl Configuration for SubmitConfigFragment {
#[serde(rename_all = "camelCase")]
pub struct VolumeMounts {
/// Volume mounts for the spark-submit, driver and executor pods.
pub volume_mounts: Option<Vec<VolumeMount>>,
#[schemars(schema_with = "raw_object_list_schema")]
pub volume_mounts: Vec<VolumeMount>,
}

impl Atomic for VolumeMounts {}
Expand All @@ -270,12 +275,12 @@ impl<'a> IntoIterator for &'a VolumeMounts {
type IntoIter = slice::Iter<'a, VolumeMount>;

fn into_iter(self) -> Self::IntoIter {
self.volume_mounts.as_deref().unwrap_or_default().iter()
self.volume_mounts.iter()
}
}

impl From<VolumeMounts> for Vec<VolumeMount> {
fn from(value: VolumeMounts) -> Self {
value.volume_mounts.unwrap_or_default()
value.volume_mounts
}
}

0 comments on commit d6fb2ea

Please sign in to comment.