Skip to content

Commit 9209edb

Browse files
authored
Fix/webhook env parsing (#374)
* only parse webhook and node config when actually set
1 parent 6c79ea8 commit 9209edb

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

crates/orchestrator/src/main.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -200,22 +200,23 @@ async fn main() -> Result<()> {
200200
let mut webhook_plugins: Vec<WebhookPlugin> = vec![];
201201

202202
let configs = std::env::var("WEBHOOK_CONFIGS").unwrap_or_default();
203-
match serde_json::from_str::<Vec<WebhookConfig>>(&configs) {
204-
Ok(configs) if !configs.is_empty() => {
205-
for config in configs {
206-
let plugin = WebhookPlugin::new(config);
207-
let plugin_clone = plugin.clone();
208-
webhook_plugins.push(plugin_clone);
209-
status_update_plugins.push(Box::new(plugin));
203+
if !configs.is_empty() {
204+
match serde_json::from_str::<Vec<WebhookConfig>>(&configs) {
205+
Ok(configs) => {
206+
for config in configs {
207+
let plugin = WebhookPlugin::new(config);
208+
let plugin_clone = plugin.clone();
209+
webhook_plugins.push(plugin_clone);
210+
status_update_plugins.push(Box::new(plugin));
211+
info!("Plugin: Webhook plugin initialized");
212+
}
213+
}
214+
Err(e) => {
215+
error!("Failed to parse webhook configs from environment: {}", e);
210216
}
211217
}
212-
Ok(_) => {
213-
info!("No webhook configurations provided");
214-
}
215-
Err(e) => {
216-
error!("Failed to parse webhook configs from environment: {}", e);
217-
std::process::exit(1);
218-
}
218+
} else {
219+
info!("No webhook configurations provided");
219220
}
220221

221222
let webhook_sender_store = store_context.clone();
@@ -234,8 +235,9 @@ async fn main() -> Result<()> {
234235
}
235236

236237
// Load node group configurations from environment variable
237-
if let Ok(configs_json) = std::env::var("NODE_GROUP_CONFIGS") {
238-
match serde_json::from_str::<Vec<NodeGroupConfiguration>>(&configs_json) {
238+
let node_group_configs = std::env::var("NODE_GROUP_CONFIGS").unwrap_or_default();
239+
if !node_group_configs.is_empty() {
240+
match serde_json::from_str::<Vec<NodeGroupConfiguration>>(&node_group_configs) {
239241
Ok(configs) if !configs.is_empty() => {
240242
let node_groups_heartbeats = heartbeats.clone();
241243
let group_plugin = NodeGroupsPlugin::new(
@@ -250,7 +252,7 @@ async fn main() -> Result<()> {
250252
node_groups_plugin = Some(Arc::new(group_plugin_for_server));
251253
scheduler_plugins.push(Box::new(group_plugin));
252254
status_update_plugins.push(Box::new(status_group_plugin));
253-
info!("Node group plugin initialized");
255+
info!("Plugin: Node group plugin initialized");
254256
}
255257
Ok(_) => {
256258
info!(

0 commit comments

Comments
 (0)