From 93722fd7b3063eedcf014621f1c8fd4bc1158cd9 Mon Sep 17 00:00:00 2001 From: mvlabat Date: Sun, 21 Nov 2021 01:35:44 +0200 Subject: [PATCH] Fix parsing autoscaler webhook requests --- bins/matchmaker/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bins/matchmaker/src/main.rs b/bins/matchmaker/src/main.rs index 0195d4ae..e8b0b7ff 100644 --- a/bins/matchmaker/src/main.rs +++ b/bins/matchmaker/src/main.rs @@ -216,7 +216,7 @@ async fn watch_game_servers(tx: Sender, servers: Servers) { #[derive(Debug, Serialize, Deserialize, Clone)] struct FleetAutoscaleReview { request: FleetAutoscaleRequest, - response: FleetAutoscaleResponse, + response: Option, } #[derive(Debug, Serialize, Deserialize, Clone)] @@ -292,11 +292,16 @@ async fn serve_webhook_service(tx: Sender, servers: Servers) let total_capacity = servers.iter().map(|s| s.player_capacity).sum::() as u32; let desired_replicas_count = active_players.unstable_div_ceil(total_capacity); - fleet_autoscale_review.response = FleetAutoscaleResponse { + fleet_autoscale_review.response = Some(FleetAutoscaleResponse { uid: fleet_autoscale_review.request.uid.clone(), scale: desired_replicas_count != fleet_autoscale_review.request.status.replicas, replicas: desired_replicas_count, - }; + }); + + log::info!( + "Webhook response: {:?}", + fleet_autoscale_review.response.as_ref().unwrap() + ); let body = serde_json::to_vec(&fleet_autoscale_review).unwrap(); Ok(hyper::Response::new(