Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aws/amazon-ecs-agent
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: db4f9502ad3af09fd8dd25f21fb7c3e8ddef44f6
Choose a base ref
..
head repository: aws/amazon-ecs-agent
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1db71f57d560576e557a64fedfc630158c973e5e
Choose a head ref
16 changes: 16 additions & 0 deletions agent/engine/image/types.go
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
package image

import (
"encoding/json"
"fmt"
"sync"
"time"
@@ -98,3 +99,18 @@ func (imageState *ImageState) RemoveContainerReference(container *api.Container)
}
return fmt.Errorf("Container reference is not found in the image state container: %s", container.String())
}

func (imageState *ImageState) MarshalJSON() ([]byte, error) {
imageState.updateLock.Lock()
defer imageState.updateLock.Unlock()

return json.Marshal(&struct {
Image *Image
PulledAt time.Time
LastUsedAt time.Time
}{
Image: imageState.Image,
PulledAt: imageState.PulledAt,
LastUsedAt: imageState.LastUsedAt,
})
}
Original file line number Diff line number Diff line change
@@ -6,69 +6,69 @@
"memory": 10,
"cpu": 0,
"entryPoint": ["powershell"],
"command": ["sleep", "20"]
"command": ["sleep", "300"]
}, {
"name": "2",
"image": "microsoft/windowsservercore:latest",
"memory": 10,
"cpu": 0,
"entryPoint": ["powershell"],
"command": ["sleep", "20"]
"command": ["sleep", "300"]
}, {
"name": "3",
"image": "microsoft/windowsservercore:latest",
"memory": 10,
"cpu": 0,
"entryPoint": ["powershell"],
"command": ["sleep", "20"]
"command": ["sleep", "300"]
}, {
"name": "4",
"image": "microsoft/windowsservercore:latest",
"memory": 10,
"cpu": 0,
"entryPoint": ["powershell"],
"command": ["sleep", "20"]
"command": ["sleep", "300"]
}, {
"name": "5",
"image": "microsoft/windowsservercore:latest",
"memory": 10,
"cpu": 0,
"entryPoint": ["powershell"],
"command": ["sleep", "20"]
"command": ["sleep", "300"]
}, {
"name": "6",
"image": "microsoft/windowsservercore:latest",
"memory": 10,
"cpu": 0,
"entryPoint": ["powershell"],
"command": ["sleep", "20"]
"command": ["sleep", "300"]
}, {
"name": "7",
"image": "microsoft/windowsservercore:latest",
"memory": 10,
"cpu": 0,
"entryPoint": ["powershell"],
"command": ["sleep", "20"]
"command": ["sleep", "300"]
}, {
"name": "8",
"image": "microsoft/windowsservercore:latest",
"memory": 10,
"cpu": 0,
"entryPoint": ["powershell"],
"command": ["sleep", "20"]
"command": ["sleep", "300"]
}, {
"name": "9",
"image": "microsoft/windowsservercore:latest",
"memory": 10,
"cpu": 0,
"entryPoint": ["powershell"],
"command": ["sleep", "20"]
"command": ["sleep", "300"]
}, {
"name": "10",
"image": "microsoft/windowsservercore:latest",
"memory": 10,
"cpu": 0,
"entryPoint": ["powershell"],
"command": ["sleep", "20"]
"command": ["sleep", "300"]
}]
}
12 changes: 9 additions & 3 deletions agent/functional_tests/tests/functionaltests_windows_test.go
Original file line number Diff line number Diff line change
@@ -62,9 +62,10 @@ func TestTaskCleanupDoesNotDeadlock(t *testing.T) {
t.Fatalf("Cycle %d: There was an error starting the Task: %v", i, err)
}

// Added 1 minute delay to allow the task to be in running state - Required only on Windows
testTask.WaitRunning(1 * time.Minute)
// Wait for the task to be running
testTask.WaitRunning(2 * time.Minute)

// Make sure the task is running on the instance
isTaskRunning, err := agent.WaitRunningViaIntrospection(testTask)
if err != nil || !isTaskRunning {
t.Fatalf("Cycle %d: Task should be RUNNING but is not: %v", i, err)
@@ -76,7 +77,12 @@ func TestTaskCleanupDoesNotDeadlock(t *testing.T) {
t.Fatalf("Cycle %d: Error resolving docker id for container in task: %v", i, err)
}

// 2 minutes should be enough for the Task to have completed. If the task has not
err = testTask.Stop()
if err != nil {
t.Fatalf("Cycle %d: Failed to stop task: %v", i, err)
}

// 2 minutes should be enough for the Task to be stopped. If the task has not
// completed and is in PENDING, the agent is most likely deadlocked.
err = testTask.WaitStopped(2 * time.Minute)
if err != nil {