Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch 'dev' into env_files #2419

Merged
merged 10 commits into from
Apr 1, 2020
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,3 @@ matrix:
- os: windows
script:
- go test -v -race -tags unit -timeout 40s ./agent/...
- os: osx
script:
- make get-deps
- make test
- make static-check
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.38.0
* Feature - add integration with EFS's access point and IAM authorization features; support EFS volume for task in awsvpc network mode
* Enhancement - adding Runtime ID of container to agent logs [#2399](https://github.com/aws/amazon-ecs-agent/pull/2399)

## 1.37.0
* Feature - additional parameters allowed when specifying secretsmanager secret [#2358](https://github.com/aws/amazon-ecs-agent/pull/2358)
* Bug - fixed a bug where Firelens container could not use config file from S3 bucket in us-east-1 [#2356](https://github.com/aws/amazon-ecs-agent/pull/2356)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ additional details on each available environment variable.
| `ECS_LOG_OUTPUT_FORMAT` | `logfmt` | `json` | Determines the log output format. When the json format is used, each line in the log would be a structured JSON map. | `logfmt` | `logfmt` |
| `ECS_LOG_MAX_FILE_SIZE_MB` | `10` | When the ECS_LOG_ROLLOVER_TYPE variable is set to size, this variable determines the maximum size (in MB) the log file before it is rotated. If the rollover type is set to hourly then this variable is ignored. | `10` | `10` |
| `ECS_LOG_MAX_ROLL_COUNT` | `24` | Determines the number of rotated log files to keep. Older log files are deleted once this limit is reached. | `24` | `24` |
| `ECS_ENABLE_AWSLOGS_EXECUTIONROLE_OVERRIDE` | `true` | Whether to enable awslogs log driver to authenticate via credentials of task execution IAM role. Needs to be true if you want to use awslogs log driver in a task that has task execution IAM role specified. When using the ecs-init RPM with version equal or later than V1.16.0-1, this env is set to true by default. | `false` | `false` |

### Persistence

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.37.0
1.38.0
6 changes: 5 additions & 1 deletion agent/acs/handler/acs_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,11 @@ func (acsSession *session) startACSSession(client wsclient.ClientServer) error {
// Stop receiving and sending messages from and to ACS when
// client.Serve returns an error. This can happen when the
// the connection is closed by ACS or the agent
seelog.Infof("ACS connection closed: %v", err)
if err == nil || err == io.EOF {
seelog.Info("ACS Websocket connection closed for a valid reason")
} else {
seelog.Errorf("Error: lost websocket connection with Agent Communication Service (ACS): %v", err)
}
return err
}
}
Expand Down
2 changes: 2 additions & 0 deletions agent/api/statechange.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type AttachmentStateChange struct {
}

// NewTaskStateChangeEvent creates a new task state change event
// returns error if the state change doesn't need to be sent to the ECS backend.
func NewTaskStateChangeEvent(task *apitask.Task, reason string) (TaskStateChange, error) {
var event TaskStateChange
taskKnownStatus := task.GetKnownStatus()
Expand Down Expand Up @@ -117,6 +118,7 @@ func NewTaskStateChangeEvent(task *apitask.Task, reason string) (TaskStateChange
}

// NewContainerStateChangeEvent creates a new container state change event
// returns error if the state change doesn't need to be sent to the ECS backend.
func NewContainerStateChangeEvent(task *apitask.Task, cont *apicontainer.Container, reason string) (ContainerStateChange, error) {
var event ContainerStateChange
contKnownStatus := cont.GetKnownStatus()
Expand Down
3 changes: 3 additions & 0 deletions agent/config/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func parseAvailableLoggingDrivers() []dockerclient.LoggingDriver {

func parseVolumePluginCapabilities() []string {
capsFromEnv := os.Getenv("ECS_VOLUME_PLUGIN_CAPABILITIES")
if capsFromEnv == "" {
return []string{}
}
capsDecoder := json.NewDecoder(strings.NewReader(capsFromEnv))
var caps []string
err := capsDecoder.Decode(&caps)
Expand Down
4 changes: 2 additions & 2 deletions agent/dockerclient/dockerapi/docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func (dg *dockerGoClient) PullImage(ctx context.Context, image string,
func() error {
err := dg.pullImage(ctx, image, authData)
if err != nil {
seelog.Warnf("DockerGoClient: failed to pull image %s: %s", image, err.Error())
seelog.Errorf("DockerGoClient: failed to pull image %s: [%s] %s", image, err.ErrorName(), err.Error())
}
return err
})
Expand Down Expand Up @@ -695,7 +695,7 @@ func (dg *dockerGoClient) stopContainer(ctx context.Context, dockerID string, ti
err = client.ContainerStop(ctx, dockerID, &timeout)
metadata := dg.containerMetadata(ctx, dockerID)
if err != nil {
seelog.Infof("DockerGoClient: error stopping container %s: %v", dockerID, err)
seelog.Errorf("DockerGoClient: error stopping container %s: %v", dockerID, err)
if metadata.Error == nil {
if strings.Contains(err.Error(), "No such container") {
err = NoSuchContainerError{dockerID}
Expand Down
16 changes: 7 additions & 9 deletions agent/engine/dependencygraph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,11 @@ func verifyContainerOrderingStatusResolvable(target *apicontainer.Container, exi
}
}

// We want to fail fast if the dependency container did not exit successfully' because target container
// We want to fail fast if the dependency container has stopped but did not exit successfully because target container
// can then never progress to its desired state when the dependency condition is 'SUCCESS'
if dependency.Condition == successCondition && dependencyContainer.GetKnownExitCode() != nil {
if !hasDependencyStoppedSuccessfully(dependencyContainer, dependency.Condition) {
return nil, fmt.Errorf("dependency graph: failed to resolve container ordering dependency [%v] for target [%v] as dependency did not exit successfully.", dependencyContainer, target)
}
if dependency.Condition == successCondition && dependencyContainer.GetKnownStatus() == apicontainerstatus.ContainerStopped &&
!hasDependencyStoppedSuccessfully(dependencyContainer) {
return nil, fmt.Errorf("dependency graph: failed to resolve container ordering dependency [%v] for target [%v] as dependency did not exit successfully.", dependencyContainer, target)
}

if !resolves(target, dependencyContainer, dependency.Condition) {
Expand Down Expand Up @@ -443,10 +442,9 @@ func hasDependencyTimedOut(dependOnContainer *apicontainer.Container, dependency
}
}

func hasDependencyStoppedSuccessfully(dependency *apicontainer.Container, condition string) bool {
isDependencyStoppedSuccessfully := dependency.GetKnownStatus() == apicontainerstatus.ContainerStopped &&
*dependency.GetKnownExitCode() == 0
return isDependencyStoppedSuccessfully
func hasDependencyStoppedSuccessfully(dependency *apicontainer.Container) bool {
p := dependency.GetKnownExitCode()
return p != nil && *p == 0
}

func verifyContainerOrderingStatus(dependsOnContainer *apicontainer.Container) bool {
Expand Down
8 changes: 8 additions & 0 deletions agent/engine/dependencygraph/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,14 @@ func TestContainerOrderingCanResolve(t *testing.T) {
DependencyCondition: successCondition,
Resolvable: true,
},
{
TargetDesired: apicontainerstatus.ContainerRunning,
DependencyKnown: apicontainerstatus.ContainerRunning,
DependencyDesired: apicontainerstatus.ContainerStopped,
ExitCode: 0,
DependencyCondition: successCondition,
Resolvable: true,
},
{
TargetDesired: apicontainerstatus.ContainerRunning,
DependencyKnown: apicontainerstatus.ContainerStopped,
Expand Down
4 changes: 2 additions & 2 deletions agent/engine/task_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func (mtask *managedTask) emitResourceChange(change resourceStateChange) {
func (mtask *managedTask) emitTaskEvent(task *apitask.Task, reason string) {
event, err := api.NewTaskStateChangeEvent(task, reason)
if err != nil {
seelog.Infof("Managed task [%s]: unable to create task state change event [%s]: %v",
seelog.Debugf("Managed task [%s]: skipping emitting event for task [%s]: %v",
task.Arn, reason, err)
return
}
Expand All @@ -518,7 +518,7 @@ func (mtask *managedTask) emitTaskEvent(task *apitask.Task, reason string) {
func (mtask *managedTask) emitContainerEvent(task *apitask.Task, cont *apicontainer.Container, reason string) {
event, err := api.NewContainerStateChangeEvent(task, cont, reason)
if err != nil {
seelog.Infof("Managed task [%s]: unable to create state change event for container [%s]: %v",
seelog.Debugf("Managed task [%s]: skipping emitting event for container [%s]: %v",
task.Arn, cont.Name, err)
return
}
Expand Down
4 changes: 2 additions & 2 deletions agent/stats/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,12 @@ func (engine *DockerStatsEngine) taskContainerMetricsUnsafe(taskArn string) ([]*
// CPU and Memory are both critical, so skip the container if either of these fail.
cpuStatsSet, err := container.statsQueue.GetCPUStatsSet()
if err != nil {
seelog.Warnf("Error getting cpu stats, skipping container, err: %v, container: %v", err, dockerID)
seelog.Infof("cloudwatch metrics for container %v not collected, reason (cpu): %v", dockerID, err)
continue
}
memoryStatsSet, err := container.statsQueue.GetMemoryStatsSet()
if err != nil {
seelog.Warnf("Error getting memory stats, skipping container, err: %v, container: %v", err, dockerID)
seelog.Infof("cloudwatch metrics for container %v not collected, reason (memory): %v", dockerID, err)
continue
}
containerMetric := &ecstcs.ContainerMetric{
Expand Down
2 changes: 1 addition & 1 deletion agent/tcs/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func StartSession(params *TelemetrySessionParams, statsEngine stats.Engine) erro
seelog.Info("TCS Websocket connection closed for a valid reason")
backoff.Reset()
} else {
seelog.Infof("Error from tcs; backing off: %v", tcsError)
seelog.Errorf("Error: lost websocket connection with ECS Telemetry service (TCS): %v", tcsError)
params.time().Sleep(backoff.Duration())
}
}
Expand Down
4 changes: 2 additions & 2 deletions agent/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ package version
// repository. Only the 'Version' const should change in checked-in source code

// Version is the version of the Agent
const Version = "1.37.0"
const Version = "1.38.0"

// GitDirty indicates the cleanliness of the git repo when this agent was built
const GitDirty = true

// GitShortHash is the short hash of this agent build
const GitShortHash = "UNKNOWN"
const GitShortHash = "3513dff5"
2 changes: 1 addition & 1 deletion agent/wsclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (cs *ClientServerImpl) ConsumeMessages() error {

default:
// Unexpected error occurred
seelog.Errorf("Error getting message from ws backend: error: [%v], messageType: [%v] ",
seelog.Debugf("Error getting message from ws backend: error: [%v], messageType: [%v] ",
err, messageType)
return err
}
Expand Down