Skip to content

Commit d1fafa5

Browse files
fix: use lazy formatting for logging calls
Signed-off-by: Mathieu Labourier <mathieu.labourier@vates.tech>
1 parent 76186f2 commit d1fafa5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

tests/storage/linstor/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def get_vdi_host(path: str) -> Host:
215215
volume_name = get_vdi_volume_name_from_linstor()
216216
lv_path = f"/dev/{GROUP_NAME}/{volume_name}_00000"
217217
vdi_host = get_vdi_host(lv_path)
218-
logging.info(f"[{host}]: corrupting `{lv_path}`")
218+
logging.info("[%s]: corrupting `%s`", host, lv_path)
219219
vdi_host.ssh([
220220
"dd",
221221
"if=/dev/urandom",

tests/storage/linstor/test_linstor_sr.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_create_and_destroy_sr(self, pool_with_linstor, provisioning_type, stora
5959

6060

6161
def get_drbd_status(host: Host, resource: str):
62-
logging.debug(f"[{host}] Fetching DRBD status for resource `{resource}`...")
62+
logging.debug("[%s] Fetching DRBD status for resource `%s`...", host, resource)
6363
return json.loads(host.ssh(["drbdsetup", "status", resource, "--json"]))
6464

6565
def get_corrupted_resources(host: Host, resource: str):
@@ -76,7 +76,7 @@ def get_corrupted_resources(host: Host, resource: str):
7676
]
7777

7878
def wait_drbd_sync(host: Host, resource: str):
79-
logging.info(f"[{host}] Waiting for DRBD sync on resource `{resource}`...")
79+
logging.info("[%s] Waiting for DRBD sync on resource `%s`...", host, resource)
8080
host.ssh(["drbdadm", "wait-sync", resource])
8181

8282

@@ -131,22 +131,22 @@ def test_resynchronization(
131131
for peer in conn.get("peer_devices", [])
132132
if peer.get("peer-disk-state", "") == "UpToDate"
133133
)
134-
logging.info(f"Elected `{other_host}` as peer for verification and repair")
134+
logging.info("Elected `%s` as peer for verification and repair", other_host)
135135
except StopIteration:
136136
pytest.fail("Could not find an UpToDate peer host")
137137

138138
corrupted = None
139139
max_attempts = 3
140140
# Attempting several times since testing revealed `drbdadm verify` can be flaky
141141
for attempt in range(1, max_attempts + 1):
142-
logging.info(f"`drbdadm verify` attempt {attempt}/{max_attempts}")
143-
logging.info(f"[{other_host}] Running DRBD verify for `{resource_name}`...")
142+
logging.info("`drbdadm verify` attempt %d/%d", attempt, max_attempts)
143+
logging.info("[%s] Running DRBD verify for %s...", other_host, resource_name)
144144
other_host.ssh(["drbdadm", "verify", f"{resource_name}:{hostname}/0"])
145145
wait_drbd_sync(other_host, resource_name)
146146

147147
corrupted_resources = get_corrupted_resources(other_host, resource_name)
148148
if not corrupted_resources:
149-
logging.warning(f"No corrupted resources found on attempt #{attempt}")
149+
logging.warning("No corrupted resources found on attempt #%d", attempt)
150150
continue
151151
for res_name, peer_name, out_of_sync in corrupted_resources:
152152
if res_name == resource_name and peer_name == hostname:
@@ -156,7 +156,7 @@ def test_resynchronization(
156156
if not corrupted:
157157
pytest.fail(f"Failed to identify corrupted resource after {max_attempts} attempts")
158158

159-
logging.info(f"Invalidating remote resource `{resource_name}`...")
159+
logging.info("Invalidating remote resource `%s`...", resource_name)
160160
other_host.ssh([
161161
"drbdadm", "invalidate-remote",
162162
f"{resource_name}:{hostname}/0",

0 commit comments

Comments
 (0)