in esrally/mechanic/provisioner.py [0:0]
def prepare(self, binary):
# we need to allow other users to write to these directories due to Docker.
#
# Although os.mkdir passes 0o777 by default, mkdir(2) uses `mode & ~umask & 0777` to determine the final flags and
# hence we need to modify the process' umask here. For details see https://linux.die.net/man/2/mkdir.
previous_umask = os.umask(0)
try:
io.ensure_dir(self.binary_path)
io.ensure_dir(self.node_log_dir)
io.ensure_dir(self.heap_dump_dir)
io.ensure_dir(self.data_paths[0])
finally:
os.umask(previous_umask)
mounts = {}
for car_config_path in self.car.config_paths:
for root, _, files in os.walk(car_config_path):
env = jinja2.Environment(loader=jinja2.FileSystemLoader(root))
relative_root = root[len(car_config_path) + 1 :]
absolute_target_root = os.path.join(self.binary_path, relative_root)
io.ensure_dir(absolute_target_root)
for name in files:
source_file = os.path.join(root, name)
target_file = os.path.join(absolute_target_root, name)
mounts[target_file] = os.path.join("/usr/share/elasticsearch", relative_root, name)
if plain_text(source_file):
self.logger.info("Reading config template file [%s] and writing to [%s].", source_file, target_file)
with open(target_file, mode="a", encoding="utf-8") as f:
f.write(_render_template(env, self.config_vars, source_file))
else:
self.logger.info("Treating [%s] as binary and copying as is to [%s].", source_file, target_file)
shutil.copy(source_file, target_file)
docker_cfg = self._render_template_from_file(self.docker_vars(mounts))
self.logger.info("Starting Docker container with configuration:\n%s", docker_cfg)
with open(os.path.join(self.binary_path, "docker-compose.yml"), mode="w", encoding="utf-8") as f:
f.write(docker_cfg)
return NodeConfiguration(
"docker",
self.car.mandatory_var("runtime.jdk"),
convert.to_bool(self.car.mandatory_var("runtime.jdk.bundled")),
self.node_ip,
self.node_name,
self.node_root_dir,
self.binary_path,
self.data_paths,
)