Skip to content

Commit

Permalink
Pull in new operator-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed Sep 21, 2023
1 parent e4adc16 commit 5c45fec
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 66 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

117 changes: 69 additions & 48 deletions deploy/helm/hdfs-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -755,22 +755,6 @@ spec:
type: string
default: {}
type: object
pdb:
default:
enabled: true
maxUnavailable: null
properties:
enabled:
default: true
description: Wether a PodDisruptionBudget should be written out for this role. Disabling this enables you to specify you own - custom - one. Defaults to true.
type: boolean
maxUnavailable:
description: The number of Pods that are allowed to be down because of voluntary disruptions. If you don't explicitly set this, the operator will use a sane default based upon knowledge about the individual product.
format: uint16
minimum: 0.0
nullable: true
type: integer
type: object
podOverrides:
default: {}
description: See PodTemplateSpec (https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core) for more details
Expand Down Expand Up @@ -3569,6 +3553,29 @@ spec:
type: array
type: object
type: object
roleConfig:
default:
podDisruptionBudget:
enabled: true
maxUnavailable: null
properties:
podDisruptionBudget:
default:
enabled: true
maxUnavailable: null
properties:
enabled:
default: true
description: Wether a PodDisruptionBudget should be written out for this role. Disabling this enables you to specify you own - custom - one. Defaults to true.
type: boolean
maxUnavailable:
description: The number of Pods that are allowed to be down because of voluntary disruptions. If you don't explicitly set this, the operator will use a sane default based upon knowledge about the individual product.
format: uint16
minimum: 0.0
nullable: true
type: integer
type: object
type: object
roleGroups:
additionalProperties:
properties:
Expand Down Expand Up @@ -7765,22 +7772,6 @@ spec:
type: string
default: {}
type: object
pdb:
default:
enabled: true
maxUnavailable: null
properties:
enabled:
default: true
description: Wether a PodDisruptionBudget should be written out for this role. Disabling this enables you to specify you own - custom - one. Defaults to true.
type: boolean
maxUnavailable:
description: The number of Pods that are allowed to be down because of voluntary disruptions. If you don't explicitly set this, the operator will use a sane default based upon knowledge about the individual product.
format: uint16
minimum: 0.0
nullable: true
type: integer
type: object
podOverrides:
default: {}
description: See PodTemplateSpec (https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core) for more details
Expand Down Expand Up @@ -10579,6 +10570,29 @@ spec:
type: array
type: object
type: object
roleConfig:
default:
podDisruptionBudget:
enabled: true
maxUnavailable: null
properties:
podDisruptionBudget:
default:
enabled: true
maxUnavailable: null
properties:
enabled:
default: true
description: Wether a PodDisruptionBudget should be written out for this role. Disabling this enables you to specify you own - custom - one. Defaults to true.
type: boolean
maxUnavailable:
description: The number of Pods that are allowed to be down because of voluntary disruptions. If you don't explicitly set this, the operator will use a sane default based upon knowledge about the individual product.
format: uint16
minimum: 0.0
nullable: true
type: integer
type: object
type: object
roleGroups:
additionalProperties:
properties:
Expand Down Expand Up @@ -14724,22 +14738,6 @@ spec:
type: string
default: {}
type: object
pdb:
default:
enabled: true
maxUnavailable: null
properties:
enabled:
default: true
description: Wether a PodDisruptionBudget should be written out for this role. Disabling this enables you to specify you own - custom - one. Defaults to true.
type: boolean
maxUnavailable:
description: The number of Pods that are allowed to be down because of voluntary disruptions. If you don't explicitly set this, the operator will use a sane default based upon knowledge about the individual product.
format: uint16
minimum: 0.0
nullable: true
type: integer
type: object
podOverrides:
default: {}
description: See PodTemplateSpec (https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core) for more details
Expand Down Expand Up @@ -17538,6 +17536,29 @@ spec:
type: array
type: object
type: object
roleConfig:
default:
podDisruptionBudget:
enabled: true
maxUnavailable: null
properties:
podDisruptionBudget:
default:
enabled: true
maxUnavailable: null
properties:
enabled:
default: true
description: Wether a PodDisruptionBudget should be written out for this role. Disabling this enables you to specify you own - custom - one. Defaults to true.
type: boolean
maxUnavailable:
description: The number of Pods that are allowed to be down because of voluntary disruptions. If you don't explicitly set this, the operator will use a sane default based upon knowledge about the individual product.
format: uint16
minimum: 0.0
nullable: true
type: integer
type: object
type: object
roleGroups:
additionalProperties:
properties:
Expand Down
10 changes: 9 additions & 1 deletion rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use stackable_operator::{
product_config_utils::{ConfigError, Configuration},
product_logging,
product_logging::spec::{ContainerLogConfig, Logging},
role_utils::{Role, RoleGroup, RoleGroupRef},
role_utils::{Role, RoleConfig, RoleGroup, RoleGroupRef},
schemars::{self, JsonSchema},
status::condition::{ClusterCondition, HasStatusCondition},
};
Expand Down Expand Up @@ -474,6 +474,14 @@ impl HdfsCluster {
.get(role_group)
}

pub fn role_config(&self, role: &HdfsRole) -> Option<&RoleConfig> {
match role {
HdfsRole::NameNode => self.spec.name_nodes.as_ref().map(|nn| &nn.role_config),
HdfsRole::DataNode => self.spec.data_nodes.as_ref().map(|nn| &nn.role_config),
HdfsRole::JournalNode => self.spec.journal_nodes.as_ref().map(|nn| &nn.role_config),
}
}

pub fn pod_overrides_for_role(&self, role: &HdfsRole) -> Option<&PodTemplateSpec> {
match role {
HdfsRole::NameNode => self
Expand Down
13 changes: 6 additions & 7 deletions rust/operator/src/hdfs_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use stackable_operator::{
types::PropertyNameKind, writer::to_java_properties_string, ProductConfigManager,
},
product_config_utils::{transform_all_roles_to_config, validate_all_roles_and_groups_config},
role_utils::RoleGroupRef,
role_utils::{RoleConfig, RoleGroupRef},
status::condition::{
compute_conditions, operations::ClusterOperationsConditionBuilder,
statefulset::StatefulSetConditionBuilder,
Expand Down Expand Up @@ -348,12 +348,11 @@ pub async fn reconcile_hdfs(hdfs: Arc<HdfsCluster>, ctx: Arc<Ctx>) -> HdfsOperat
);
}

let pdb = match role {
HdfsRole::NameNode => hdfs.spec.name_nodes.as_ref().map(|nn| &nn.pdb),
HdfsRole::DataNode => hdfs.spec.data_nodes.as_ref().map(|nn| &nn.pdb),
HdfsRole::JournalNode => hdfs.spec.journal_nodes.as_ref().map(|nn| &nn.pdb),
};
if let Some(pdb) = pdb {
let role_config = hdfs.role_config(&role);
if let Some(RoleConfig {
pod_disruption_budget: pdb,
}) = role_config
{
add_pdbs(pdb, &hdfs, &role, client, &mut cluster_resources)
.await
.context(FailedToCreatePdbSnafu)?;
Expand Down

0 comments on commit 5c45fec

Please sign in to comment.