huskies: merge 1182 bug Sled uplinks all register as 'workspace' — containers never get HUSKIES_PROJECT_NAME
This commit is contained in:
@@ -343,6 +343,12 @@ async fn run_sled_uplink_session(
|
||||
"[gateway/sled-uplink] Sled '{}' connected and registered",
|
||||
identity
|
||||
);
|
||||
if !state.projects.read().await.contains_key(&identity) {
|
||||
crate::slog_warn!(
|
||||
"[gateway/sled-uplink] Sled registered under name '{}', which matches no project in projects.toml",
|
||||
identity
|
||||
);
|
||||
}
|
||||
|
||||
// Aggregator channel for perm responses produced by spawned per-request tasks.
|
||||
let (agg_tx, mut agg_rx) =
|
||||
@@ -734,4 +740,49 @@ mod tests {
|
||||
"with no sled tokens configured anywhere, the uplink must accept unauthenticated"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn unconfigured_project_name_logs_warning() {
|
||||
let mut projects = BTreeMap::new();
|
||||
projects.insert(
|
||||
"other-project".to_string(),
|
||||
ProjectEntry::with_url("http://other-project:3001"),
|
||||
);
|
||||
let config = GatewayConfig {
|
||||
projects,
|
||||
sled_tokens: BTreeMap::new(),
|
||||
release_channels: BTreeMap::new(),
|
||||
};
|
||||
let (base_url, _state) = start_test_gateway(config).await;
|
||||
let url = format!("{base_url}/api/sled-uplink?project=ghost-project");
|
||||
|
||||
let (mut ws_stream, _) = tokio_tungstenite::connect_async(url.as_str())
|
||||
.await
|
||||
.expect("uplink connect should succeed when no tokens are configured");
|
||||
|
||||
let identity = crate::sled_uplink::UplinkEnvelope {
|
||||
msg_type: "identity".to_string(),
|
||||
req_id: String::new(),
|
||||
payload: serde_json::json!({ "project": "ghost-project" }),
|
||||
};
|
||||
ws_stream
|
||||
.send(tokio_tungstenite::tungstenite::Message::Text(
|
||||
serde_json::to_string(&identity).unwrap().into(),
|
||||
))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Give the server task time to process the identity frame and register.
|
||||
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
|
||||
|
||||
let warnings = crate::log_buffer::global().get_recent(
|
||||
50,
|
||||
Some("ghost-project"),
|
||||
Some(&crate::log_buffer::LogLevel::Warn),
|
||||
);
|
||||
assert!(
|
||||
warnings.iter().any(|w| w.contains("matches no project")),
|
||||
"expected an unconfigured-project warning, got: {warnings:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user