diff --git a/deploy/helm/spark-k8s-operator/crds/crds.yaml b/deploy/helm/spark-k8s-operator/crds/crds.yaml index 07c89b71..5815d4c6 100644 --- a/deploy/helm/spark-k8s-operator/crds/crds.yaml +++ b/deploy/helm/spark-k8s-operator/crds/crds.yaml @@ -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: @@ -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: @@ -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: diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index b5fc22f2..6fee239c 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -387,7 +387,7 @@ impl SparkApplication { SubmitConfigFragment { volume_mounts: Some(VolumeMounts { - volume_mounts: Some(job_vm), + volume_mounts: job_vm, }), .. }, @@ -1140,7 +1140,7 @@ mod tests { enable_vector_agent: false, containers: BTreeMap::new(), }, - volume_mounts: None, + volume_mounts: Default::default(), affinity: StackableAffinity::default(), }; @@ -1184,7 +1184,7 @@ mod tests { enable_vector_agent: false, containers: BTreeMap::new(), }, - volume_mounts: None, + volume_mounts: Default::default(), affinity: StackableAffinity::default(), }; diff --git a/rust/crd/src/roles.rs b/rust/crd/src/roles.rs index 4cee4409..bf3111c4 100644 --- a/rust/crd/src/roles.rs +++ b/rust/crd/src/roles.rs @@ -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}; @@ -113,10 +114,13 @@ pub enum SparkMode { pub struct RoleConfig { #[fragment_attrs(serde(default))] pub resources: Resources, + #[fragment_attrs(serde(default))] pub logging: Logging, + #[fragment_attrs(serde(default, flatten))] - pub volume_mounts: Option, + pub volume_mounts: VolumeMounts, + #[fragment_attrs(serde(default))] pub affinity: StackableAffinity, } @@ -146,7 +150,7 @@ impl RoleConfig { s3conn: &Option, s3logdir: &Option, ) -> Vec { - 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) } } @@ -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>, + #[schemars(schema_with = "raw_object_list_schema")] + pub volume_mounts: Vec, } impl Atomic for VolumeMounts {} @@ -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 for Vec { fn from(value: VolumeMounts) -> Self { - value.volume_mounts.unwrap_or_default() + value.volume_mounts } }