Fix salt cloud's log_file location when root_dir is given in config

This commit is contained in:
Daniel A. Wozniak 2024-06-22 03:22:17 -07:00 committed by Daniel Wozniak
parent 3735415fbc
commit dfd6221cc5
3 changed files with 15 additions and 1 deletions

1
changelog/64728.fixed.md Normal file
View file

@ -0,0 +1 @@
Cloud honors root_dir config settin when determining log file location

View file

@ -2765,7 +2765,7 @@ def cloud_config(
# prepend root_dir
prepend_root_dirs = ["cachedir"]
if "log_file" in opts and urllib.parse.urlparse(opts["log_file"]).scheme == "":
prepend_root_dirs.append(opts["log_file"])
prepend_root_dirs.append("log_file")
prepend_root_dir(opts, prepend_root_dirs)
salt.features.setup_features(opts)

View file

@ -25,3 +25,16 @@ def test_minion_config_type_check(caplog):
assert msg not in caplog.text
finally:
os.remove(path)
def test_cloud_config_relative_logfile(tmp_path):
root_path = tmp_path
config_path = tmp_path / "conf"
config_path.mkdir()
cloud_config = config_path / "cloud"
cloud_config.write_text("")
master_config = config_path / "master"
master_config = config_path / "master"
master_config.write_text(f"root_dir: {root_path}")
opts = salt.config.cloud_config(cloud_config)
assert opts["log_file"] == str(root_path / "var" / "log" / "salt" / "cloud")