Skip to content

Commit df9f14d

Browse files
committed
feat(operator): consolidated apply summary for services needing ingress recreation
Review F2: the 'service exists without service discovery' warning was a mid-run eprintln that's easy to miss in non-interactive CI, so a partial apply could look like a clean success. apply_ecs now returns whether the service needs recreation; apply::run collects these and prints a single consolidated ⚠ summary block (with the exact recreate commands) after the 'N service(s) applied' line. build + clippy -D warnings + test (11 passed).
1 parent 499df8c commit df9f14d

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

operator/src/apply.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,30 @@ pub async fn run(aws_config: &aws_config::SdkConfig, file_path: &str, sync_confi
6060
}
6161
}
6262

63+
let mut needs_recreate: Vec<String> = Vec::new();
6364
for m in &manifests {
6465
println!(" Applying {} (ECS)...", m.metadata.name);
65-
apply_ecs(&ecs, &s3, aws_config, m, wait).await?;
66+
if apply_ecs(&ecs, &s3, aws_config, m, wait).await? {
67+
needs_recreate.push(format!("{}/{}", m.metadata.namespace, m.metadata.name));
68+
}
6669
}
6770

6871
println!("\n{} service(s) applied.", manifests.len());
72+
73+
// Surface the create-only service-discovery limitation as a consolidated
74+
// summary so it isn't lost in mid-run output (e.g. in non-interactive CI).
75+
if !needs_recreate.is_empty() {
76+
eprintln!(
77+
"\n⚠ {} service(s) have ingress configured but were created WITHOUT service\n discovery, so webhook traffic will NOT reach them until recreated:",
78+
needs_recreate.len()
79+
);
80+
for id in &needs_recreate {
81+
eprintln!(" - {id}");
82+
}
83+
eprintln!(
84+
" ECS service registries can only be set at creation time. For each, run:\n oabctl delete oabservice <name> --cluster oab --namespace <ns> && oabctl apply -f <manifest>"
85+
);
86+
}
6987
Ok(())
7088
}
7189

@@ -117,7 +135,7 @@ async fn apply_ecs(
117135
config: &aws_config::SdkConfig,
118136
m: &OABServiceManifest,
119137
wait: bool,
120-
) -> Result<()> {
138+
) -> Result<bool> {
121139
let ecs_rt = match &m.spec.runtime {
122140
Runtime::Ecs(rt) => rt,
123141
_ => unreachable!(),
@@ -266,6 +284,7 @@ async fn apply_ecs(
266284
.and_then(|r| r.services().first())
267285
.is_some_and(|s| !s.service_registries().is_empty());
268286

287+
let mut needs_recreate = false;
269288
if service_active {
270289
ecs.update_service()
271290
.cluster("oab")
@@ -278,6 +297,7 @@ async fn apply_ecs(
278297
println!(" ✓ {} updated", m.metadata.name);
279298

280299
if cloud_map.is_some() && !has_registries {
300+
needs_recreate = true;
281301
eprintln!(
282302
" ⚠ Service '{}' already exists WITHOUT service discovery.",
283303
m.metadata.name
@@ -361,7 +381,7 @@ async fn apply_ecs(
361381
eprintln!(" ✓ {} is stable", m.metadata.name);
362382
}
363383

364-
Ok(())
384+
Ok(needs_recreate)
365385
}
366386

367387
async fn wait_for_stable(ecs: &aws_sdk_ecs::Client, cluster: &str, service: &str) -> Result<()> {

0 commit comments

Comments
 (0)