Skip to content

Commit

Permalink
Define defaults for cluster config settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz authored and garethgreenaway committed Sep 6, 2023
1 parent 46eb7f7 commit caa5e39
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 13 additions & 2 deletions salt/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
)

Expand Down Expand Up @@ -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!
Expand Down
6 changes: 3 additions & 3 deletions tests/pytests/unit/config/test_master_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand All @@ -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"}

Expand All @@ -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 = {
Expand Down

0 comments on commit caa5e39

Please sign in to comment.