Skip to content

Commit

Permalink
Add ecs-agent container healthcheck localhost ip override env var
Browse files Browse the repository at this point in the history
  • Loading branch information
fierlion committed Mar 16, 2021
1 parent 5be7aa0 commit 8df1a05
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ additional details on each available environment variable.
| `ECS_ENABLE_TASK_CPU_MEM_LIMIT` | `true` | Whether to enable task-level cpu and memory limits | `true` | `false` |
| `ECS_CGROUP_PATH` | `/sys/fs/cgroup` | The root cgroup path that is expected by the ECS agent. This is the path that accessible from the agent mount. | `/sys/fs/cgroup` | Not applicable |
| `ECS_CGROUP_CPU_PERIOD` | `10ms` | CGroups CPU period for task level limits. This value should be between 8ms to 100ms | `100ms` | Not applicable |
| `AGENT_HEALTHCHECK_LOCALHOST_OVERRIDE` | `127.0.0.1` | Override for the ecs-agent container's healthcheck localhost ip address| `localhost` | `localhost` |
| `ECS_ENABLE_CPU_UNBOUNDED_WINDOWS_WORKAROUND` | `true` | When `true`, ECS will allow CPU unbounded(CPU=`0`) tasks to run along with CPU bounded tasks in Windows. | Not applicable | `false` |
| `ECS_ENABLE_MEMORY_UNBOUNDED_WINDOWS_WORKAROUND` | `true` | When `true`, ECS will ignore the memory reservation parameter (soft limit) to run along with memory bounded tasks in Windows. To run a memory unbounded task, omit the memory hard limit and set any memory reservation, it will be ignored. | Not applicable | `false` |
| `ECS_TASK_METADATA_RPS_LIMIT` | `100,150` | Comma separated integer values for steady state and burst throttle limits for task metadata endpoint | `40,60` | `40,60` |
Expand Down
15 changes: 14 additions & 1 deletion agent/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
package app

import (
"fmt"
"os"
"time"

"github.com/aws/amazon-ecs-agent/agent/app/args"
Expand All @@ -24,6 +26,10 @@ import (
log "github.com/cihub/seelog"
)

const (
HEALTHCHECK_LOCALHOST_OVERRIDE_ENV_VAR = "AGENT_HEALTHCHECK_LOCALHOST_OVERRIDE"
)

// Run runs the ECS Agent App. It returns an exit code, which is used by
// main() to set the status code for the program
func Run(arguments []string) int {
Expand All @@ -43,7 +49,14 @@ func Run(arguments []string) int {
// timeout of 30s. This is so that we can catch any http timeout and log the
// issue within agent logs.
// see https://docs.docker.com/engine/reference/builder/#healthcheck
return runHealthcheck("http://localhost:51678/v1/metadata", time.Second*25)
// if AGENT_HEALTHCHECK_LOCALHOST_OVERRIDE env var is set, it will override
// the healthcheck's localhost ip address inside the ecs-agent container
localhost := "localhost"
if localhostOverride := os.Getenv(HEALTHCHECK_LOCALHOST_OVERRIDE_ENV_VAR); localhostOverride != "" {
localhost = localhostOverride
}
healthcheckUrl := fmt.Sprintf("http://%s:51678/v1/metadata", localhost)
return runHealthcheck(healthcheckUrl, time.Second*25)
}

if *parsedArgs.LogLevel != "" {
Expand Down

0 comments on commit 8df1a05

Please sign in to comment.