Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(composer): fix composer router generation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Aug 6, 2019
1 parent 23a83a4 commit e35e3b3
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions gnes/composer/base.py
Expand Up @@ -191,17 +191,17 @@ def build_dockerswarm(all_layers: List['YamlComposer.Layer'], docker_img: str =
args.append('--yaml_path /%s_yaml' % c_name)
config_dict['%s_yaml' % c_name] = {'file': c['yaml_path']}

# if l_idx + 1 < len(all_layers):
# next_layer = all_layers[l_idx + 1]
# _l_idx = l_idx + 1
# else:
# next_layer = all_layers[0]
# _l_idx = 0
# host_out_name = ''
# for _c_idx, _c in enumerate(next_layer.components):
# if _c['port_in'] == c['port_out']:
# host_out_name = '%s%d%d' % (_c['name'], _l_idx, _c_idx)
# break
if l_idx + 1 < len(all_layers):
next_layer = all_layers[l_idx + 1]
_l_idx = l_idx + 1
else:
next_layer = all_layers[0]
_l_idx = 0
host_out_name = ''
for _c_idx, _c in enumerate(next_layer.components):
if _c['port_in'] == c['port_out']:
host_out_name = '%s%d%d' % (_c['name'], _l_idx, _c_idx)
break

if l_idx - 1 >= 0:
last_layer = all_layers[l_idx - 1]
Expand All @@ -216,8 +216,10 @@ def build_dockerswarm(all_layers: List['YamlComposer.Layer'], docker_img: str =
host_in_name = '%s%d%d' % (_c['name'], _l_idx, _c_idx)
break

args += ['--host_in %s' % host_in_name]
# '--host_out %s' % host_out_name]
if 'BIND' not in c['socket_out']:
args.append('--host_out %s' % host_out_name)
if 'BIND' not in c['socket_in']:
args.append('--host_in %s' % host_in_name)

cmd = '%s %s' % (YamlComposer.comp2file[c['name']], ' '.join(args))
swarm_lines['services'][c_name] = CommentedMap({
Expand Down

0 comments on commit e35e3b3

Please sign in to comment.