Skip to content

Commit

Permalink
remove legacy node selector code
Browse files Browse the repository at this point in the history
  • Loading branch information
NickLarsenNZ committed Jan 11, 2024
1 parent a5be211 commit 38817d2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 131 deletions.
120 changes: 0 additions & 120 deletions rust/crd/src/affinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,124 +219,4 @@ mod tests {
}
);
}

#[test]
fn test_affinity_legacy_node_selector() {
let input = r#"
apiVersion: hbase.stackable.tech/v1alpha1
kind: HbaseCluster
metadata:
name: simple-hbase
spec:
image:
productVersion: 2.4.17
clusterConfig:
hdfsConfigMapName: simple-hdfs
zookeeperConfigMapName: simple-znode
masters:
roleGroups:
default:
replicas: 1
selector:
matchLabels:
disktype: ssd
matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- antarctica-east1
- antarctica-west1
regionServers:
roleGroups:
default:
replicas: 1
restServers:
roleGroups:
default:
replicas: 1
"#;
let hbase: HbaseCluster = serde_yaml::from_str(input).expect("illegal test input");
let merged_config = hbase
.merged_config(
&HbaseRole::Master,
"default",
&hbase.spec.cluster_config.hdfs_config_map_name,
)
.unwrap();

assert_eq!(
merged_config.affinity,
StackableAffinity {
pod_affinity: Some(PodAffinity {
preferred_during_scheduling_ignored_during_execution: Some(vec![
WeightedPodAffinityTerm {
pod_affinity_term: PodAffinityTerm {
label_selector: Some(LabelSelector {
match_expressions: None,
match_labels: Some(BTreeMap::from([
("app.kubernetes.io/name".to_string(), "hbase".to_string(),),
(
"app.kubernetes.io/instance".to_string(),
"simple-hbase".to_string(),
),
]))
}),
namespace_selector: None,
namespaces: None,
topology_key: "kubernetes.io/hostname".to_string(),
},
weight: 20
}
]),
required_during_scheduling_ignored_during_execution: None,
}),
pod_anti_affinity: Some(PodAntiAffinity {
preferred_during_scheduling_ignored_during_execution: Some(vec![
WeightedPodAffinityTerm {
pod_affinity_term: PodAffinityTerm {
label_selector: Some(LabelSelector {
match_expressions: None,
match_labels: Some(BTreeMap::from([
("app.kubernetes.io/name".to_string(), "hbase".to_string(),),
(
"app.kubernetes.io/instance".to_string(),
"simple-hbase".to_string(),
),
(
"app.kubernetes.io/component".to_string(),
"master".to_string(),
)
]))
}),
namespace_selector: None,
namespaces: None,
topology_key: "kubernetes.io/hostname".to_string(),
},
weight: 70
}
]),
required_during_scheduling_ignored_during_execution: None,
}),
node_affinity: Some(NodeAffinity {
preferred_during_scheduling_ignored_during_execution: None,
required_during_scheduling_ignored_during_execution: Some(NodeSelector {
node_selector_terms: vec![NodeSelectorTerm {
match_expressions: Some(vec![NodeSelectorRequirement {
key: "topology.kubernetes.io/zone".to_string(),
operator: "In".to_string(),
values: Some(vec![
"antarctica-east1".to_string(),
"antarctica-west1".to_string()
]),
}]),
match_fields: None,
}]
}),
}),
node_selector: Some(StackableNodeSelector {
node_selector: BTreeMap::from([("disktype".to_string(), "ssd".to_string())])
}),
}
);
}
}
11 changes: 0 additions & 11 deletions rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,17 +520,6 @@ impl HbaseCluster {
.map(|rg| rg.config.config.clone())
.unwrap_or_default();

if let Some(RoleGroup {
selector: Some(selector),
..
}) = role.role_groups.get(role_group)
{
// Migrate old `selector` attribute, see ADR 26 affinities.
// TODO Can be removed after support for the old `selector` field is dropped.
#[allow(deprecated)]
conf_rolegroup.affinity.add_legacy_selector(selector);
}

// Merge more specific configs into default config
// Hierarchy is:
// 1. RoleGroup
Expand Down

0 comments on commit 38817d2

Please sign in to comment.