@@ -33,6 +33,7 @@ import (
33
33
"github.com/aws/amazon-ecs-agent/agent/config"
34
34
"github.com/aws/amazon-ecs-agent/agent/dockerclient"
35
35
"github.com/aws/amazon-ecs-agent/agent/dockerclient/dockerapi"
36
+ "github.com/aws/amazon-ecs-agent/agent/ecs_client/model/ecs"
36
37
"github.com/aws/amazon-ecs-agent/agent/taskresource"
37
38
"github.com/aws/amazon-ecs-agent/agent/taskresource/asmauth"
38
39
"github.com/aws/amazon-ecs-agent/agent/taskresource/asmsecret"
@@ -48,7 +49,6 @@ import (
48
49
apieni "github.com/aws/amazon-ecs-agent/ecs-agent/api/eni"
49
50
apierrors "github.com/aws/amazon-ecs-agent/ecs-agent/api/errors"
50
51
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials"
51
- "github.com/aws/amazon-ecs-agent/ecs-agent/ecs_client/model/ecs"
52
52
"github.com/aws/amazon-ecs-agent/ecs-agent/logger"
53
53
"github.com/aws/amazon-ecs-agent/ecs-agent/logger/field"
54
54
"github.com/aws/amazon-ecs-agent/ecs-agent/utils/arn"
@@ -235,6 +235,9 @@ type Task struct {
235
235
// is handled properly so that the state storage continues to work.
236
236
SentStatusUnsafe apitaskstatus.TaskStatus `json:"SentStatus"`
237
237
238
+ StartSequenceNumber int64
239
+ StopSequenceNumber int64
240
+
238
241
// ExecutionCredentialsID is the ID of credentials that are used by agent to
239
242
// perform some action at the task level, such as pulling image from ECR
240
243
ExecutionCredentialsID string `json:"executionCredentialsID"`
@@ -310,6 +313,11 @@ func TaskFromACS(acsTask *ecsacs.Task, envelope *ecsacs.PayloadMessage) (*Task,
310
313
if err := json .Unmarshal (data , task ); err != nil {
311
314
return nil , err
312
315
}
316
+ if task .GetDesiredStatus () == apitaskstatus .TaskRunning && envelope .SeqNum != nil {
317
+ task .StartSequenceNumber = * envelope .SeqNum
318
+ } else if task .GetDesiredStatus () == apitaskstatus .TaskStopped && envelope .SeqNum != nil {
319
+ task .StopSequenceNumber = * envelope .SeqNum
320
+ }
313
321
314
322
// Overrides the container command if it's set
315
323
for _ , container := range task .Containers {
@@ -2818,6 +2826,22 @@ func (task *Task) GetAppMesh() *apiappmesh.AppMesh {
2818
2826
return task .AppMesh
2819
2827
}
2820
2828
2829
+ // GetStopSequenceNumber returns the stop sequence number of a task
2830
+ func (task * Task ) GetStopSequenceNumber () int64 {
2831
+ task .lock .RLock ()
2832
+ defer task .lock .RUnlock ()
2833
+
2834
+ return task .StopSequenceNumber
2835
+ }
2836
+
2837
+ // SetStopSequenceNumber sets the stop seqence number of a task
2838
+ func (task * Task ) SetStopSequenceNumber (seqnum int64 ) {
2839
+ task .lock .Lock ()
2840
+ defer task .lock .Unlock ()
2841
+
2842
+ task .StopSequenceNumber = seqnum
2843
+ }
2844
+
2821
2845
// SetPullStartedAt sets the task pullstartedat timestamp and returns whether
2822
2846
// this field was updated or not
2823
2847
func (task * Task ) SetPullStartedAt (timestamp time.Time ) bool {
@@ -3521,6 +3545,10 @@ func (task *Task) IsServiceConnectConnectionDraining() bool {
3521
3545
//
3522
3546
// * GPU
3523
3547
// - Return num of gpus requested (len of GPUIDs field)
3548
+ //
3549
+ // TODO remove this once ToHostResources is used
3550
+ //
3551
+ //lint:file-ignore U1000 Ignore all unused code
3524
3552
func (task * Task ) ToHostResources () map [string ]* ecs.Resource {
3525
3553
resources := make (map [string ]* ecs.Resource )
3526
3554
// CPU
@@ -3634,13 +3662,3 @@ func (task *Task) ToHostResources() map[string]*ecs.Resource {
3634
3662
})
3635
3663
return resources
3636
3664
}
3637
-
3638
- func (task * Task ) HasActiveContainers () bool {
3639
- for _ , container := range task .Containers {
3640
- containerStatus := container .GetKnownStatus ()
3641
- if containerStatus >= apicontainerstatus .ContainerPulled && containerStatus <= apicontainerstatus .ContainerResourcesProvisioned {
3642
- return true
3643
- }
3644
- }
3645
- return false
3646
- }
0 commit comments