Skip to content

Commit e3a4426

Browse files
author
Yuriy Bezsonov
committed
refactor(perf-platform): rename ECS_FARGATE to ECS platform enum
1 parent aea6352 commit e3a4426

10 files changed

Lines changed: 27 additions & 26 deletions

File tree

apps/perf-analyzer/src/main/java/com/example/perf/analyzer/AnalysisService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ record WorkloadMetadata(String githubRepo, String githubPath) {
214214
private LocatedCollector locateCollector(AnalysisRequest request) {
215215
return switch (request.platform()) {
216216
case EKS -> locateCollectorEks(request);
217-
case ECS_FARGATE -> locateCollectorEcs(request);
217+
case ECS -> locateCollectorEcs(request);
218218
};
219219
}
220220

@@ -378,16 +378,16 @@ private static String shortRandom() {
378378
* queries must use the same suffix or Pyroscope returns no data.
379379
*/
380380
private static String pyroscopeServiceName(AnalysisRequest request) {
381-
var suffix = request.platform() == Platform.ECS_FARGATE ? "ecs" : "eks";
381+
var suffix = request.platform() == Platform.ECS ? "ecs" : "eks";
382382
return request.service() + "-" + suffix;
383383
}
384384

385385
// === Domain types ===
386386

387387
public enum Platform {
388-
EKS, ECS_FARGATE;
388+
EKS, ECS;
389389

390-
/** Case-insensitive deserialization: accepts "eks"/"EKS" and "ecs-fargate"/"ECS_FARGATE". */
390+
/** Case-insensitive deserialization: accepts "eks"/"EKS" and "ecs"/"ECS". */
391391
@com.fasterxml.jackson.annotation.JsonCreator
392392
public static Platform fromJson(String value) {
393393
if (value == null) return null;
@@ -407,7 +407,7 @@ public enum DumpKind {
407407
public record AnalysisRequest(
408408
String service, Platform platform, String pod, String task, String reason, TriggerSource source
409409
) {
410-
public String target() { return platform == Platform.ECS_FARGATE ? task : pod; }
410+
public String target() { return platform == Platform.ECS ? task : pod; }
411411
}
412412

413413
public record AnalysisContext(

apps/perf-analyzer/src/main/java/com/example/perf/analyzer/AnalyzeController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ private static void validateTarget(AnalyzeRequest r) {
7676
if (r.platform() == AnalysisService.Platform.EKS && !hasPod) {
7777
throw new IllegalArgumentException("pod is required for platform=eks");
7878
}
79-
if (r.platform() == AnalysisService.Platform.ECS_FARGATE && !hasTask) {
80-
throw new IllegalArgumentException("task is required for platform=ecs-fargate");
79+
if (r.platform() == AnalysisService.Platform.ECS && !hasTask) {
80+
throw new IllegalArgumentException("task is required for platform=ecs");
8181
}
8282
}
8383

@@ -102,7 +102,7 @@ private AnalysisService.AnalysisRequest toRequest(Map<String, String> labels) {
102102
platform = AnalysisService.Platform.EKS;
103103
workload = serviceLabel.substring(0, serviceLabel.length() - "-eks".length());
104104
} else if (serviceLabel.endsWith("-ecs")) {
105-
platform = AnalysisService.Platform.ECS_FARGATE;
105+
platform = AnalysisService.Platform.ECS;
106106
workload = serviceLabel.substring(0, serviceLabel.length() - "-ecs".length());
107107
} else {
108108
// Unsuffixed — honour explicit platform label if present.

apps/perf-collector/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# perf-collector
22

3-
Runs alongside target JVMs on Amazon EKS (DaemonSet) and Amazon ECS Fargate
3+
Runs alongside target JVMs on Amazon EKS (DaemonSet) and Amazon ECS
44
(sidecar). Discovers JVMs whose owning workload is opted in with the
55
`perf-profile/service` label (EKS) or tag (ECS). Attaches async-profiler
66
for continuous Pyroscope push. Serves `POST /dump` to capture on-demand
@@ -58,15 +58,15 @@ Multi-arch (`linux/amd64` + `linux/arm64`), Amazon Corretto 25 JRE base.
5858
| `AWS_REGION` | yes | AWS Region for the S3 SDK client. |
5959
| `AWS_S3_BUCKET` | yes | Workshop bucket (SSM `workshop-bucket-name`). |
6060
| `PYROSCOPE_URL` | yes | `http://pyroscope.monitoring:4040` on EKS; internal NLB DNS on ECS. |
61-
| `PERF_COLLECTOR_PLATFORM` | yes | `eks` or `ecs_fargate`. Drives which `TargetResolver` bean wakes up. |
61+
| `PERF_COLLECTOR_PLATFORM` | yes | `eks` or `ecs`. Drives which `TargetResolver` bean wakes up. |
6262
| `NODE_NAME` | EKS only | From Downward API (`spec.nodeName`). Limits discovery to pods on own node. |
6363

6464
## Label / tag contract
6565

6666
| Platform | Opt-in marker | Service name source | Version source |
6767
|----------|---------------|---------------------|----------------|
6868
| EKS | pod label `perf-profile/service=<name>` | label value | `app.kubernetes.io/version` or container image tag |
69-
| ECS Fargate | task tag `perf-profile:service=<name>` | tag value | app container image tag |
69+
| ECS | task tag `perf-profile:service=<name>` | tag value | app container image tag |
7070

7171
Missing marker → workload is ignored entirely. No profiler attach, no
7272
Pyroscope samples, no footprint.
@@ -78,6 +78,6 @@ manifests, Pod Identity binding, and capability requirements.
7878
Key invariants:
7979

8080
- EKS DaemonSet: `hostPID: true` + `SYS_PTRACE` capability.
81-
- ECS Fargate task: `pidMode: task` + sidecar `linuxParameters.capabilities.add: ["SYS_PTRACE"]`.
81+
- ECS task: `pidMode: task` + sidecar `linuxParameters.capabilities.add: ["SYS_PTRACE"]`.
8282
- IAM: `perf-collector-eks-pod-role` (EKS) or `perf-collector-ecs-task-role`
8383
(ECS), both provisioned by the `PerfPlatform.java` CDK construct.

apps/perf-collector/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<artifactId>perf-collector</artifactId>
1414
<version>1.0.0</version>
1515
<name>perf-collector</name>
16-
<description>Agentic Performance Platform collector (DaemonSet on EKS, sidecar on ECS Fargate)</description>
16+
<description>Agentic Performance Platform collector (DaemonSet on EKS, sidecar on ECS)</description>
1717

1818
<properties>
1919
<java.version>25</java.version>
@@ -59,7 +59,7 @@
5959
<groupId>software.amazon.awssdk</groupId>
6060
<artifactId>s3</artifactId>
6161
</dependency>
62-
<!-- ECS client for DescribeTasks with tag inclusion. Fargate task metadata
62+
<!-- ECS client for DescribeTasks with tag inclusion. The task metadata
6363
endpoint does not expose task tags, so we call the ECS API directly. -->
6464
<dependency>
6565
<groupId>software.amazon.awssdk</groupId>

apps/perf-collector/src/main/java/com/example/perf/collector/Application.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* node, attaches async-profiler for continuous Pyroscope push, serves /dump
2525
* on demand for JFR and Thread.print.
2626
*
27-
* On Amazon ECS Fargate: sidecar, pidMode=task, SYS_PTRACE. Sees sibling
27+
* On Amazon ECS: sidecar, pidMode=task, SYS_PTRACE. Sees sibling
2828
* Java container's JVM via /proc; same mechanics.
2929
*
3030
* AWS and Kubernetes client beans live here so the rest of the package stays
@@ -44,16 +44,17 @@ S3Client s3Client(@Value("${AWS_REGION:us-east-1}") String region) {
4444
return S3Client.builder().region(Region.of(region)).build();
4545
}
4646

47-
/** ECS client — only on Fargate. The Fargate task-metadata endpoint does
48-
* not include task tags, so the resolver reads them via ecs:DescribeTasks. */
47+
/** ECS client — only when the collector runs as an ECS sidecar. The task
48+
* metadata endpoint does not include task tags, so the resolver reads
49+
* them via ecs:DescribeTasks. */
4950
@Bean
5051
@ConditionalOnProperty(prefix = "perf.collector", name = "platform",
51-
havingValue = "ecs_fargate")
52+
havingValue = "ecs")
5253
EcsClient ecsClient(@Value("${AWS_REGION:us-east-1}") String region) {
5354
return EcsClient.builder().region(Region.of(region)).build();
5455
}
5556

56-
/** Kubernetes client — only on EKS. The ECS Fargate resolver uses no K8s API. */
57+
/** Kubernetes client — only on EKS. The ECS resolver uses no K8s API. */
5758
@Bean
5859
@ConditionalOnProperty(prefix = "perf.collector", name = "platform",
5960
havingValue = "eks", matchIfMissing = true)

apps/perf-collector/src/main/java/com/example/perf/collector/CollectorController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static DumpTarget of(
6464
}
6565

6666
public String id() {
67-
return platform == Platform.ECS_FARGATE ? task : pod;
67+
return platform == Platform.ECS ? task : pod;
6868
}
6969

7070
private static Platform parsePlatform(String s) {

apps/perf-collector/src/main/java/com/example/perf/collector/CollectorProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public record CollectorProperties(
2424
String hostLibPath
2525
) {
2626

27-
public enum Platform { EKS, ECS_FARGATE }
27+
public enum Platform { EKS, ECS }
2828

2929
public enum DumpKind {
3030
JFR("jfr"),

apps/perf-collector/src/main/java/com/example/perf/collector/Profiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ private void pushFile(Path file, long pid, TargetJvm jvm) throws IOException, In
262262
// underlying workload (what the user set with perf-profile/service) is
263263
// published as a `workload` label for cross-platform pivoting.
264264
var platformTag = jvm.platform().name().toLowerCase().replace('_', '-');
265-
var platformSuffix = jvm.platform() == CollectorProperties.Platform.ECS_FARGATE
265+
var platformSuffix = jvm.platform() == CollectorProperties.Platform.ECS
266266
? "ecs"
267267
: "eks";
268268
var pyroscopeServiceName = jvm.serviceName() + "-" + platformSuffix;

apps/perf-collector/src/main/java/com/example/perf/collector/TargetResolver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ private static String stripRuntimePrefix(String containerId) {
155155
}
156156
}
157157

158-
/** ECS Fargate sidecar implementation. Reads task metadata endpoint. */
158+
/** ECS sidecar implementation. Reads task metadata endpoint. */
159159
@Component
160160
@ConditionalOnProperty(prefix = "perf.collector", name = "platform",
161-
havingValue = "ecs_fargate")
161+
havingValue = "ecs")
162162
final class Ecs implements TargetResolver {
163163

164164
private static final Logger logger = LoggerFactory.getLogger(Ecs.class);
@@ -201,7 +201,7 @@ public List<TargetJvm> resolve() {
201201
if (javaPids.isEmpty()) return List.of();
202202

203203
var pid = javaPids.getFirst(); // one sibling Java container per task
204-
var t = new TargetJvm(pid, serviceName, version, taskId, Platform.ECS_FARGATE);
204+
var t = new TargetJvm(pid, serviceName, version, taskId, Platform.ECS);
205205
byTaskId.clear();
206206
byTaskId.put(taskId, t);
207207
logger.info("ECS discovery: taskId={} service={} version={} pid={}",

apps/perf-collector/src/main/resources/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ perf:
1919
discovery-interval-seconds: 30
2020
# Node identity (EKS DaemonSet): kubelet downward API.
2121
node-name: ${NODE_NAME:}
22-
# Platform selector (set per deployment: eks | ecs_fargate).
22+
# Platform selector (set per deployment: eks | ecs).
2323
platform: ${PERF_COLLECTOR_PLATFORM:eks}
2424
async-profiler-lib: /opt/perf-collector/async-profiler/libasyncProfiler.so
2525
jattach-binary: /opt/perf-collector/bin/jattach

0 commit comments

Comments
 (0)