Skip to content

Commit 863ae03

Browse files
Merge pull request #548 from lmiccini/iha_disabled_fix
Fix INSTANCEHA_DISABLED env var override logic
2 parents 5d1715f + ee8da25 commit 863ae03

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

templates/instanceha/bin/instanceha.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,10 @@ def _load_config(self) -> Dict[str, Any]:
398398
data = self._load_yaml_file(self.config_path, "configuration")
399399
config = data.get("config", {})
400400
# Allow the INSTANCEHA_DISABLED env var (set from the CR spec) to override
401-
# the config file value
402-
env_disabled = os.getenv('INSTANCEHA_DISABLED')
403-
if env_disabled is not None:
404-
config['DISABLED'] = env_disabled == 'True'
401+
# the config file value. The env var is always set (either "True" or
402+
# "False"), so we only override when it is explicitly "True".
403+
if os.getenv('INSTANCEHA_DISABLED') == 'True':
404+
config['DISABLED'] = True
405405
return config
406406

407407
def _load_clouds_config(self) -> Dict[str, Any]:

test/instanceha/test_config_features.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def test_env_var_true_overrides_config(self):
7474

7575
self.assertTrue(result['DISABLED'])
7676

77-
def test_env_var_false_overrides_config(self):
78-
"""Test that INSTANCEHA_DISABLED=False env var sets DISABLED=False in config."""
77+
def test_env_var_false_preserves_config(self):
78+
"""Test that INSTANCEHA_DISABLED=False preserves the config file value."""
7979
with patch.dict(os.environ, {'INSTANCEHA_DISABLED': 'False'}):
8080
config = instanceha.ConfigManager.__new__(instanceha.ConfigManager)
8181
config.config_path = '/nonexistent'
@@ -86,7 +86,7 @@ def test_env_var_false_overrides_config(self):
8686
with patch.object(config, '_load_yaml_file', return_value={'config': {'DISABLED': True}}):
8787
result = config._load_config()
8888

89-
self.assertFalse(result['DISABLED'])
89+
self.assertTrue(result['DISABLED'])
9090

9191
def test_env_var_absent_uses_config_file(self):
9292
"""Test that without INSTANCEHA_DISABLED env var, config file value is used."""

zuul.d/projects.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
github-check:
77
jobs:
88
- openstack-k8s-operators-content-provider:
9-
irrelevant-files:
9+
irrelevant-files: &iha_irrelevant_files
1010
- ^templates/instanceha/.*$
1111
- ^test/instanceha/.*$
1212
vars:
1313
cifmw_install_yamls_sdk_version: v1.41.1
1414
cifmw_operator_build_golang_ct: "docker.io/library/golang:1.24"
1515
cifmw_operator_build_golang_alt_ct: "quay.rdoproject.org/openstack-k8s-operators/golang:1.24"
16+
- podified-multinode-edpm-deployment-crc:
17+
irrelevant-files: *iha_irrelevant_files
18+
- cifmw-crc-podified-edpm-baremetal:
19+
irrelevant-files: *iha_irrelevant_files

0 commit comments

Comments
 (0)