Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 634d4d3

Browse files
committed
Merge branch 'main' into prs/adding-pickle-output-to-cli
2 parents bff688c + eca2435 commit 634d4d3

File tree

21 files changed

+183
-66
lines changed

21 files changed

+183
-66
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: pre-commit
1+
name: py:pre-commit
22

33
on:
44
pull_request:
@@ -11,5 +11,5 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v3
1313
- uses: actions/setup-python@v3
14-
- run: python -m pip install .[tests]
14+
- run: pip install .[tests]
1515
- uses: pre-commit/[email protected]

.github/workflows/on-push-test.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: py:test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
codeql-analysis:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
- name: Set up Python
16+
id: setup-python
17+
uses: actions/setup-python@v3
18+
- name: Get the Python path
19+
id: get-python-path
20+
run: echo "python-path=`which python`"
21+
- name: Install dependencies
22+
run: |-
23+
pip install -r ./requirements.txt
24+
pip install pylint --upgrade
25+
- name: Initialize CodeQL
26+
uses: github/codeql-action/init@v3
27+
with:
28+
languages: python
29+
queries: security-extended
30+
- name: Perform CodeQL analysis
31+
env:
32+
CODEQL_PYTHON: ${{ steps.get-python-path.outputs.python-path }}
33+
uses: github/codeql-action/analyze@v3
34+
35+
test:
36+
runs-on: ubuntu-latest
37+
strategy:
38+
matrix:
39+
python-version: [ "3.9", "3.10", "3.11", "3.12" ]
40+
41+
steps:
42+
- name: Checkout commit
43+
uses: actions/checkout@v3
44+
- name: Set up Python ${{ matrix.python-version }}
45+
uses: actions/setup-python@v3
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
- name: Install dependencies
49+
run: |-
50+
pip install -r ./requirements.txt
51+
- name: Execute tests
52+
run: pytest

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ build-container: ## Build container from Dockerfile, add e.g. ROOKIFY_VERSION=0.
7575

7676
.PHONY: run-local-rookify
7777
run-local-rookify: ## Runs rookify in the local development environment (requires setup-venv)
78-
if [ ! -f ./.venv/bin/rookify ]; then \
79-
${MAKE} build-local-rookify; \
80-
fi; \
81-
.venv/bin/rookify
78+
source ./.venv/bin/activate && pip install -e . && rookify
8279

8380
.PHONY: run-rookify
8481
run-rookify: ## Runs rookify in the container

mock_src/__init__.py

Whitespace-only changes.

mock_src/rados.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# -*- coding: utf-8 -*-
2+
3+
pass

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ classifiers = [
2626
Homepage = "https://scs.community"
2727

2828
[tool.pytest.ini_options]
29-
pythonpath = [ "src" ]
29+
pythonpath = [ "src", "mock_src" ]

src/rookify/modules/ceph.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import json
44
import rados
5-
from typing import Any, Dict, List
5+
from typing import Any, Dict
66
from .exception import ModuleException
77

88

@@ -19,7 +19,7 @@ def __init__(self, config: Dict[str, Any]):
1919
def __getattr__(self, name: str) -> Any:
2020
return getattr(self.__ceph, name)
2121

22-
def _json_command(self, handler: Any, *args: Any) -> Dict[str, Any] | List[Any]:
22+
def _json_command(self, handler: Any, *args: Any) -> Any:
2323
result = handler(*args)
2424
if result[0] != 0:
2525
raise ModuleException(f"Ceph did return an error: {result}")
@@ -53,19 +53,17 @@ def get_osd_pool_configurations_from_osd_dump(
5353

5454
return osd_pools
5555

56-
def mon_command(self, command: str, **kwargs: Any) -> Dict[str, Any] | List[Any]:
56+
def mon_command(self, command: str, **kwargs: Any) -> Any:
5757
cmd = {"prefix": command, "format": "json"}
5858
cmd.update(**kwargs)
5959
return self._json_command(self.__ceph.mon_command, json.dumps(cmd), b"")
6060

61-
def mgr_command(self, command: str, **kwargs: Any) -> Dict[str, Any] | List[Any]:
61+
def mgr_command(self, command: str, **kwargs: Any) -> Any:
6262
cmd = {"prefix": command, "format": "json"}
6363
cmd.update(**kwargs)
6464
return self._json_command(self.__ceph.mgr_command, json.dumps(cmd), b"")
6565

66-
def osd_command(
67-
self, osd_id: int, command: str, **kwargs: Any
68-
) -> Dict[str, Any] | List[Any]:
66+
def osd_command(self, osd_id: int, command: str, **kwargs: Any) -> Any:
6967
cmd = {"prefix": command, "format": "json"}
7068
cmd.update(**kwargs)
7169
return self._json_command(self.__ceph.osd_command, osd_id, json.dumps(cmd), b"")

src/rookify/modules/create_rook_resources/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ def execute(self) -> None:
106106
mon="allow *",
107107
mgr="allow *",
108108
mds="allow *",
109-
) # type: ignore
109+
)
110110

111111
mon_auth: Dict[str, Any] = self.ceph.mon_command(
112112
"auth get-or-create-key", entity="mon.", mon="allow *"
113-
) # type: ignore
113+
)
114114

115115
metadata = kubernetes.client.V1ObjectMeta(name="rook-ceph-mon")
116116

src/rookify/modules/k8s.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,39 +43,39 @@ def mds_placement_label(self) -> str:
4343
return (
4444
str(self._rook_config["cluster"]["mds_placement_label"])
4545
if "mds_placement_label" in self._rook_config["cluster"]
46-
else f"placement-{self._rook_config["cluster"]["name"]}-mds"
46+
else "placement-{0}-mds".format(self._rook_config["cluster"]["name"])
4747
)
4848

4949
@property
5050
def mon_placement_label(self) -> str:
5151
return (
5252
str(self._rook_config["cluster"]["mon_placement_label"])
5353
if "mon_placement_label" in self._rook_config["cluster"]
54-
else f"placement-{self._rook_config["cluster"]["name"]}-mon"
54+
else "placement-{0}-mon".format(self._rook_config["cluster"]["name"])
5555
)
5656

5757
@property
5858
def mgr_placement_label(self) -> str:
5959
return (
6060
str(self._rook_config["cluster"]["mgr_placement_label"])
6161
if "mgr_placement_label" in self._rook_config["cluster"]
62-
else f"placement-{self._rook_config["cluster"]["name"]}-mgr"
62+
else "placement-{0}-mgr".format(self._rook_config["cluster"]["name"])
6363
)
6464

6565
@property
6666
def osd_placement_label(self) -> str:
6767
return (
6868
str(self._rook_config["cluster"]["osd_placement_label"])
6969
if "osd_placement_label" in self._rook_config["cluster"]
70-
else f"placement-{self._rook_config["cluster"]["name"]}-osd"
70+
else "placement-{0}-osd".format(self._rook_config["cluster"]["name"])
7171
)
7272

7373
@property
7474
def rgw_placement_label(self) -> str:
7575
return (
7676
str(self._rook_config["cluster"]["rgw_placement_label"])
7777
if "rgw_placement_label" in self._rook_config["cluster"]
78-
else f"placement-{self._rook_config["cluster"]["name"]}-rgw"
78+
else "placement-{0}-rgw".format(self._rook_config["cluster"]["name"])
7979
)
8080

8181
def check_nodes_for_initial_label_state(self, label: str) -> None:

src/rookify/modules/machine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def __init__(self, machine_pickle_file: Optional[str] = None) -> None:
2020

2121
_Machine.__init__(self, states=["uninitialized"], initial="uninitialized")
2222

23-
def add_execution_state(self, name: str, **kwargs: Dict[str, Any]) -> None:
23+
def add_execution_state(self, name: str, **kwargs: Any) -> None:
2424
self._execution_states.append(self.__class__.state_cls(name, **kwargs))
2525

26-
def add_preflight_state(self, name: str, **kwargs: Dict[str, Any]) -> None:
26+
def add_preflight_state(self, name: str, **kwargs: Any) -> None:
2727
self._preflight_states.append(self.__class__.state_cls(name, **kwargs))
2828

2929
def execute(

0 commit comments

Comments
 (0)