Skip to content

Commit cd30003

Browse files
Add cycleio infra platform (#212)
1 parent 209dadd commit cd30003

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

Dockerfiles/DockerfileKube

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ COPY --from=build /app/configyamls-k8s/otel-config-deployment.yaml /app/otel-con
2727
# A symlink to support existing k8s agent users
2828
RUN ln -s /usr/bin/mw-agent /usr/bin/api-server
2929

30-
CMD ["mw-agent", "start"]
30+
CMD ["mw-agent", "start"]

cmd/host-agent/main.go

+17-7
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,22 @@ func getFlags(execPath string, cfg *agent.HostConfig) []cli.Flag {
323323
}
324324
}
325325

326+
func detectInfraPlatform() agent.InfraPlatform {
327+
awsEnv := os.Getenv("AWS_EXECUTION_ENV")
328+
if awsEnv == "AWS_ECS_EC2" {
329+
return agent.InfraPlatformECSEC2
330+
} else if awsEnv == "AWS_ECS_FARGATE" {
331+
return agent.InfraPlatformECSFargate
332+
}
333+
334+
cycleIOEnv := os.Getenv("CYCLE_INSTANCE_ID")
335+
if cycleIOEnv != "" {
336+
return agent.InfraPlatformCycleIO
337+
}
338+
339+
return agent.InfraPlatformInstance
340+
}
341+
326342
func main() {
327343
zapEncoderCfg := zapcore.EncoderConfig{
328344
MessageKey: "message",
@@ -407,13 +423,7 @@ func main() {
407423
go profiler.StartProfiling("mw-host-agent", cfg.Target, cfg.HostTags)
408424
}
409425

410-
infraPlatform := agent.InfraPlatformInstance
411-
awsEnv := os.Getenv("AWS_EXECUTION_ENV")
412-
if awsEnv == "AWS_ECS_EC2" {
413-
infraPlatform = agent.InfraPlatformECSEC2
414-
} else if awsEnv == "AWS_ECS_FARGATE" {
415-
infraPlatform = agent.InfraPlatformECSFargate
416-
}
426+
infraPlatform := detectInfraPlatform()
417427

418428
hostname, err := os.Hostname()
419429
if err != nil {

pkg/agent/definitions.go

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ var (
4646
InfraPlatformECSEC2 InfraPlatform = 2
4747
// InfraPlatformECSFargate is for AWS ECS Fargate platform
4848
InfraPlatformECSFargate InfraPlatform = 3
49+
// InfraPlatformCycleIO is for Cycle.io platform
50+
InfraPlatformCycleIO InfraPlatform = 4
4951
)
5052

5153
func (p InfraPlatform) String() string {

0 commit comments

Comments
 (0)