From caa5e39303aa8cffc6ea5b191249c6ec7fe0282e Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Mon, 28 Aug 2023 15:38:01 -0700 Subject: [PATCH] Define defaults for cluster config settings --- salt/config/__init__.py | 15 +++++++++++++-- tests/pytests/unit/config/test_master_config.py | 6 +++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 815209ad8e9d..523d09addb61 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -1653,6 +1653,9 @@ def _gather_buffer_space(): "netapi_enable_clients": [], "maintenance_interval": 3600, "fileserver_interval": 3600, + "cluster_id": None, + "cluster_peers": [], + "cluster_pki_dir": None, } ) @@ -4051,12 +4054,20 @@ def apply_master_config(overrides=None, defaults=None): opts["cluster_id"] = None if opts["cluster_id"] is not None: if not opts.get("cluster_peers", None): + log.warning("Cluster id defined without defining cluster peers") opts["cluster_peers"] = [] if not opts.get("cluster_pki_dir", None): + log.warning( + "Cluster id defined without defining cluster pki, falling back to pki_dir" + ) opts["cluster_pki_dir"] = opts["pki_dir"] else: - opts["cluster_peers"] = [] - opts["cluster_pki_dir"] = None + if opts.get("cluster_peers", None): + log.warning("Cluster peers defined without a cluster_id, ignoring.") + opts["cluster_peers"] = [] + if opts.get("cluster_pki_dir", None): + log.warning("Cluster pki defined without a cluster_id, ignoring.") + opts["cluster_pki_dir"] = None # Enabling open mode requires that the value be set to True, and # nothing else! diff --git a/tests/pytests/unit/config/test_master_config.py b/tests/pytests/unit/config/test_master_config.py index ae482c7a572d..527f944e0eaa 100644 --- a/tests/pytests/unit/config/test_master_config.py +++ b/tests/pytests/unit/config/test_master_config.py @@ -3,7 +3,7 @@ def test_apply_no_cluster_id(): defaults = salt.config.DEFAULT_MASTER_OPTS.copy() - assert "cluster_id" not in defaults + assert defaults["cluster_id"] is None overrides = {} @@ -16,7 +16,7 @@ def test_apply_no_cluster_id(): def test_apply_default_for_cluster(): defaults = salt.config.DEFAULT_MASTER_OPTS.copy() - assert "cluster_id" not in defaults + assert defaults["cluster_id"] is None overrides = {"cluster_id": "test-cluster"} @@ -35,7 +35,7 @@ def test_apply_default_for_cluster(): def test_apply_for_cluster(): defaults = salt.config.DEFAULT_MASTER_OPTS.copy() - assert "cluster_id" not in defaults + assert defaults["cluster_id"] is None cluster_dir = "/tmp/cluster" overrides = {