fix(ecs): accept a service ARN in ListTasks (#4859)

ListTasks looked the serviceName filter up by the string it was given,
so only a bare service name matched. A service ARN, which is what CDK
passes, found no service, and the call returned an empty taskArns list
even while the service had running tasks.

The filter now goes through extractServiceName, the helper UpdateService
and DeleteService already use, which keeps the last path segment. A
name, a full service/<cluster>/<name> ARN, the older service/<name> ARN
and <cluster>/<name> all resolve to the service in the request's
cluster. AWS accepts each of these forms. An unknown service still
lists nothing, which is unchanged.
This commit is contained in:
Mario Toffia authored and GitHub committed 2026-10-08 07:41:20 -04:00
1 parent ddc47a465d
commit 5a8694e97a
3 files changed
+57 -2

No files matched your search

@@ -2186,9 +2186,10 @@ public class EcsService implements ContainerTeardown, ResourceProvider, Resettab
: (serviceName != null ? clusters.get(clusterKey(region, DEFAULT_CLUSTER)) : null);
String clusterArn = clusterRef != null ? cluster.getClusterArn() : null;
// A serviceName filter selects the service's own tasks, so it resolves through the
// reconciler-stamped ownership rather than the caller-supplied group.
// reconciler-stamped ownership rather than the caller-supplied group. It may be the
// service's name or its ARN; as on AWS, only the last path segment names the service.
EcsServiceModel svc = serviceName != null && cluster != null
? services.get(serviceKey(region, cluster.getClusterName(), serviceName))
? services.get(serviceKey(region, cluster.getClusterName(), extractServiceName(serviceName)))
: null;
String family = request.getFamily();
LaunchType launchType = request.getLaunchType();