From 52e85d53885c1c5632682768f717a0c480e104e7 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Thu, 25 Apr 2024 13:52:40 -0700 Subject: [PATCH] ContainerRestartPolicy ACS and TCS models, TMDS updates (#4158) * ACS model update * go mod vendor agent dir * Add RestartStatSet to tcs model * go mod vendor in agent dir * Update TMDS v4 response * go mod vendor in tmds v4 changes --- .../ecs-agent/acs/model/ecsacs/api.go | 30 +++++++++++++++++++ .../ecs-agent/tcs/model/ecstcs/api.go | 26 ++++++++++++++++ .../tmds/handlers/v4/state/response.go | 6 ++-- ecs-agent/acs/model/api/api-2.json | 15 +++++++++- ecs-agent/acs/model/ecsacs/api.go | 30 +++++++++++++++++++ ecs-agent/tcs/model/api/api-2.json | 9 +++++- ecs-agent/tcs/model/ecstcs/api.go | 26 ++++++++++++++++ ecs-agent/tmds/handlers/v4/state/response.go | 6 ++-- 8 files changed, 142 insertions(+), 6 deletions(-) diff --git a/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs/api.go b/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs/api.go index 7e9ab2950e..bd9a75b4e7 100644 --- a/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs/api.go +++ b/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/acs/model/ecsacs/api.go @@ -622,6 +622,8 @@ type Container struct { ContainerArn *string `locationName:"containerArn" type:"string"` + ContainerRestartPolicy *ContainerRestartPolicy `locationName:"containerRestartPolicy" type:"structure"` + Cpu *int64 `locationName:"cpu" type:"integer"` CredentialSpecs []*string `locationName:"credentialSpecs" type:"list"` @@ -743,6 +745,34 @@ func (s ContainerDependency) GoString() string { return s.String() } +type ContainerRestartPolicy struct { + _ struct{} `type:"structure"` + + Enabled *bool `locationName:"enabled" type:"boolean"` + + IgnoredExitCodes []*int64 `locationName:"ignoredExitCodes" type:"list"` + + RestartAttemptPeriod *int64 `locationName:"restartAttemptPeriod" type:"integer"` +} + +// String returns the string representation. +// +// API parameter values that are decorated as "sensitive" in the API will not +// be included in the string output. The member name will be present, but the +// value will be replaced with "sensitive". +func (s ContainerRestartPolicy) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation. +// +// API parameter values that are decorated as "sensitive" in the API will not +// be included in the string output. The member name will be present, but the +// value will be replaced with "sensitive". +func (s ContainerRestartPolicy) GoString() string { + return s.String() +} + type Device struct { _ struct{} `type:"structure"` diff --git a/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tcs/model/ecstcs/api.go b/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tcs/model/ecstcs/api.go index ab45a5b832..54caf6ec2c 100644 --- a/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tcs/model/ecstcs/api.go +++ b/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tcs/model/ecstcs/api.go @@ -230,6 +230,8 @@ type ContainerMetric struct { NetworkStatsSet *NetworkStatsSet `locationName:"networkStatsSet" type:"structure"` + RestartStatsSet *RestartStatsSet `locationName:"restartStatsSet" type:"structure"` + StorageStatsSet *StorageStatsSet `locationName:"storageStatsSet" type:"structure"` } @@ -1070,6 +1072,30 @@ func (s *ResourceValidationException) RequestID() string { return s.RespMetadata.RequestID } +type RestartStatsSet struct { + _ struct{} `type:"structure"` + + RestartCount *int64 `locationName:"restartCount" type:"integer"` +} + +// String returns the string representation. +// +// API parameter values that are decorated as "sensitive" in the API will not +// be included in the string output. The member name will be present, but the +// value will be replaced with "sensitive". +func (s RestartStatsSet) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation. +// +// API parameter values that are decorated as "sensitive" in the API will not +// be included in the string output. The member name will be present, but the +// value will be replaced with "sensitive". +func (s RestartStatsSet) GoString() string { + return s.String() +} + type ServerException struct { _ struct{} `type:"structure"` RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"` diff --git a/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v4/state/response.go b/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v4/state/response.go index 9a6d523d8b..e26c7bb9bd 100644 --- a/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v4/state/response.go +++ b/agent/vendor/github.com/aws/amazon-ecs-agent/ecs-agent/tmds/handlers/v4/state/response.go @@ -57,8 +57,10 @@ type EphemeralStorageMetrics struct { // with the v2 container response object. type ContainerResponse struct { *v2.ContainerResponse - Networks []Network `json:"Networks,omitempty"` - Snapshotter string `json:"Snapshotter,omitempty"` + Networks []Network `json:"Networks,omitempty"` + Snapshotter string `json:"Snapshotter,omitempty"` + RestartCount int `json:"RestartCount,omitempty"` + LastRestartAt time.Time `json:"LastRestartAt,omitempty"` } // Network is the v4 Network response. It adds a bunch of information about network diff --git a/ecs-agent/acs/model/api/api-2.json b/ecs-agent/acs/model/api/api-2.json index 7ed90991e7..6056c22455 100644 --- a/ecs-agent/acs/model/api/api-2.json +++ b/ecs-agent/acs/model/api/api-2.json @@ -311,9 +311,22 @@ "startTimeout":{"shape":"Integer"}, "stopTimeout":{"shape":"Integer"}, "firelensConfiguration":{"shape":"FirelensConfiguration"}, - "containerArn":{"shape":"String"} + "containerArn":{"shape":"String"}, + "containerRestartPolicy":{"shape":"ContainerRestartPolicy"} } }, + "ContainerRestartPolicy":{ + "type":"structure", + "members":{ + "enabled":{"shape":"Boolean"}, + "ignoredExitCodes":{"shape":"IntegerList"}, + "restartAttemptPeriod":{"shape":"Integer"} + } + }, + "IntegerList":{ + "type":"list", + "member":{"shape":"Integer"} + }, "ContainerCondition":{ "type":"string", "enum":[ diff --git a/ecs-agent/acs/model/ecsacs/api.go b/ecs-agent/acs/model/ecsacs/api.go index 7e9ab2950e..bd9a75b4e7 100644 --- a/ecs-agent/acs/model/ecsacs/api.go +++ b/ecs-agent/acs/model/ecsacs/api.go @@ -622,6 +622,8 @@ type Container struct { ContainerArn *string `locationName:"containerArn" type:"string"` + ContainerRestartPolicy *ContainerRestartPolicy `locationName:"containerRestartPolicy" type:"structure"` + Cpu *int64 `locationName:"cpu" type:"integer"` CredentialSpecs []*string `locationName:"credentialSpecs" type:"list"` @@ -743,6 +745,34 @@ func (s ContainerDependency) GoString() string { return s.String() } +type ContainerRestartPolicy struct { + _ struct{} `type:"structure"` + + Enabled *bool `locationName:"enabled" type:"boolean"` + + IgnoredExitCodes []*int64 `locationName:"ignoredExitCodes" type:"list"` + + RestartAttemptPeriod *int64 `locationName:"restartAttemptPeriod" type:"integer"` +} + +// String returns the string representation. +// +// API parameter values that are decorated as "sensitive" in the API will not +// be included in the string output. The member name will be present, but the +// value will be replaced with "sensitive". +func (s ContainerRestartPolicy) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation. +// +// API parameter values that are decorated as "sensitive" in the API will not +// be included in the string output. The member name will be present, but the +// value will be replaced with "sensitive". +func (s ContainerRestartPolicy) GoString() string { + return s.String() +} + type Device struct { _ struct{} `type:"structure"` diff --git a/ecs-agent/tcs/model/api/api-2.json b/ecs-agent/tcs/model/api/api-2.json index 7f472ef04d..0f3a812d28 100644 --- a/ecs-agent/tcs/model/api/api-2.json +++ b/ecs-agent/tcs/model/api/api-2.json @@ -135,7 +135,14 @@ "cpuStatsSet":{"shape":"CWStatsSet"}, "memoryStatsSet":{"shape":"CWStatsSet"}, "networkStatsSet":{"shape":"NetworkStatsSet"}, - "storageStatsSet":{"shape":"StorageStatsSet"} + "storageStatsSet":{"shape":"StorageStatsSet"}, + "restartStatsSet":{"shape":"RestartStatsSet"} + } + }, + "RestartStatsSet":{ + "type":"structure", + "members":{ + "restartCount":{"shape":"UInteger"} } }, "ContainerMetrics":{ diff --git a/ecs-agent/tcs/model/ecstcs/api.go b/ecs-agent/tcs/model/ecstcs/api.go index ab45a5b832..54caf6ec2c 100644 --- a/ecs-agent/tcs/model/ecstcs/api.go +++ b/ecs-agent/tcs/model/ecstcs/api.go @@ -230,6 +230,8 @@ type ContainerMetric struct { NetworkStatsSet *NetworkStatsSet `locationName:"networkStatsSet" type:"structure"` + RestartStatsSet *RestartStatsSet `locationName:"restartStatsSet" type:"structure"` + StorageStatsSet *StorageStatsSet `locationName:"storageStatsSet" type:"structure"` } @@ -1070,6 +1072,30 @@ func (s *ResourceValidationException) RequestID() string { return s.RespMetadata.RequestID } +type RestartStatsSet struct { + _ struct{} `type:"structure"` + + RestartCount *int64 `locationName:"restartCount" type:"integer"` +} + +// String returns the string representation. +// +// API parameter values that are decorated as "sensitive" in the API will not +// be included in the string output. The member name will be present, but the +// value will be replaced with "sensitive". +func (s RestartStatsSet) String() string { + return awsutil.Prettify(s) +} + +// GoString returns the string representation. +// +// API parameter values that are decorated as "sensitive" in the API will not +// be included in the string output. The member name will be present, but the +// value will be replaced with "sensitive". +func (s RestartStatsSet) GoString() string { + return s.String() +} + type ServerException struct { _ struct{} `type:"structure"` RespMetadata protocol.ResponseMetadata `json:"-" xml:"-"` diff --git a/ecs-agent/tmds/handlers/v4/state/response.go b/ecs-agent/tmds/handlers/v4/state/response.go index 9a6d523d8b..e26c7bb9bd 100644 --- a/ecs-agent/tmds/handlers/v4/state/response.go +++ b/ecs-agent/tmds/handlers/v4/state/response.go @@ -57,8 +57,10 @@ type EphemeralStorageMetrics struct { // with the v2 container response object. type ContainerResponse struct { *v2.ContainerResponse - Networks []Network `json:"Networks,omitempty"` - Snapshotter string `json:"Snapshotter,omitempty"` + Networks []Network `json:"Networks,omitempty"` + Snapshotter string `json:"Snapshotter,omitempty"` + RestartCount int `json:"RestartCount,omitempty"` + LastRestartAt time.Time `json:"LastRestartAt,omitempty"` } // Network is the v4 Network response. It adds a bunch of information about network