Skip to content

Commit aa56092

Browse files
committed
Adopting to review, fixing lints
1 parent 705811f commit aa56092

2 files changed

Lines changed: 31 additions & 44 deletions

File tree

rust/operator-binary/src/controller.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ use crate::{
9292
APP_NAME, CORE_SITE_XML, Container, DB_PASSWORD_ENV, DB_USERNAME_ENV, HIVE_PORT,
9393
HIVE_PORT_NAME, HIVE_SITE_XML, HiveClusterStatus, HiveRole, JVM_SECURITY_PROPERTIES_FILE,
9494
LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, METRICS_PORT, METRICS_PORT_NAME,
95-
MetaStoreConfig, MetaStoreConfigFragment, STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_DIR_NAME,
95+
MetaStoreConfig, STACKABLE_CONFIG_DIR, STACKABLE_CONFIG_DIR_NAME,
9696
STACKABLE_CONFIG_MOUNT_DIR, STACKABLE_CONFIG_MOUNT_DIR_NAME,
9797
STACKABLE_LOG_CONFIG_MOUNT_DIR, STACKABLE_LOG_CONFIG_MOUNT_DIR_NAME, STACKABLE_LOG_DIR,
9898
STACKABLE_LOG_DIR_NAME,
@@ -501,52 +501,52 @@ pub async fn reconcile_hive(
501501
})?,
502502
);
503503
}
504-
// Init listener struct. Collect listener after applied to cluster_resources
505-
// to use listener object in later created discovery configMap
506-
let mut listener = Listener::new("name", ListenerSpec::default());
504+
507505
let role_config = hive.role_config(&hive_role);
508506
if let Some(HiveMetastoreRoleConfig {
509507
common: GenericRoleConfig {
510508
pod_disruption_budget: pdb,
511509
},
512-
listener_class,
510+
..
513511
}) = role_config
514512
{
515513
add_pdbs(pdb, hive, &hive_role, client, &mut cluster_resources)
516514
.await
517515
.context(FailedToCreatePdbSnafu)?;
516+
}
517+
518+
// std's SipHasher is deprecated, and DefaultHasher is unstable across Rust releases.
519+
// We don't /need/ stability, but it's still nice to avoid spurious changes where possible.
520+
let mut discovery_hash = FnvHasher::with_key(0);
518521

522+
if let Some(HiveMetastoreRoleConfig { listener_class, .. }) = role_config {
519523
let group_listener: Listener =
520524
build_group_listener(hive, &resolved_product_image, &hive_role, listener_class)?;
521-
listener = cluster_resources
525+
let listener = cluster_resources
522526
.add(client, group_listener)
523527
.await
524-
.with_context(|_| ApplyGroupListenerSnafu {
528+
.context(ApplyGroupListenerSnafu {
525529
role: hive_role.to_string(),
526530
})?;
527-
}
528-
529-
// std's SipHasher is deprecated, and DefaultHasher is unstable across Rust releases.
530-
// We don't /need/ stability, but it's still nice to avoid spurious changes where possible.
531-
let mut discovery_hash = FnvHasher::with_key(0);
532531

533-
for discovery_cm in discovery::build_discovery_configmaps(
534-
hive,
535-
hive,
536-
hive_role,
537-
&resolved_product_image,
538-
None,
539-
listener,
540-
)
541-
.await
542-
.context(BuildDiscoveryConfigSnafu)?
543-
{
544-
let discovery_cm = cluster_resources
545-
.add(client, discovery_cm)
546-
.await
547-
.context(ApplyDiscoveryConfigSnafu)?;
548-
if let Some(generation) = discovery_cm.metadata.resource_version {
549-
discovery_hash.write(generation.as_bytes())
532+
for discovery_cm in discovery::build_discovery_configmaps(
533+
hive,
534+
hive,
535+
hive_role,
536+
&resolved_product_image,
537+
None,
538+
listener,
539+
)
540+
.await
541+
.context(BuildDiscoveryConfigSnafu)?
542+
{
543+
let discovery_cm = cluster_resources
544+
.add(client, discovery_cm)
545+
.await
546+
.context(ApplyDiscoveryConfigSnafu)?;
547+
if let Some(generation) = discovery_cm.metadata.resource_version {
548+
discovery_hash.write(generation.as_bytes())
549+
}
550550
}
551551
}
552552

rust/operator-binary/src/discovery.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
use std::num::TryFromIntError;
2-
31
use snafu::{OptionExt, ResultExt, Snafu};
42
use stackable_operator::{
53
builder::{configmap::ConfigMapBuilder, meta::ObjectMetaBuilder},
64
commons::product_image_selection::ResolvedProductImage,
75
crd::listener::v1alpha1::Listener,
8-
k8s_openapi::api::core::v1::{ConfigMap, Service},
6+
k8s_openapi::api::core::v1::ConfigMap,
97
kube::{Resource, runtime::reflector::ObjectRef},
108
};
119

@@ -30,18 +28,7 @@ pub enum Error {
3028
},
3129
#[snafu(display("could not find port [{port_name}] for rolegroup listener {role}"))]
3230
NoServicePort { port_name: String, role: String },
33-
#[snafu(display("service [{obj_ref}] port [{port_name}] does not have a nodePort "))]
34-
NoNodePort {
35-
port_name: String,
36-
obj_ref: ObjectRef<Service>,
37-
},
38-
#[snafu(display("could not find Endpoints for {svc}"))]
39-
FindEndpoints {
40-
source: stackable_operator::client::Error,
41-
svc: ObjectRef<Service>,
42-
},
43-
#[snafu(display("nodePort was out of range"))]
44-
InvalidNodePort { source: TryFromIntError },
31+
4532
#[snafu(display("invalid owner name for discovery ConfigMap"))]
4633
InvalidOwnerNameForDiscoveryConfigMap,
4734

0 commit comments

Comments
 (0)