Skip to content

Commit

Permalink
requested changes 3
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuajerin committed Aug 26, 2024
1 parent 58b75c2 commit c29df1e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions tembo-operator/src/dedicated_networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ pub async fn reconcile_dedicated_networking(
"Dedicated networking is not configured for CoreDB instance: {}",
cdb.name_any()
);

delete_dedicated_networking_service(client.clone(), &ns, &cdb.name_any(), false)
.await
.map_err(|e| {
error!("Failed to delete primary service: {:?}", e);
e
})?;

delete_dedicated_networking_service(client.clone(), &ns, &cdb.name_any(), true)
.await
.map_err(|e| {
error!("Failed to delete standby service: {:?}", e);
e
})?;
}

debug!(
Expand Down Expand Up @@ -168,7 +182,7 @@ async fn reconcile_dedicated_networking_network_policies(
.collect::<Vec<String>>();

let policy_name = format!("{}-allow-nlb", cdb_name);
info!(
debug!(
"Applying network policy: {} in namespace: {} to allow traffic from CIDRs: {:?}",
policy_name, namespace, cidr_list
);
Expand Down Expand Up @@ -222,7 +236,7 @@ async fn reconcile_dedicated_networking_network_policies(
OperatorError::NetworkPolicyError(format!("Failed to apply network policy: {:?}", e))
})?;

info!(
debug!(
"Successfully applied network policy: {} in namespace: {}",
policy_name, namespace
);
Expand Down Expand Up @@ -264,7 +278,7 @@ async fn reconcile_dedicated_networking_service(
};
let lb_internal = if is_public { "false" } else { "true" };

info!(
debug!(
"Applying Service: {} in namespace: {} with type: {} and scheme: {}",
service_name, namespace, service_type, lb_scheme
);
Expand Down Expand Up @@ -375,7 +389,7 @@ async fn reconcile_dedicated_networking_service(
OperatorError::ServiceError(format!("Failed to apply service: {:?}", e))
})?;

info!(
debug!(
"Successfully applied service: {} in namespace: {}",
service_name, namespace
);
Expand Down Expand Up @@ -406,13 +420,13 @@ async fn delete_dedicated_networking_service(

let svc_api: Api<Service> = Api::namespaced(client, namespace);

info!(
debug!(
"Checking if service: {} exists in namespace: {} for deletion",
service_name, namespace
);

if svc_api.get(&service_name).await.is_ok() {
debug!(
info!(
"Service: {} exists in namespace: {}. Proceeding with deletion.",
service_name, namespace
);
Expand Down
2 changes: 1 addition & 1 deletion tembo-operator/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,7 @@ mod test {
let state = State::default();

let mut rng = rand::thread_rng();
let suffix = rng.gen_range(0..10000);
let suffix = rng.gen_range(1000..10000);
let name = &format!("test-dedicated-networking-{}", suffix.clone());
let namespace = match create_namespace(client.clone(), name).await {
Ok(namespace) => namespace,
Expand Down

0 comments on commit c29df1e

Please sign in to comment.