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

Expose PlatformFields field in order for it to be persisted in state #1480

Merged
merged 2 commits into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions agent/api/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ type Task struct {
// MemoryCPULimitsEnabled to determine if task supports CPU, memory limits
MemoryCPULimitsEnabled bool `json:"MemoryCPULimitsEnabled,omitempty"`

// platformFields consists of fields specific to linux/windows for a task
platformFields platformFields
// PlatformFields consists of fields specific to linux/windows for a task
PlatformFields PlatformFields `json:"PlatformFields,omitempty"`

// terminalReason should be used when we explicitly move a task to stopped.
// This ensures the task object carries some context for why it was explicitly
Expand Down
4 changes: 2 additions & 2 deletions agent/api/task/task_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ const (
bytesPerMegabyte = 1024 * 1024
)

// platformFields consists of fields specific to Linux for a task
type platformFields struct{}
// PlatformFields consists of fields specific to Linux for a task
type PlatformFields struct{}

func (task *Task) adjustForPlatform(cfg *config.Config) {
task.lock.Lock()
Expand Down
4 changes: 2 additions & 2 deletions agent/api/task/task_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const (
bytesPerMegabyte = 1024 * 1024
)

// platformFields consists of fields specific to Linux for a task
type platformFields struct{}
// PlatformFields consists of fields specific to Linux for a task
type PlatformFields struct{}

func (task *Task) adjustForPlatform(cfg *config.Config) {
task.lock.Lock()
Expand Down
16 changes: 8 additions & 8 deletions agent/api/task/task_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ const (
minimumCPUPercent = 1
)

// platformFields consists of fields specific to Windows for a task
type platformFields struct {
// cpuUnbounded determines whether a mix of unbounded and bounded CPU tasks
// PlatformFields consists of fields specific to Windows for a task
type PlatformFields struct {
// CpuUnbounded determines whether a mix of unbounded and bounded CPU tasks
// are allowed to run in the instance
cpuUnbounded bool
CpuUnbounded bool `json:"cpuUnbounded"`
}

var cpuShareScaleFactor = runtime.NumCPU() * cpuSharesPerCore

// adjustForPlatform makes Windows-specific changes to the task after unmarshal
func (task *Task) adjustForPlatform(cfg *config.Config) {
task.downcaseAllVolumePaths()
platformFields := platformFields{
cpuUnbounded: cfg.PlatformVariables.CPUUnbounded,
platformFields := PlatformFields{
CpuUnbounded: cfg.PlatformVariables.CPUUnbounded,
}
task.platformFields = platformFields
task.PlatformFields = platformFields
}

// downcaseAllVolumePaths forces all volume paths (host path and container path)
Expand Down Expand Up @@ -109,7 +109,7 @@ func (task *Task) overrideDefaultMemorySwappiness(hostConfig *docker.HostConfig)
// want. Instead, we convert 0 to 2 to be closer to expected behavior. The
// reason for 2 over 1 is that 1 is an invalid value (Linux's choice, not Docker's).
func (task *Task) dockerCPUShares(containerCPU uint) int64 {
if containerCPU <= 1 && !task.platformFields.cpuUnbounded {
if containerCPU <= 1 && !task.PlatformFields.CpuUnbounded {
seelog.Debugf(
"Converting CPU shares to allowed minimum of 2 for task arn: [%s] and cpu shares: %d",
task.Arn, containerCPU)
Expand Down
4 changes: 2 additions & 2 deletions agent/api/task/task_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ func TestCPUPercentBasedOnUnboundedEnabled(t *testing.T) {
CPU: uint(tc.cpu),
},
},
platformFields: platformFields{
cpuUnbounded: tc.cpuUnbounded,
PlatformFields: PlatformFields{
CpuUnbounded: tc.cpuUnbounded,
},
}

Expand Down
3 changes: 2 additions & 1 deletion agent/statemanager/state_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ const (
// b)Remove `AppliedStatus` field form 'apicontainer.Container'
// 12) Deprecate 'TransitionDependencySet' and add new 'TransitionDependenciesMap' in 'apicontainer.Container'
// 13) Add 'resources' field to 'api.task.task'
ECSDataVersion = 13
// 14) Add 'PlatformFields' field to 'api.task.task'
ECSDataVersion = 14

// ecsDataFile specifies the filename in the ECS_DATADIR
ecsDataFile = "ecs_agent_data.json"
Expand Down