Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cfg.add(config.Scope.applicationOverride, "mechanic", "build.type", args.build_type)
cfg.add(config.Scope.applicationOverride, "mechanic", "node.name", args.node_name)
cfg.add(config.Scope.applicationOverride, "mechanic", "master.nodes", opts.csv_to_list(args.master_nodes))
cfg.add(config.Scope.applicationOverride, "mechanic", "seed.hosts", opts.csv_to_list(args.seed_hosts))
if sub_command in ["start", "stop"]:
cfg.add(config.Scope.applicationOverride, "system", "install.id", args.installation_id)
logger.info("OS [%s]", str(platform.uname()))
logger.info("Python [%s]", str(sys.implementation))
logger.info("Rally version [%s]", version.version())
logger.debug("Command line arguments: %s", args)
# Configure networking
net.init()
if not args.offline:
if not net.has_internet_connection():
console.warn("No Internet connection detected. Automatic download of track data sets etc. is disabled.",
logger=logger)
cfg.add(config.Scope.applicationOverride, "system", "offline.mode", True)
else:
logger.info("Detected a working Internet connection.")
success = dispatch_sub_command(cfg, sub_command)
end = time.time()
if success:
console.println("")
console.info("SUCCESS (took %d seconds)" % (end - start), overline="-", underline="-")
else:
console.println("")
console.info("FAILURE (took %d seconds)" % (end - start), overline="-", underline="-")
sys.exit(64)
if timeout > 0:
shutdown_complete = True
logger.info("Shutdown completed.")
else:
logger.warning("Shutdown timed out. Actor system is still running.")
break
except KeyboardInterrupt:
times_interrupted += 1
logger.warning("User interrupted shutdown of internal actor system.")
console.info("Please wait a moment for Rally's internal components to shutdown.")
if not shutdown_complete and times_interrupted > 0:
logger.warning("Terminating after user has interrupted actor system shutdown explicitly for [%d] times.", times_interrupted)
console.println("")
console.warn("Terminating now at the risk of leaving child processes behind.")
console.println("")
console.warn("The next race may fail due to an unclean shutdown.")
console.println("")
console.println(SKULL)
console.println("")
elif not shutdown_complete:
console.warn("Could not terminate all internal processes within timeout. Please check and force-terminate all Rally processes.")
if timeout > 0:
shutdown_complete = True
logger.info("Shutdown completed.")
else:
logger.warning("Shutdown timed out. Actor system is still running.")
break
except KeyboardInterrupt:
times_interrupted += 1
logger.warning("User interrupted shutdown of internal actor system.")
console.info("Please wait a moment for Rally's internal components to shutdown.")
if not shutdown_complete and times_interrupted > 0:
logger.warning("Terminating after user has interrupted actor system shutdown explicitly for [%d] times." % times_interrupted)
console.println("")
console.warn("Terminating now at the risk of leaving child processes behind.")
console.println("")
console.warn("The next race may fail due to an unclean shutdown.")
console.println("")
console.println(SKULL)
console.println("")
elif not shutdown_complete:
console.warn("Could not terminate all internal processes within timeout. Please check and force-terminate all Rally processes.")
def on_benchmark_start(self):
# we only determine this value at the start of the benchmark. This is actually only useful for
# the pipeline "benchmark-only" where we don't have control over the cluster and the user might not have restarted
# the cluster so we can at least tell them.
if self.first_time:
for t in self.index_times(self.index_stats(), per_shard_stats=False):
n = t["name"]
v = t["value"]
if t["value"] > 0:
console.warn("%s is %d ms indicating that the cluster is not in a defined clean state. Recorded index time "
"metrics may be misleading." % (n, v), logger=self.logger)
self.first_time = False
logger = logging.getLogger(__name__)
already_running = actor.actor_system_already_running()
logger.info("Actor system already running locally? [%s]", str(already_running))
try:
actors = actor.bootstrap_actor_system(try_join=already_running, prefer_local_only=not already_running)
# We can only support remote benchmarks if we have a dedicated daemon that is not only bound to 127.0.0.1
cfg.add(config.Scope.application, "system", "remote.benchmarking.supported", already_running)
# This happens when the admin process could not be started, e.g. because it could not open a socket.
except thespian.actors.InvalidActorAddress:
logger.info("Falling back to offline actor system.")
actor.use_offline_actor_system()
actors = actor.bootstrap_actor_system(try_join=True)
except Exception as e:
logger.exception("Could not bootstrap actor system.")
if str(e) == "Unable to determine valid external socket address.":
console.warn("Could not determine a socket address. Are you running without any network? Switching to degraded mode.",
logger=logger)
logger.info("Falling back to offline actor system.")
actor.use_offline_actor_system()
actors = actor.bootstrap_actor_system(try_join=True)
else:
raise
try:
runnable(cfg)
finally:
# We only shutdown the actor system if it was not already running before
if not already_running:
shutdown_complete = False
times_interrupted = 0
# give some time for any outstanding messages to be delivered to the actor system
time.sleep(3)
while not shutdown_complete and times_interrupted < 2:
break
except KeyboardInterrupt:
times_interrupted += 1
logger.warning("User interrupted shutdown of internal actor system.")
console.info("Please wait a moment for Rally's internal components to shutdown.")
if not shutdown_complete and times_interrupted > 0:
logger.warning("Terminating after user has interrupted actor system shutdown explicitly for [%d] times." % times_interrupted)
console.println("")
console.warn("Terminating now at the risk of leaving child processes behind.")
console.println("")
console.warn("The next race may fail due to an unclean shutdown.")
console.println("")
console.println(SKULL)
console.println("")
elif not shutdown_complete:
console.warn("Could not terminate all internal processes within timeout. Please check and force-terminate all Rally processes.")
if task.warmup_time_period is not None or task.time_period is not None:
warmup_time_period = task.warmup_time_period if task.warmup_time_period else 0
logger.info("Creating time-period based schedule with [%s] distribution for [%s] with a warmup period of [%s] seconds and a "
"time period of [%s] seconds." % (task.schedule, task, str(warmup_time_period), str(task.time_period)))
return time_period_based(sched, warmup_time_period, task.time_period, runner_for_op, params_for_op)
else:
logger.info("Creating iteration-count based schedule with [%s] distribution for [%s] with [%d] warmup iterations and "
"[%d] iterations." % (task.schedule, op, task.warmup_iterations, task.iterations))
# TODO: Remove this message after some grace period
# just print this info message once
if client_index == 0 and num_clients > 1:
console.warn("!!! Behavior change for task %s !!!" % task)
console.warn("Before Rally 0.8.0: All %d clients together executed %d warmup iterations and %d iterations "
"(each got 1/%d th)." % (num_clients, task.warmup_iterations, task.iterations, num_clients))
console.warn("Now: Each client executes %d warmup iterations and %d iterations." % (task.warmup_iterations, task.iterations))
return iteration_count_based(sched, task.warmup_iterations, task.iterations, runner_for_op, params_for_op)
time.sleep(1)
timeout -= 1
if timeout > 0:
shutdown_complete = True
logger.info("Shutdown completed.")
else:
logger.warning("Shutdown timed out. Actor system is still running.")
break
except KeyboardInterrupt:
times_interrupted += 1
logger.warning("User interrupted shutdown of internal actor system.")
console.info("Please wait a moment for Rally's internal components to shutdown.")
if not shutdown_complete and times_interrupted > 0:
logger.warning("Terminating after user has interrupted actor system shutdown explicitly for [%d] times.", times_interrupted)
console.println("")
console.warn("Terminating now at the risk of leaving child processes behind.")
console.println("")
console.warn("The next race may fail due to an unclean shutdown.")
console.println("")
console.println(SKULL)
console.println("")
elif not shutdown_complete:
console.warn("Could not terminate all internal processes within timeout. Please check and force-terminate all Rally processes.")
def list_facts(cfg):
console.warn("This command is deprecated and will be removed with the next release of Rally.", overline="!", underline="!")
# provide a custom error message
target_hosts = cfg.opts("facts", "hosts", mandatory=False)
if not target_hosts:
raise exceptions.SystemSetupError("Please define a target host with --target-hosts")
if len(target_hosts) > 1:
raise exceptions.SystemSetupError("Only one target host is supported at the moment but you provided %s" % target_hosts)
# at this point an actor system has to run and we should only join
actor_system = actor.bootstrap_actor_system(try_join=True)
facts_actor = actor_system.createActor(FactsActor, targetActorRequirements={"ip": target_hosts[0]})
result = actor_system.ask(facts_actor, GatherFacts())
if isinstance(result, Facts):
console.println(json.dumps(result.facts, indent=" "))
else:
raise exceptions.RallyError("Could not gather facts: [%s]." % str(result))