-
Notifications
You must be signed in to change notification settings - Fork 617
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
Improve the error message when reserved memory is larger than the available memory #897
Conversation
agent/api/ecsclient/client.go
Outdated
mem = mem - int64(client.config.ReservedMemory) | ||
registeredMem := mem - int64(client.config.ReservedMemory) | ||
if registeredMem < 0 { | ||
return "", fmt.Errorf("Resource memory is less than reserved, total memory: %d, reserved: %d", mem, client.config.ReservedMemory) |
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 modify the error string to be of the "context: message"
format?
"api register-container-instance: reserved memory higher than available memory on the host ..."
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'm sorry for nitpicking but the commit message also has typos.
agent/api/ecsclient/client.go
Outdated
registeredMem := mem - int64(client.config.ReservedMemory) | ||
if registeredMem < 0 { | ||
return "", fmt.Errorf( | ||
"api register-container-instance: reserved memory is higher than available memory on the hos, total memory: %d, reserved: %d", |
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.
nit: hos --> host
c0c62ea
to
c9b51ac
Compare
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.
Nice!
agent/api/ecsclient/client.go
Outdated
@@ -172,7 +173,12 @@ func (client *APIECSClient) registerContainerInstance(clusterRef string, contain | |||
integerStr := "INTEGER" | |||
|
|||
cpu, mem := getCpuAndMemory() | |||
mem = mem - int64(client.config.ReservedMemory) | |||
registeredMem := mem - int64(client.config.ReservedMemory) |
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.
Would 'remainingMem' be more appropriate?
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.
lgtm; i'd vote for modifying this as per petderek@'s comment before merging.
… reserved memory value is greater than available memory on the instance
Summary
Fix #888
Implementation details
Check the value of memory trying to registered before calling ecs RegisterContainerInstance. And if the value is negative then just emit an error and exit the agent.
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:
yes