Skip to content

Add support to change behaviour based on feature flags #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config.example.osism.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ rook:
rgw_placement_label: node-role.osism.tech/rook-rgw
ceph:
image: quay.io/ceph/ceph:v18.2.1
flags:
mds_support_metadata_name: False

migration_modules:
- example
Expand Down
3 changes: 3 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ rook:
namespace: rook-ceph
ceph:
image: quay.io/ceph/ceph:v18.2.1
flags:
mds_support_metadata_name: False

migration_modules:
- example
Expand All @@ -48,5 +50,6 @@ migration_modules:
- migrate_osd_pools
- migrate_mds
- migrate_mds_pools
- migrate_mgrs
- migrate_rgws
- migrate_rgw_pools
6 changes: 6 additions & 0 deletions src/rookify/config.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ logging:

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

Expand All @@ -18,6 +19,7 @@ ssh:

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

rook:
cluster:
Expand All @@ -34,9 +36,13 @@ rook:
image: str()
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)
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)
flags: include("rook_flags", required=False)

migration_modules: list(str())
---
rook_flags:
mds_support_metadata_name: bool()
---
ssh_host:
address: ip()
user: str()
Expand Down
4 changes: 4 additions & 0 deletions src/rookify/modules/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, config: Dict[str, Any]):

status_data = self.mon_command("status")

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

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

return data

def get_flag(self, name: str, default_value: bool = False) -> bool:
return self._flags.get(name, default_value)

def get_systemd_mds_file_name(self, host: str) -> str:
return self._get_systemd_template_file_name(
self._systemd_file_name_templates.get("mds", "ceph-mds.target"),
Expand Down
13 changes: 13 additions & 0 deletions src/rookify/modules/k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def __init__(self, config: Dict[str, Any]):
config_file=config["kubernetes"]["config"]
)

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

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

def _get_flag(
self, flags: Dict[str, bool], name: str, default_value: bool = False
) -> bool:
return flags.get(name, default_value)

def get_flag(self, name: str, default_value: bool = False) -> bool:
return self._get_flag(self._flags, name, default_value)

def get_rook_flag(self, name: str, default_value: bool = False) -> bool:
return self._get_flag(self._rook_flags, name, default_value)

def watch_events(
self,
callback_func: Callable[[Any], Any],
Expand Down
Loading