File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,10 @@ type ErrorResponse struct {
94
94
ResourceARN string `json:"ResourceARN,omitempty"`
95
95
}
96
96
97
+ // Agent versions >= 1.2.0: Null, zero, and CPU values of 1
98
+ // are passed to Docker as two CPU shares
99
+ const minimumCPUUnit = 2
100
+
97
101
// NewTaskResponse creates a new response object for the task
98
102
func NewTaskResponse (
99
103
taskARN string ,
@@ -234,6 +238,12 @@ func NewContainerResponse(
234
238
ExitCode : container .GetKnownExitCode (),
235
239
Labels : container .GetLabels (),
236
240
}
241
+
242
+ if container .CPU < minimumCPUUnit {
243
+ defaultCPU := func (val float64 ) * float64 { return & val }(minimumCPUUnit )
244
+ resp .Limits .CPU = defaultCPU
245
+ }
246
+
237
247
// V4 metadata endpoint calls this function for consistency across versions,
238
248
// but needs additional metadata only available at this scope.
239
249
if includeV4Metadata {
Original file line number Diff line number Diff line change @@ -351,7 +351,7 @@ func TestTaskResponseMarshal(t *testing.T) {
351
351
"DesiredStatus" : "NONE" ,
352
352
"KnownStatus" : "NONE" ,
353
353
"Limits" : map [string ]interface {}{
354
- "CPU" : float64 (0 ),
354
+ "CPU" : float64 (2 ),
355
355
"Memory" : float64 (0 ),
356
356
},
357
357
"Type" : "NORMAL" ,
You can’t perform that action at this time.
0 commit comments