Skip to content

Commit cb21b84

Browse files
committed
add logging
1 parent c59d90f commit cb21b84

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

Diff for: clickhouse-admin/src/context.rs

+20-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use omicron_common::address::CLICKHOUSE_TCP_PORT;
1919
use omicron_common::api::external::Generation;
2020
use oximeter_db::Client as OximeterClient;
2121
use oximeter_db::OXIMETER_VERSION;
22-
use slog::info;
22+
use slog::{info, error};
2323
use slog::Logger;
2424
use std::fs::File;
2525
use std::io::{BufRead, BufReader};
@@ -109,7 +109,7 @@ impl ServerContext {
109109
// We only want to handle one in flight request at a time. Reconfigurator execution will retry
110110
// again later anyway. We use a flume bounded channel with a size of 0 to act as a rendezvous channel.
111111
let (inner_tx, inner_rx) = flume::bounded(0);
112-
tokio::spawn(long_running_ch_server_task(inner_rx));
112+
tokio::spawn(long_running_ch_admin_server_task(inner_rx));
113113

114114
Ok(Self {
115115
clickhouse_cli,
@@ -158,7 +158,7 @@ pub enum ClickhouseAdminServerRequest {
158158
},
159159
}
160160

161-
async fn long_running_ch_server_task(
161+
async fn long_running_ch_admin_server_task(
162162
incoming: Receiver<ClickhouseAdminServerRequest>,
163163
) {
164164
while let Ok(request) = incoming.recv_async().await {
@@ -168,23 +168,35 @@ async fn long_running_ch_server_task(
168168
replica_settings,
169169
response,
170170
} => {
171+
// TODO: Remove clone
171172
let result =
172-
generate_config_and_enable_svc(ctx, replica_settings);
173-
response.send(result).expect("failed to send value from configuration generation to channel");
173+
generate_config_and_enable_svc(ctx.clone(), replica_settings);
174+
if let Err(e) = response.send(result) {
175+
error!(
176+
&ctx.log,
177+
"failed to send value from configuration generation to channel: {e:?}"
178+
);
179+
};
174180
}
175181
ClickhouseAdminServerRequest::DbInit {
176182
ctx,
177183
replicated,
178184
response,
179185
} => {
180-
let result = init_db(ctx, replicated).await;
181-
response.send(result).expect("failed to send value from database initialization to channel");
186+
let result = init_db(ctx.clone(), replicated).await;
187+
if let Err(e) = response.send(result) {
188+
error!(
189+
&ctx.log,
190+
"failed to send value from database initialization to channel: {e:?}"
191+
);
192+
};
182193
}
183194
}
184195
}
185196
}
186197

187198
pub fn generate_config_and_enable_svc(
199+
// TODO: Expand ctx into separate items
188200
ctx: Arc<ServerContext>,
189201
replica_settings: ServerConfigurableSettings,
190202
) -> Result<ReplicaConfig, HttpError> {
@@ -222,6 +234,7 @@ pub fn generate_config_and_enable_svc(
222234
}
223235

224236
pub async fn init_db(
237+
// TODO: Expand ctx into separate items
225238
ctx: Arc<ServerContext>,
226239
replicated: bool,
227240
) -> Result<(), HttpError> {

0 commit comments

Comments
 (0)