Skip to content

Commit

Permalink
Ability to change sidekicks images when upgrading a service
Browse files Browse the repository at this point in the history
  • Loading branch information
kariae committed Mar 15, 2017
1 parent 2fb0c8b commit 5bf7f74
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rancher_gitlab_deploy/cli.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
help="Mark the upgrade as finished after it completes") help="Mark the upgrade as finished after it completes")
@click.option('--sidekicks/--no-sidekicks', default=False, @click.option('--sidekicks/--no-sidekicks', default=False,
help="Upgrade also service sidekicks") help="Upgrade also service sidekicks")
def main(rancher_url, rancher_key, rancher_secret, environment, stack, service, new_image, batch_size, batch_interval, start_before_stopping, upgrade_timeout, wait_for_upgrade_to_finish, finish_upgrade, sidekicks): @click.option('--new-sidekick-image', default=None, multiple=True,
help="If specified, replace the image (and :tag) with this one during the upgrade", type=(str, str))
def main(rancher_url, rancher_key, rancher_secret, environment, stack, service, new_image, batch_size, batch_interval, start_before_stopping, upgrade_timeout, wait_for_upgrade_to_finish, finish_upgrade, sidekicks, new_sidekick_image):
"""Performs an in service upgrade of the service specified on the command line""" """Performs an in service upgrade of the service specified on the command line"""
# split url to protocol and host # split url to protocol and host
if "://" not in rancher_url: if "://" not in rancher_url:
Expand Down Expand Up @@ -153,6 +155,7 @@ def main(rancher_url, rancher_key, rancher_secret, environment, stack, service,
}} }}
# copy over the existing config # copy over the existing config
upgrade['inServiceStrategy']['launchConfig'] = service['launchConfig'] upgrade['inServiceStrategy']['launchConfig'] = service['launchConfig']
upgrade['inServiceStrategy']['secondaryLaunchConfigs'] = service['secondaryLaunchConfigs']


if sidekicks: if sidekicks:
# copy over existing sidekicks config # copy over existing sidekicks config
Expand All @@ -162,6 +165,13 @@ def main(rancher_url, rancher_key, rancher_secret, environment, stack, service,
# place new image into config # place new image into config
upgrade['inServiceStrategy']['launchConfig']['imageUuid'] = 'docker:%s' % new_image upgrade['inServiceStrategy']['launchConfig']['imageUuid'] = 'docker:%s' % new_image


if new_sidekick_image:
new_sidekick_image = dict(new_sidekick_image)

for idx, secondaryLaunchConfigs in enumerate(service['secondaryLaunchConfigs']):
if secondaryLaunchConfigs['name'] in new_sidekick_image:
upgrade['inServiceStrategy']['secondaryLaunchConfigs'][idx]['imageUuid'] = 'docker:%s' % new_sidekick_image[secondaryLaunchConfigs['name']]

# 5 -> Start the upgrade # 5 -> Start the upgrade


try: try:
Expand Down

0 comments on commit 5bf7f74

Please sign in to comment.