-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Added scale method to the Service model. #1846
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
Conversation
Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
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.
Thanks! LGTM, though I'm wondering if we should check whether the service is in global
mode and raise an error if the user tries to rescale a global service. WDYT?
Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
747fd9d
to
0e0a852
Compare
@shin- You're right. I just submitted a validation for it. If you think that the exception message isn't good, please tell me. Thanks. |
I think it's a network problem. |
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.
Changes look good, just a small test issue.
spec = service.attrs['Spec']['TaskTemplate']['ContainerSpec'] | ||
assert spec.get('Command') == ['sleep', '300'] | ||
|
||
def test_scale_method_service(self): |
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 test is failing because the default mode
for a service is global
. Make sure to set the initial mode to replicated
!
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.
Thanks @shin-. I already changed.
df6274b
to
9855dcd
Compare
|
||
def test_scale_method_global_service(self): | ||
client = docker.from_env(version=TEST_API_VERSION) | ||
mode = ServiceMode('global') |
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.
It looks like the default value is replicated
.
docker/models/services.py
Outdated
``True``if successful. | ||
""" | ||
|
||
if not self.attrs['Spec']['Mode'].get('Global'): |
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.
The conditional is wrong.
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.
In fact, the conditional was very wrong. It returned an empty dictionary and did not raise the exception.
eeee297
to
41e67c9
Compare
Signed-off-by: Felipe Ruhland <felipe.ruhland@gmail.com>
41e67c9
to
663c608
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.
Obrigado!
Hi, I find this new method does not work consistently. I got varying results, 1st time I called it with 1 task already running, service.scale(2) it worked like 'service update -force' and updated the running task and started a 2nd one. But after that, service.scale(3) just didn't work at all, didn't start any new tasks or update existing ones. I find |
This should satisfy the request #1734