Skip to content

Commit

Permalink
Merge branch 'main' into prs/externalize-modulehandler-subclasses
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Wolf <[email protected]>
  • Loading branch information
NotTheEvilOne authored Jun 12, 2024
2 parents 4dcc214 + e2ce404 commit 6e98a4d
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/rookify/modules/create_cluster/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-

import kubernetes
from typing import Any
from ..exception import ModuleException
from ..machine import Machine
from ..module import ModuleHandler
from ..module import ModuleHandler, ModuleException


class CreateClusterHandler(ModuleHandler):
Expand All @@ -16,16 +17,16 @@ class CreateClusterHandler(ModuleHandler):

@property
def __mon_placement_label(self) -> str:
return ( # type: ignore
self._config["rook"]["cluster"]["mon_placement_label"]
return (
str(self._config["rook"]["cluster"]["mon_placement_label"])
if "mon_placement_label" in self._config["rook"]["cluster"]
else f"placement-{self._config["rook"]["cluster"]["name"]}-mon"
)

@property
def __mgr_placement_label(self) -> str:
return ( # type: ignore
self._config["rook"]["cluster"]["mgr_placement_label"]
return (
str(self._config["rook"]["cluster"]["mgr_placement_label"])
if "mgr_placement_label" in self._config["rook"]["cluster"]
else f"placement-{self._config["rook"]["cluster"]["name"]}-mgr"
)
Expand Down Expand Up @@ -54,6 +55,15 @@ def __create_cluster_definition(self) -> None:
f"There are more than 1 mgr running on node {node}"
)

self.logger.debug(
"Rook cluster definition values: {0} {1} with mon label {2} and mgr label {3}".format(
self._config["rook"]["cluster"]["namespace"],
self._config["rook"]["cluster"]["name"],
self.__mon_placement_label,
self.__mgr_placement_label,
)
)

# Render cluster config from template
cluster_definition = self.load_template(
"cluster.yaml.j2",
Expand Down Expand Up @@ -97,6 +107,8 @@ def preflight(self) -> None:
self.__create_cluster_definition()

def execute(self) -> None:
self.logger.info("Creating Rook cluster definition")

# Create CephCluster
cluster_definition = self.machine.get_preflight_state(
"CreateClusterHandler"
Expand All @@ -105,6 +117,8 @@ def execute(self) -> None:
self.k8s.crd_api_apply(cluster_definition)

# Wait for CephCluster to get into Progressing phase
self.logger.info("Waiting for Rook cluster created")

result = self.k8s.watch_events(
self._watch_cluster_phase_callback,
self.k8s.custom_objects_api.list_namespaced_custom_object,
Expand Down

0 comments on commit 6e98a4d

Please sign in to comment.