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

Engine seelog #1208

Merged
merged 4 commits into from
Jan 23, 2018
Merged

Engine seelog #1208

merged 4 commits into from
Jan 23, 2018

Conversation

aaithal
Copy link
Contributor

@aaithal aaithal commented Jan 23, 2018

Summary

Removed module logger and switched to seelog in engine package

Implementation details

Testing

  • Builds on Linux (make release)
  • Builds on Windows (go build -out amazon-ecs-agent.exe ./agent)
  • Unit tests on Linux (make test) pass
  • Unit tests on Windows (go test -timeout=25s ./agent/...) pass
  • Integration tests on Linux (make run-integ-tests) pass
  • Integration tests on Windows (.\scripts\run-integ-tests.ps1) pass
  • Functional tests on Linux (make run-functional-tests) pass
  • Functional tests on Windows (.\scripts\run-functional-tests.ps1) pass

New tests cover the changes: yes

Description for the changelog

None

Licensing

This contribution is under the terms of the Apache 2.0 License: Yes

Copy link

@richardpen richardpen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like all the changes are related to naming, I'm assuming all the tests will pass.

Copy link
Contributor

@adnxn adnxn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm, mostly nits about formatting, naming.

@@ -658,7 +665,7 @@ func (dg *dockerGoClient) stopContainer(ctx context.Context, dockerID string) Do
err = client.StopContainerWithContext(dockerID, uint(dg.config.DockerStopTimeout/time.Second), ctx)
metadata := dg.containerMetadata(dockerID)
if err != nil {
log.Debug("Error stopping container", "err", err, "id", dockerID)
seelog.Infof("Error stopping container %s: %v", dockerID, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DockerGoClient: tag for this line

@@ -221,7 +221,7 @@ func (engine *DockerTaskEngine) MustInit(ctx context.Context) {
err := engine.Init(ctx)
if err != nil {
errorOnce.Do(func() {
log.Error("Could not connect to docker daemon", "err", err)
seelog.Errorf("Task engine: could not connect to docker daemon: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we tag these as DockerTaskEngine to keep parity with naming style as we have for DockerGoClient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TL;DR I don't think so. Let me know what you think.

I used DockerGoClient as I couldn't think of a better name for this. "Task engine" distinguishes this from things like "Stats engine". I don't know if we need very strict rules about this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay that's fine with me. I don't feel strongly either way. I'm guessing we'll have a better idea after a couple of weeks of log diving and debugging with these new changes 😛

@@ -863,11 +906,13 @@ func (engine *DockerTaskEngine) buildCNIConfigFromTaskContainer(task *api.Task,
}

func (engine *DockerTaskEngine) stopContainer(task *api.Task, container *api.Container) DockerContainerMetadata {
seelog.Infof("Stopping container, container: %s, task: %s", container.String(), task.String())
seelog.Infof("Task engine[ %s]: stopping container [%s]", task.Arn, container.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing: Task engine[ %s]

@@ -882,16 +927,17 @@ func (engine *DockerTaskEngine) stopContainer(task *api.Task, container *api.Con
if container.Type == api.ContainerCNIPause {
err := engine.cleanupPauseContainerNetwork(task, container)
if err != nil {
seelog.Errorf("Engine: cleanup pause container network namespace error, task: %s", task.String())
seelog.Errorf("Task engine[%s]: unable to cleanup pause container network namespace: %v",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing: Task engine[%s]

}
seelog.Infof("Cleaned pause container network namespace, task: %s", task.String())
seelog.Infof("Task engine[%s]: cleaned pause container network namespace", task.Arn)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing: Task engine[%s]

@@ -165,17 +168,19 @@ func (mtask *managedTask) overseeTask() {
if !mtask.GetKnownStatus().Terminal() {
// If we aren't terminal and we aren't steady state, we should be
// able to move some containers along.
llog.Debug("Task not steady state or terminal; progressing it")
seelog.Debugf("Managed task [%s]: task not steady state or terminal; progressing it",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: again to keep parity, should we make the tags ManagedTask?

@@ -358,16 +366,17 @@ func (mtask *managedTask) handleContainerChange(containerChange dockerContainerC
now := mtask.time().Now()
ok := mtask.Task.SetExecutionStoppedAt(now)
if ok {
seelog.Infof("Recording execution stopped time for a task, essential container in task stopped, task %s, time: %s",
mtask.Task.String(), now.String())
seelog.Infof("Managed task [%s]: recording execution stopped time. Essential container %s stopped at: %s",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: container [%s], I think there are few of these where formatting varies from line to line. Not sure if this was intentional.

Copy link
Contributor

@adnxn adnxn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops meant to approve since mostly nits. thanks for going through this and making these changes. =]

Copy link
Contributor

@sharanyad sharanyad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for tags in logs

DependentContainerNotResolvedErr = errors.New("dependency graph: dependent container not in expected state")
// ContainerPastDesiredStatusErr is the error where the container status is bigger than desired status
ContainerPastDesiredStatusErr = errors.New("container transition: container status is equal or greater than desired status")
volumeUnresolvedErr = errors.New("dependency graph: container volume dependency not resolved")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing comments

@@ -336,7 +339,7 @@ func (engine *DockerTaskEngine) synchronizeContainerStatus(container *api.Docker
func (engine *DockerTaskEngine) CheckTaskState(task *api.Task) {
taskContainers, ok := engine.state.ContainerMapByArn(task.Arn)
if !ok {
seelog.Warnf("Could not check task state for task; no task in state: %s", task.Arn)
seelog.Warnf("Task engine [%s]: could not check task state for task; no task in state", task.Arn)
Copy link
Contributor

@sharanyad sharanyad Jan 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewording suggestion: could not check task state; no task in state

return
}

seelog.Infof("Managed task: sending container change event: %s", event.String())
seelog.Infof("Managed task [%s]: sending container change event [%s]: %s",
mtask.Arn, container.Name, event.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this should be cont.Name

Move to seelog and a uniform logging structure in the task manager code
Switch logger to seelog for container and task engine files.
Added a mock for StopContainer in TestBatchContainerHappyPath. On slower
machines, if the cleanup takes long, the task engine could invoke
StopContainer and this would cause the unit test to fail.

Example:
https://travis-ci.org/aws/amazon-ecs-agent/builds/332087012?utm_source=github_status&utm_medium=notification
Renamed docker_container_engine.go to docker_client.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants