Skip to content

Commit 725917c

Browse files
Add support to change behaviour based on feature flags
This commit supports feature flags for: - Ceph - Kubernetes - Rook As we do not have feature flags for Ceph or Kubernetes yet any key is currently accepted. This will change once needed. Signed-off-by: Tobias Wolf <[email protected]>
1 parent 9222d68 commit 725917c

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

config.example.osism.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ rook:
3939
rgw_placement_label: node-role.osism.tech/rook-rgw
4040
ceph:
4141
image: quay.io/ceph/ceph:v18.2.1
42+
flags:
43+
mds_support_metadata_name: False
4244

4345
migration_modules:
4446
- example

config.example.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ rook:
4040
namespace: rook-ceph
4141
ceph:
4242
image: quay.io/ceph/ceph:v18.2.1
43+
flags:
44+
mds_support_metadata_name: False
4345

4446
migration_modules:
4547
- example
@@ -48,5 +50,6 @@ migration_modules:
4850
- migrate_osd_pools
4951
- migrate_mds
5052
- migrate_mds_pools
53+
- migrate_mgrs
5154
- migrate_rgws
5255
- migrate_rgw_pools

src/rookify/config.schema.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ logging:
99

1010
ceph:
1111
config: str()
12+
flags: map(key=str(), required=False) # @TODO: Replace with include once we support at least one Ceph flag
1213
keyring: str()
1314
systemd_file_name_templates: include("systemd_file_name_templates", required=False)
1415

@@ -18,6 +19,7 @@ ssh:
1819

1920
kubernetes:
2021
config: str()
22+
flags: map(key=str(), required=False) # @TODO: Replace with include once we support at least one Kubernetes flag
2123

2224
rook:
2325
cluster:
@@ -34,9 +36,13 @@ rook:
3436
image: str()
3537
public_network: regex("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(/(3[0-2]|2[0-9]|1[0-9]|[0-9]))?$", required=False)
3638
cluster_network: regex("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(/(3[0-2]|2[0-9]|1[0-9]|[0-9]))?$", required=False)
39+
flags: include("rook_flags", required=False)
3740

3841
migration_modules: list(str())
3942
---
43+
rook_flags:
44+
mds_support_metadata_name: bool()
45+
---
4046
ssh_host:
4147
address: ip()
4248
user: str()

src/rookify/modules/ceph.py

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def __init__(self, config: Dict[str, Any]):
1818

1919
status_data = self.mon_command("status")
2020

21+
self._flags: Dict[str, bool] = config.get("flags", {})
2122
self._fsid = status_data["fsid"]
2223

2324
self._systemd_file_name_templates = config.get(
@@ -40,6 +41,9 @@ def _json_command(self, handler: Any, *args: Any) -> Any:
4041

4142
return data
4243

44+
def get_flag(self, name: str, default_value: bool = False) -> bool:
45+
return self._flags.get(name, default_value)
46+
4347
def get_systemd_mds_file_name(self, host: str) -> str:
4448
return self._get_systemd_template_file_name(
4549
self._systemd_file_name_templates.get("mds", "ceph-mds.target"),

src/rookify/modules/k8s.py

+13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ def __init__(self, config: Dict[str, Any]):
1111
config_file=config["kubernetes"]["config"]
1212
)
1313

14+
self._flags: Dict[str, bool] = config["kubernetes"].get("flags", {})
1415
self._rook_config = config["rook"]
16+
self._rook_flags: Dict[str, bool] = config["rook"].get("flags", {})
1517

1618
self.__client = kubernetes.client.ApiClient(k8s_config)
1719
self.__dynamic_client: Optional[kubernetes.dynamic.DynamicClient] = None
@@ -116,6 +118,17 @@ def crd_api_apply(
116118
except kubernetes.dynamic.exceptions.NotFoundError:
117119
return crd_api.create(body=manifest, namespace=namespace)
118120

121+
def _get_flag(
122+
self, flags: Dict[str, bool], name: str, default_value: bool = False
123+
) -> bool:
124+
return flags.get(name, default_value)
125+
126+
def get_flag(self, name: str, default_value: bool = False) -> bool:
127+
return self._get_flag(self._flags, name, default_value)
128+
129+
def get_rook_flag(self, name: str, default_value: bool = False) -> bool:
130+
return self._get_flag(self._rook_flags, name, default_value)
131+
119132
def watch_events(
120133
self,
121134
callback_func: Callable[[Any], Any],

0 commit comments

Comments
 (0)