-
Notifications
You must be signed in to change notification settings - Fork 619
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
Fix CPUPercent for windows and add functional test #1089
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good, some minor comments.
agent/api/task_windows.go
Outdated
@@ -62,7 +62,12 @@ func getCanonicalPath(path string) string { | |||
// passed to Docker API. | |||
func (task *Task) platformHostConfigOverride(hostConfig *docker.HostConfig) error { | |||
task.overrideDefaultMemorySwappiness(hostConfig) | |||
hostConfig.CPUPercent = hostConfig.CPUShares / int64(cpuShareScaleFactor) | |||
// Convert the CPUShares to CPUPercent | |||
hostConfig.CPUPercent = hostConfig.CPUShares * 100 / int64(cpuShareScaleFactor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the 100 here? Please make a named constant expressing what this is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CPUPercent
is the integer of percentage, this is the conversion: 25% -> 25
agent/functional_tests/util/utils.go
Outdated
@@ -266,36 +266,36 @@ func DeleteCluster(t *testing.T, clusterName string) { | |||
|
|||
// VerifyMetrics whether the response is as expected | |||
// the expected value can be 0 or positive | |||
func VerifyMetrics(cwclient *cloudwatch.CloudWatch, params *cloudwatch.GetMetricStatisticsInput, idleCluster bool) error { | |||
func VerifyMetrics(cwclient *cloudwatch.CloudWatch, params *cloudwatch.GetMetricStatisticsInput, idleCluster bool) (error, *cloudwatch.Datapoint) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reorder the return to be (*cloudwatch.Datapoint, error)
.
|
||
tdOverrides := make(map[string]string) | ||
// Set the container cpu percentage 25% | ||
tdOverrides["$$$$CPUSHARE$$$$"] = strconv.Itoa(cpuNum * 1024 / 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you * 0.25
instead of / 4
so that it's clearer with respect to your comment?
Can you add a constant for 1024? cpuSharesPerCore
would be reasonable.
assert.NoError(t, err, "Task is running, verify metrics for CPU utilization failed") | ||
// Also verify the cpu usage is around 25% | ||
assert.True(t, *metrics.Average < 0.3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can use assert.InDelta
.
assert.InDelta(t, 0.25, *metrics.Average, 0.05)
@@ -0,0 +1,24 @@ | |||
package main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs the license header.
WORKDIR /gopath | ||
COPY main.go . | ||
|
||
CMD ["go", "run", "main.go", "-concurrency", "1000"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why compile it at runtime?
RUN go build main.go -o cpuhog
ENTRYPOINT ["./cpuhog"]
CMD ["-concurrency", "1000"]
6df5ef3
to
b62f1b0
Compare
Summary
Implementation details
Testing
make release
)go build -out amazon-ecs-agent.exe ./agent
)make test
) passgo test -timeout=25s ./agent/...
) passmake run-integ-tests
) pass.\scripts\run-integ-tests.ps1
) passmake run-functional-tests
) pass.\scripts\run-functional-tests.ps1
) passNew tests cover the changes:
yes
Description for the changelog
Licensing
This contribution is under the terms of the Apache 2.0 License: