Skip to content

Commit b6436eb

Browse files
committed
Upgrade operator-rs to 0.24.0 (#219)
# Description *Please add a description here. This will become the commit message of the merge request later.*
1 parent e3654c3 commit b6436eb

File tree

8 files changed

+77
-60
lines changed

8 files changed

+77
-60
lines changed

Cargo.lock

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

rust/crd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repository = "https://github.com/stackabletech/hdfs-operator"
88
version = "0.5.0-nightly"
99

1010
[dependencies]
11-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.22.0" }
11+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.24.0" }
1212

1313
semver = "1.0"
1414
serde = { version = "1.0", features = ["derive"] }

rust/crd/src/error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ pub enum Error {
6969
#[error("Cannot find rolegroup [{rolegroup}]")]
7070
RoleGroupNotFound { rolegroup: String },
7171

72+
#[error("Object has no name")]
73+
ObjectHasNoName,
7274
#[error("Object has no namespace [{obj_ref}]")]
7375
ObjectHasNoNamespace { obj_ref: ObjectRef<HdfsCluster> },
7476

@@ -81,10 +83,9 @@ pub enum Error {
8183
role_group: String,
8284
},
8385

84-
#[error("Cannot build config discovery config map {name}. Caused by: {source}")]
86+
#[error("Cannot build config discovery config map. Caused by: {source}")]
8587
BuildDiscoveryConfigMap {
8688
source: stackable_operator::error::Error,
87-
name: String,
8889
},
8990

9091
#[error("Pod has no name")]

rust/operator-binary/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version = "0.5.0-nightly"
99
build = "build.rs"
1010

1111
[dependencies]
12-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.22.0" }
12+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.24.0" }
1313
stackable-hdfs-crd = { path = "../crd" }
1414
stackable-hdfs-operator = { path = "../operator" }
1515
clap = { version = "3.2", features = ["derive"] }
@@ -19,7 +19,7 @@ serde_yaml = "0.8"
1919

2020
[build-dependencies]
2121
built = { version = "0.5", features = ["chrono", "git2"] }
22-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.22.0" }
22+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.24.0" }
2323
stackable-hdfs-crd = { path = "../crd" }
2424

2525
[[bin]]

rust/operator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repository = "https://github.com/stackabletech/hdfs-operator"
88
version = "0.5.0-nightly"
99

1010
[dependencies]
11-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.22.0" }
11+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "0.24.0" }
1212
stackable-hdfs-crd = { path = "../crd" }
1313

1414
futures = "0.3"

rust/operator/src/discovery.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use crate::config::{CoreSiteConfigBuilder, HdfsNodeDataDirectory, HdfsSiteConfigBuilder};
1+
use crate::{
2+
config::{CoreSiteConfigBuilder, HdfsNodeDataDirectory, HdfsSiteConfigBuilder},
3+
OPERATOR_NAME,
4+
};
25
use stackable_hdfs_crd::{
36
constants::{APP_NAME, CORE_SITE_XML, HDFS_SITE_XML},
47
HdfsCluster, HdfsPodRef, HdfsRole,
@@ -26,16 +29,20 @@ pub fn build_discovery_configmap(
2629
APP_NAME,
2730
hdfs.hdfs_version()
2831
.map_err(|_| Error::MissingObjectKey { key: "version" })?,
32+
OPERATOR_NAME,
2933
&HdfsRole::NameNode.to_string(),
3034
"discovery",
3135
)
3236
.build(),
3337
)
3438
.add_data(
3539
HDFS_SITE_XML,
36-
build_discovery_hdfs_site_xml(hdfs.name(), namenode_podrefs),
40+
build_discovery_hdfs_site_xml(hdfs.name_any(), namenode_podrefs),
41+
)
42+
.add_data(
43+
CORE_SITE_XML,
44+
build_discovery_core_site_xml(hdfs.name_any()),
3745
)
38-
.add_data(CORE_SITE_XML, build_discovery_core_site_xml(hdfs.name()))
3946
.build()
4047
}
4148

rust/operator/src/hdfs_controller.rs

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::config::{
22
CoreSiteConfigBuilder, HdfsNodeDataDirectory, HdfsSiteConfigBuilder, ROOT_DATA_DIR,
33
};
44
use crate::discovery::build_discovery_configmap;
5+
use crate::OPERATOR_NAME;
56
use stackable_hdfs_crd::error::{Error, HdfsOperatorResult};
67
use stackable_hdfs_crd::{constants::*, ROLE_PORTS};
78
use stackable_hdfs_crd::{HdfsCluster, HdfsPodRef, HdfsRole};
@@ -24,7 +25,6 @@ use stackable_operator::kube::api::ObjectMeta;
2425
use stackable_operator::kube::runtime::controller::Action;
2526
use stackable_operator::kube::runtime::events::{Event, EventType, Recorder, Reporter};
2627
use stackable_operator::kube::runtime::reflector::ObjectRef;
27-
use stackable_operator::kube::ResourceExt;
2828
use stackable_operator::labels::role_group_selector_labels;
2929
use stackable_operator::memory::to_java_heap;
3030
use stackable_operator::product_config::{types::PropertyNameKind, ProductConfigManager};
@@ -59,12 +59,8 @@ pub async fn reconcile_hdfs(hdfs: Arc<HdfsCluster>, ctx: Arc<Ctx>) -> HdfsOperat
5959
let namenode_podrefs = hdfs.pod_refs(&HdfsRole::NameNode)?;
6060
let journalnode_podrefs = hdfs.pod_refs(&HdfsRole::JournalNode)?;
6161

62-
let discovery_cm = build_discovery_configmap(&hdfs, &namenode_podrefs).map_err(|e| {
63-
Error::BuildDiscoveryConfigMap {
64-
source: e,
65-
name: hdfs.name(),
66-
}
67-
})?;
62+
let discovery_cm = build_discovery_configmap(&hdfs, &namenode_podrefs)
63+
.map_err(|e| Error::BuildDiscoveryConfigMap { source: e })?;
6864

6965
client
7066
.apply_patch(FIELD_MANAGER_SCOPE, &discovery_cm, &discovery_cm)
@@ -167,6 +163,7 @@ fn rolegroup_service(
167163
hdfs,
168164
APP_NAME,
169165
hdfs.hdfs_version()?,
166+
OPERATOR_NAME,
170167
&rolegroup_ref.role,
171168
&rolegroup_ref.role_group,
172169
)
@@ -202,44 +199,52 @@ fn rolegroup_config_map(
202199
) -> HdfsOperatorResult<ConfigMap> {
203200
tracing::info!("Setting up ConfigMap for {:?}", rolegroup_ref);
204201

202+
let hdfs_name = hdfs
203+
.metadata
204+
.name
205+
.as_deref()
206+
.ok_or(Error::ObjectHasNoName)?;
207+
205208
let mut hdfs_site_xml = String::new();
206209
let mut core_site_xml = String::new();
207210

208211
for (property_name_kind, config) in rolegroup_config {
209212
match property_name_kind {
210213
PropertyNameKind::File(file_name) if file_name == HDFS_SITE_XML => {
211-
hdfs_site_xml =
212-
HdfsSiteConfigBuilder::new(hdfs.name(), HdfsNodeDataDirectory::default())
213-
// IMPORTANT: these folders must be under the volume mount point, otherwise they will not
214-
// be formatted by the namenode, or used by the other services.
215-
// See also: https://github.com/apache-spark-on-k8s/kubernetes-HDFS/commit/aef9586ecc8551ca0f0a468c3b917d8c38f494a0
216-
.dfs_namenode_name_dir()
217-
.dfs_datanode_data_dir()
218-
.dfs_journalnode_edits_dir()
219-
.dfs_replication(
220-
*hdfs
221-
.spec
222-
.dfs_replication
223-
.as_ref()
224-
.unwrap_or(&DEFAULT_DFS_REPLICATION_FACTOR),
225-
)
226-
.dfs_name_services()
227-
.dfs_ha_namenodes(namenode_podrefs)
228-
.dfs_namenode_shared_edits_dir(journalnode_podrefs)
229-
.dfs_namenode_name_dir_ha(namenode_podrefs)
230-
.dfs_namenode_rpc_address_ha(namenode_podrefs)
231-
.dfs_namenode_http_address_ha(namenode_podrefs)
232-
.dfs_client_failover_proxy_provider()
233-
.add("dfs.ha.fencing.methods", "shell(/bin/true)")
234-
.add("dfs.ha.nn.not-become-active-in-safemode", "true")
235-
.add("dfs.ha.automatic-failover.enabled", "true")
236-
.add("dfs.ha.namenode.id", "${env.POD_NAME}")
237-
// the extend with config must come last in order to have overrides working!!!
238-
.extend(config)
239-
.build_as_xml();
214+
hdfs_site_xml = HdfsSiteConfigBuilder::new(
215+
hdfs_name.to_string(),
216+
HdfsNodeDataDirectory::default(),
217+
)
218+
// IMPORTANT: these folders must be under the volume mount point, otherwise they will not
219+
// be formatted by the namenode, or used by the other services.
220+
// See also: https://github.com/apache-spark-on-k8s/kubernetes-HDFS/commit/aef9586ecc8551ca0f0a468c3b917d8c38f494a0
221+
.dfs_namenode_name_dir()
222+
.dfs_datanode_data_dir()
223+
.dfs_journalnode_edits_dir()
224+
.dfs_replication(
225+
*hdfs
226+
.spec
227+
.dfs_replication
228+
.as_ref()
229+
.unwrap_or(&DEFAULT_DFS_REPLICATION_FACTOR),
230+
)
231+
.dfs_name_services()
232+
.dfs_ha_namenodes(namenode_podrefs)
233+
.dfs_namenode_shared_edits_dir(journalnode_podrefs)
234+
.dfs_namenode_name_dir_ha(namenode_podrefs)
235+
.dfs_namenode_rpc_address_ha(namenode_podrefs)
236+
.dfs_namenode_http_address_ha(namenode_podrefs)
237+
.dfs_client_failover_proxy_provider()
238+
.add("dfs.ha.fencing.methods", "shell(/bin/true)")
239+
.add("dfs.ha.nn.not-become-active-in-safemode", "true")
240+
.add("dfs.ha.automatic-failover.enabled", "true")
241+
.add("dfs.ha.namenode.id", "${env.POD_NAME}")
242+
// the extend with config must come last in order to have overrides working!!!
243+
.extend(config)
244+
.build_as_xml();
240245
}
241246
PropertyNameKind::File(file_name) if file_name == CORE_SITE_XML => {
242-
core_site_xml = CoreSiteConfigBuilder::new(hdfs.name())
247+
core_site_xml = CoreSiteConfigBuilder::new(hdfs_name.to_string())
243248
.fs_default_fs()
244249
.ha_zookeeper_quorum()
245250
// the extend with config must come last in order to have overrides working!!!
@@ -264,6 +269,7 @@ fn rolegroup_config_map(
264269
hdfs,
265270
APP_NAME,
266271
hdfs.hdfs_version()?,
272+
OPERATOR_NAME,
267273
&rolegroup_ref.role,
268274
&rolegroup_ref.role_group,
269275
)
@@ -352,6 +358,7 @@ fn rolegroup_statefulset(
352358
hdfs,
353359
APP_NAME,
354360
hdfs.hdfs_version()?,
361+
OPERATOR_NAME,
355362
&rolegroup_ref.role,
356363
&rolegroup_ref.role_group,
357364
)

rust/operator/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ use stackable_operator::product_config::ProductConfigManager;
2020
use tracing::info_span;
2121
use tracing_futures::Instrument;
2222

23+
const OPERATOR_NAME: &str = "hdfs-operator";
24+
2325
pub async fn create_controller(
2426
client: Client,
2527
product_config: ProductConfigManager,

0 commit comments

Comments
 (0)