Skip to content

Commit 1744350

Browse files
Sivaram Mothikimboersma
authored andcommitted
feat(deisctl): add support for swarm scheduler components
fix(swarm): change swarm binary path in swarm.go ref(swarm): refactor code fix(test): add /deis/scheduler directory in controller functional test
1 parent 159c752 commit 1744350

3 files changed

Lines changed: 5 additions & 17 deletions

File tree

scheduler/swarm.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,27 @@ def create(self, name, image, command='', template=None, **kwargs):
3535
self.docker_cli.create_container(image=cimage, name=name,
3636
command=command.encode('utf-8'), mem_limit=mem,
3737
cpu_shares=cpu,
38-
environment=[affinity])
39-
self.docker_cli.stop(name)
38+
environment=[affinity],
39+
host_config={'PublishAllPorts': True})
4040

4141
def start(self, name):
4242
"""
4343
Start a container
4444
"""
45-
self.docker_cli.start(name, publish_all_ports=True)
46-
47-
return
45+
self.docker_cli.start(name)
4846

4947
def stop(self, name):
5048
"""
5149
Stop a container
5250
"""
5351
self.docker_cli.stop(name)
54-
return
5552

5653
def destroy(self, name):
5754
"""
5855
Destroy a container
5956
"""
6057
self.stop(name)
6158
self.docker_cli.remove_container(name)
62-
return
6359

6460
def run(self, name, image, entrypoint, command):
6561
"""
@@ -97,20 +93,13 @@ def _get_container_state(self, name):
9793

9894
def state(self, name):
9995
try:
100-
# NOTE (bacongobbler): this call to ._get_unit() acts as a pre-emptive check to
101-
# determine if the job no longer exists (will raise a RuntimeError on 404)
10296
for _ in range(30):
10397
return self._get_container_state(name)
10498
time.sleep(1)
105-
# FIXME (bacongobbler): when fleet loads a job, sometimes it'll automatically start and
106-
# stop the container, which in our case will return as 'failed', even though
107-
# the container is perfectly fine.
99+
# FIXME (smothiki): should be able to send JobState.crashed
108100
except KeyError:
109-
# failed retrieving a proper response from the fleet API
110101
return JobState.error
111102
except RuntimeError:
112-
# failed to retrieve a response from the fleet API,
113-
# which means it does not exist
114103
return JobState.destroyed
115104

116105
def attach(self, name):

templates/confd_settings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
# scheduler swarm manager host
1414
SWARM_HOST = '{{ if exists "/deis/scheduler/swarm/host" }}{{ getv "/deis/scheduler/swarm/host" }}{{ else }}127.0.0.1{{ end }}'
15-
#SWARM_HOST = '{{ or (.deis_scheduler_swarm_host) "127.0.0.1" }}'
16-
1715

1816
# base64-encoded SSH private key to facilitate current version of "deis run"
1917
SSH_PRIVATE_KEY = """{{ if exists "/deis/platform/sshPrivateKey" }}{{ getv "/deis/platform/sshPrivateKey" }}{{ else }}""{{end}}"""

tests/controller_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func TestController(t *testing.T) {
2424
"/deis/database",
2525
"/deis/registry",
2626
"/deis/domains",
27+
"/deis/scheduler",
2728
}
2829
tag, etcdPort := utils.BuildTag(), utils.RandomPort()
2930
imageName := utils.ImagePrefix() + "controller" + ":" + tag

0 commit comments

Comments
 (0)