Skip to content

Commit

Permalink
Add support to configure which systemd unit services or targets to use
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Wolf <[email protected]>
  • Loading branch information
NotTheEvilOne committed Nov 4, 2024
1 parent 4e78de7 commit d962cc9
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 10 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,19 @@ OSD devices: Not analyzed yet

#### Troubleshooting

**ssh-issues:**
- make sure the id-rsa keys are "clean" and do not contain unexpected strings like "\<\<EOF". E.g. call `ssh-keygen -p -N "" -f ssh.key` to convert and reformat the keyfile to the expected format.
- allow direnv (`direnv allow`) to use `.envrc` or copy and execute the command from the file: this switches off the ssh-agent, which sometimes has too many keys loaded
**missing Ceph systemd targets:**
- please consult your distribution's documentation in case documented Ceph systemd unit services or targets are missing

**frozen state:**
- if the rookify process freezes, check your connections. In the OSISM testbed especially check the vpn-connection (in testbed repository try `make vpn-*`)

**ssh-issues:**
- make sure the id-rsa keys are "clean" and do not contain unexpected strings like "\<\<EOF". E.g. call `ssh-keygen -p -N "" -f ssh.key` to convert and reformat the keyfile to the expected format.
- allow direnv (`direnv allow`) to use `.envrc` or copy and execute the command from the file: this switches off the ssh-agent, which sometimes has too many keys loaded

## Support

For issues, questions, or contributions, please open an issue or pull request in the GitHub repository. We welcome community feedback and contributions to enhance rookify.


## License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
1 change: 0 additions & 1 deletion config.example.osism.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ rook:

migration_modules:
- example
- create_rook_cluster
- migrate_osds
- migrate_osd_pools
- migrate_mds
Expand Down
6 changes: 6 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ logging:
ceph:
config: ./.ceph/ceph.conf
keyring: ./.ceph/ceph.client.admin.keyring
systemd_file_name_templates:
mds: "ceph-{fsid}@mds.{host}.service"
mgr: "ceph-{fsid}@mgr.{host}.service"
mon: "ceph-{fsid}@mon.{host}.service"
osd: "ceph-{fsid}@osd.{host}.service"
rgw: "ceph-{fsid}@rgw.{host}.service"

# fill in correct path to private key
ssh:
Expand Down
8 changes: 8 additions & 0 deletions src/rookify/config.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ logging:
ceph:
config: str()
keyring: str()
systemd_file_name_templates: include("systemd_file_name_templates", required=False)

ssh:
private_key: str()
Expand Down Expand Up @@ -39,3 +40,10 @@ migration_modules: list(str())
ssh_host:
address: ip()
user: str()
---
systemd_file_name_templates:
mds: str(required=False)
mgr: str(required=False)
mon: str(required=False)
osd: str(required=False)
rgw: str(required=False)
43 changes: 43 additions & 0 deletions src/rookify/modules/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def __init__(self, config: Dict[str, Any]):
except rados.ObjectNotFound as err:
raise ModuleException(f"Could not connect to ceph: {err}")

status_data = self.mon_command("status")

self._fsid = status_data["fsid"]
self._systemd_file_name_templates = config.get(
"systemd_file_name_templates", {}
)

def __getattr__(self, name: str) -> Any:
return getattr(self.__ceph, name)

Expand All @@ -32,6 +39,42 @@ def _json_command(self, handler: Any, *args: Any) -> Any:

return data

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"),
host,
)

def get_systemd_mgr_file_name(self, host: str) -> str:
return self._get_systemd_template_file_name(
self._systemd_file_name_templates.get("mgr", "ceph-mgr.target"),
host,
)

def get_systemd_mon_file_name(self, host: str) -> str:
return self._get_systemd_template_file_name(
self._systemd_file_name_templates.get("mon", "ceph-mon.target"),
host,
)

def get_systemd_osd_file_name(self, host: str, osd_id: int) -> str:
file_name_template: str = self._systemd_file_name_templates.get(
"osd", "ceph-osd@{0:d}.service".format(osd_id)
)

return file_name_template.format(fsid=self._fsid, host=host, osd_id=osd_id)

def get_systemd_rgw_file_name(self, host: str) -> str:
return self._get_systemd_template_file_name(
self._systemd_file_name_templates.get("mon", "ceph-radosgw.target"),
host,
)

def _get_systemd_template_file_name(
self, file_name_template: str, host: str
) -> str:
return file_name_template.format(fsid=self._fsid, host=host)

def get_osd_pool_configurations_from_map(
self, dump_data: Dict[str, Any]
) -> Dict[str, Any]:
Expand Down
5 changes: 4 additions & 1 deletion src/rookify/modules/migrate_mds/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ def execute(self) -> None:

def _disable_mds(self, mds_host: str) -> None:
result = self.ssh.command(
mds_host, "sudo systemctl disable --now ceph-mds.target"
mds_host,
"sudo systemctl disable --now {0}".format(
self.ceph.get_systemd_mds_file_name(mds_host)
),
)

if result.failed:
Expand Down
5 changes: 4 additions & 1 deletion src/rookify/modules/migrate_mgrs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ def _migrate_mgr(self, mgr_host: str) -> None:
self.logger.info("Migrating ceph-mgr daemon at host'{0}'".format(mgr_host))

result = self.ssh.command(
mgr_host, "sudo systemctl disable --now ceph-mgr.target"
mgr_host,
"sudo systemctl disable --now {0}".format(
self.ceph.get_systemd_mgr_file_name(mgr_host)
),
)

if result.failed:
Expand Down
5 changes: 4 additions & 1 deletion src/rookify/modules/migrate_mons/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def _migrate_mon(self, mon: Dict[str, Any]) -> None:
self.logger.info("Migrating ceph-mon daemon '{0}'".format(mon["name"]))

result = self.ssh.command(
mon["name"], "sudo systemctl disable --now ceph-mon.target"
mon["name"],
"sudo systemctl disable --now {0}".format(
self.ceph.get_systemd_mon_file_name(mon["name"])
),
)

if result.failed:
Expand Down
4 changes: 3 additions & 1 deletion src/rookify/modules/migrate_osds/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ def migrate_osds(self, host: str, osd_ids: List[int]) -> None:

result = self.ssh.command(
host,
"sudo systemctl disable --now ceph-osd@{0:d}.service".format(osd_id),
"sudo systemctl disable --now {0}".format(
self.ceph.get_systemd_osd_file_name(host, osd_id)
),
)

if result.failed:
Expand Down
5 changes: 4 additions & 1 deletion src/rookify/modules/migrate_rgws/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def _migrate_rgw(self, rgw_host: str) -> None:

if is_migration_required:
result = self.ssh.command(
rgw_host, "sudo systemctl disable --now ceph-radosgw.target"
rgw_host,
"sudo systemctl disable --now {0}".format(
self.ceph.get_systemd_rgw_file_name(rgw_host)
),
)

if result.failed:
Expand Down

0 comments on commit d962cc9

Please sign in to comment.