def execute(self, context): job = context.options.instance_spec.jobkey instances = (None if context.options.instance_spec.instance == ALL_INSTANCES else context.options.instance_spec.instance) config = context.get_job_config(job, context.options.config_file) if config.raw().has_cron_schedule(): raise context.CommandError( EXIT_COMMAND_FAILURE, "Cron jobs may only be updated with \"aurora cron schedule\" command") api = context.get_api(config.cluster()) try: resp = api.start_job_update(config, context.options.message, instances) except AuroraClientAPI.UpdateConfigError as e: raise context.CommandError(EXIT_INVALID_CONFIGURATION, e.message) context.log_response_and_raise(resp, err_code=EXIT_API_ERROR, err_msg="Failed to start update due to error:") if resp.result: update_key = resp.result.startJobUpdateResult.key url = get_update_page( api, AuroraJobKey.from_thrift(config.cluster(), update_key.job), resp.result.startJobUpdateResult.key.id) context.print_out(self.UPDATE_MSG_TEMPLATE % url) if context.options.wait: return wait_for_update(context, self._clock, api, update_key) else: context.print_out(combine_messages(resp)) return EXIT_OK
def execute(self, context): # release_package = get_latest_release() # if release_package is not terminal: # resume_release(release_package) # # old_config = get_old_config(...) # most recent terminal # new_config, uuid = start_release(new_config) # release_package = set_release_live(new_config, uuid) # resume_release(release_package) api = context.get_api(context.options.jobspec.cluster) terminal, nonterminal = self._previous_release_pair(context) # determine if we have an in-flight release and resume if necessary if nonterminal: return self._resume_release(api, context, terminal, nonterminal) # if not, start a new release config_package, uuid = self._start_release(api, context) if uuid is None: context.print_out('Update would be a no-op.') return EXIT_OK # launch update browser update_page = get_update_page(api, context.options.jobspec, uuid) context.print_out('Update: %s' % update_page) webbrowser.open_new_tab(update_page) # record the active release in the ledger nonterminal = self._set_release_live(context, config_package, uuid) # wait until terminal return self._resume_release(api, context, terminal, nonterminal)
def execute(self, context): job = context.options.instance_spec.jobkey instances = (None if context.options.instance_spec.instance == ALL_INSTANCES else context.options.instance_spec.instance) update_id = str(uuid.uuid4()) config = context.get_job_config(job, context.options.config_file) if config.raw().has_cron_schedule(): raise context.CommandError( EXIT_COMMAND_FAILURE, "Cron jobs may only be updated with \"aurora cron schedule\" command" ) api = context.get_api(config.cluster()) formatter = DiffFormatter(context, config) formatter.show_job_update_diff(instances) try: resp = api.start_job_update(config, context.options.message, instances, {CLIENT_UPDATE_ID: update_id}) except AuroraClientAPI.UpdateConfigError as e: raise context.CommandError(EXIT_INVALID_CONFIGURATION, e.message) if not self._is_update_already_in_progress(resp, update_id): context.log_response_and_raise( resp, err_code=EXIT_API_ERROR, err_msg=self.FAILED_TO_START_UPDATE_ERROR_MSG) if resp.result: update_key = resp.result.startJobUpdateResult.key url = get_update_page( api, AuroraJobKey.from_thrift(config.cluster(), update_key.job), resp.result.startJobUpdateResult.key.id) context.print_out(self.UPDATE_MSG_TEMPLATE % url) if context.options.open_browser: webbrowser.open_new_tab(url) if context.options.wait: return wait_for_update(context, self._clock, api, update_key, update_state_to_err_code) else: context.print_out(combine_messages(resp)) return EXIT_OK
def execute(self, context): job = context.options.instance_spec.jobkey instances = (None if context.options.instance_spec.instance == ALL_INSTANCES else context.options.instance_spec.instance) update_id = str(uuid.uuid4()) config = context.get_job_config(job, context.options.config_file) if config.raw().has_cron_schedule(): raise context.CommandError( EXIT_COMMAND_FAILURE, "Cron jobs may only be updated with \"aurora cron schedule\" command") api = context.get_api(config.cluster()) formatter = DiffFormatter(context, config) formatter.show_job_update_diff(instances) try: resp = api.start_job_update(config, context.options.message, instances, {CLIENT_UPDATE_ID: update_id}) except AuroraClientAPI.UpdateConfigError as e: raise context.CommandError(EXIT_INVALID_CONFIGURATION, e.message) if not self._is_update_already_in_progress(resp, update_id): context.log_response_and_raise(resp, err_code=EXIT_API_ERROR, err_msg=self.FAILED_TO_START_UPDATE_ERROR_MSG) if resp.result: update_key = resp.result.startJobUpdateResult.key url = get_update_page( api, AuroraJobKey.from_thrift(config.cluster(), update_key.job), resp.result.startJobUpdateResult.key.id) context.print_out(self.UPDATE_MSG_TEMPLATE % url) if context.options.open_browser: webbrowser.open_new_tab(url) if context.options.wait: return wait_for_update(context, self._clock, api, update_key, update_state_to_err_code) else: context.print_out(combine_messages(resp)) return EXIT_OK