def restart(args, options): """usage: restart cluster/role/env/job [--shards=SHARDS] [--batch_size=INT] [--updater_health_check_interval_seconds=SECONDS] [--max_per_shard_failures=INT] [--max_total_failures=INT] [--restart_threshold=INT] [--watch_secs=SECONDS] Performs a rolling restart of shards within a job. Restarts are fully controlled client-side, so aborting halts the restart. """ api, job_key, config_file = LiveJobDisambiguator.disambiguate_args_or_die( args, options, make_client_factory()) config = get_job_config(job_key.to_path(), config_file, options) if config_file else None updater_config = UpdaterConfig( options.batch_size, options.restart_threshold, options.watch_secs, options.max_per_shard_failures, options.max_total_failures) resp = api.restart(job_key, options.shards, updater_config, options.health_check_interval_seconds, config=config) check_and_log_response(resp) handle_open(api.scheduler.scheduler().url, job_key.role, job_key.env, job_key.name)
def start_cron(args, options): """usage: start_cron cluster/role/env/job Invokes a cron job immediately, out of its normal cron cycle. This does not affect the cron cycle in any way. """ api, job_key, config_file = LiveJobDisambiguator.disambiguate_args_or_die( args, options, make_client_factory()) config = get_job_config(job_key.to_path(), config_file, options) if config_file else None resp = api.start_cronjob(job_key, config=config) check_and_log_response(resp) handle_open(api.scheduler.scheduler().url, job_key.role, job_key.env, job_key.name)
def kill(args, options): """usage: kill cluster/role/env/job Kills a running job, blocking until all tasks have terminated. Default behaviour is to kill all shards in the job, but the kill can be limited to specific shards with the --shards option """ api, job_key, config_file = LiveJobDisambiguator.disambiguate_args_or_die( args, options, make_client_factory()) options = app.get_options() config = get_job_config(job_key.to_path(), config_file, options) if config_file else None resp = api.kill_job(job_key, options.shards, config=config) check_and_log_response(resp) handle_open(api.scheduler.scheduler().url, job_key.role, job_key.env, job_key.name)
def create(job_spec, config_file): """usage: create cluster/role/env/job config Creates a job based on a configuration file. """ options = app.get_options() try: config = get_job_config(job_spec, config_file, options) except ValueError as v: print("Error: %s" % v) sys.exit(1) api = make_client(config.cluster()) monitor = JobMonitor(api, config.role(), config.environment(), config.name()) resp = api.create_job(config) check_and_log_response(resp) handle_open(api.scheduler.scheduler().url, config.role(), config.environment(), config.name()) if options.wait_until == 'RUNNING': monitor.wait_until(monitor.running_or_finished) elif options.wait_until == 'FINISHED': monitor.wait_until(monitor.terminal)