Skip to content

Commit 5b29f77

Browse files
add a pio repair and sqlite3 optimize to each release
1 parent c6ba29f commit 5b29f77

2 files changed

Lines changed: 44 additions & 73 deletions

File tree

core/pioreactor/cli/pio.py

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -422,39 +422,44 @@ def create_commands_for_release_archive(
422422

423423
install_extra = get_install_extra_for_this_unit()
424424

425+
release_commands.append(
426+
update_command(
427+
[
428+
"/opt/pioreactor/venv/bin/pip",
429+
"install",
430+
"--no-index",
431+
f"--find-links={tmp_rls_dir}/wheels/",
432+
f"{tmp_rls_dir}/pioreactor-{release_version}-py3-none-any.whl[{install_extra}]",
433+
],
434+
3,
435+
)
436+
)
437+
438+
release_commands.append(
439+
update_command(
440+
[
441+
"/opt/pioreactor/venv/bin/pio",
442+
"repair",
443+
],
444+
99,
445+
)
446+
)
447+
425448
if whoami.am_I_leader():
426449
release_commands.extend(
427450
[
428-
update_command(
429-
[
430-
"/opt/pioreactor/venv/bin/pip",
431-
"install",
432-
"--no-index",
433-
f"--find-links={tmp_rls_dir}/wheels/",
434-
f"{tmp_rls_dir}/pioreactor-{release_version}-py3-none-any.whl[{install_extra}]",
435-
],
436-
3,
437-
),
438451
update_command(
439452
["sudo", "sqlite3", database_path, f".read {tmp_rls_dir}/update.sql"],
440453
10,
441454
allow_failure=True,
442455
),
456+
update_command(
457+
["sudo", "sqlite3", database_path, "PRAGMA optimize = 0x10002"],
458+
11,
459+
allow_failure=True,
460+
),
443461
]
444462
)
445-
else:
446-
release_commands.append(
447-
update_command(
448-
[
449-
"/opt/pioreactor/venv/bin/pip",
450-
"install",
451-
"--no-index",
452-
f"--find-links={tmp_rls_dir}/wheels/",
453-
f"{tmp_rls_dir}/pioreactor-{release_version}-py3-none-any.whl[{install_extra}]",
454-
],
455-
3,
456-
)
457-
)
458463

459464
return release_commands
460465

core/tests/test_update_app_commands.py

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -194,56 +194,6 @@ def test_app_commands_with_4_char_sha() -> None:
194194
assert command_priorities(cmds) == [expected]
195195

196196

197-
def test_app_commands_with_release_zip(tmp_path) -> None:
198-
version = "26.3.0"
199-
# construct a source path matching release zip pattern
200-
source_path = tmp_path / f"release_{version}.zip"
201-
# no need to create the file on disk; path string is enough
202-
source = str(source_path)
203-
cmds, ver = get_update_app_commands(
204-
branch=None,
205-
repo="org/repo",
206-
source=source,
207-
version=None,
208-
defer_web_restart=True,
209-
)
210-
assert ver == version
211-
tmp_dir = tempfile.gettempdir()
212-
tmp_rls_dir = f"{tmp_dir}/release_{version}"
213-
# verify expected sequence of commands and their priorities
214-
expected = [
215-
(verify_release_archive_command(source, version), -99.5),
216-
(["sudo", "rm", "-rf", tmp_rls_dir], -99),
217-
(["unzip", "-o", source, "-d", tmp_rls_dir], 0),
218-
(["unzip", "-o", f"{tmp_rls_dir}/wheels_{version}.zip", "-d", f"{tmp_rls_dir}/wheels"], 1),
219-
(["sudo", "bash", f"{tmp_rls_dir}/pre_update.sh"], 2),
220-
(["sudo", "bash", f"{tmp_rls_dir}/update.sh"], 4),
221-
(["sudo", "bash", f"{tmp_rls_dir}/post_update.sh"], 20),
222-
(["sudo", "rm", "-rf", tmp_rls_dir], 98),
223-
(
224-
[
225-
"/opt/pioreactor/venv/bin/pip",
226-
"install",
227-
"--no-index",
228-
f"--find-links={tmp_rls_dir}/wheels/",
229-
f"{tmp_rls_dir}/pioreactor-{version}-py3-none-any.whl[leader_worker]",
230-
],
231-
3,
232-
),
233-
(
234-
[
235-
"sudo",
236-
"sqlite3",
237-
config_module.config.get("storage", "database"),
238-
f".read {tmp_rls_dir}/update.sql",
239-
],
240-
10,
241-
),
242-
]
243-
assert command_priorities(cmds) == expected
244-
assert cmds[-1][2] is True
245-
246-
247197
def test_app_commands_with_release_zip_with_spaces_in_path(tmp_path) -> None:
248198
version = "26.3.0"
249199
source = str(tmp_path / "release bundles" / f"release_{version}.zip")
@@ -442,6 +392,13 @@ def mock_get(_url: str, **_kwargs) -> Response:
442392
],
443393
3,
444394
),
395+
(
396+
[
397+
"/opt/pioreactor/venv/bin/pio",
398+
"repair",
399+
],
400+
99,
401+
),
445402
(
446403
[
447404
"sudo",
@@ -451,6 +408,15 @@ def mock_get(_url: str, **_kwargs) -> Response:
451408
],
452409
10,
453410
),
411+
(
412+
[
413+
"sudo",
414+
"sqlite3",
415+
config_module.config.get("storage", "database"),
416+
"PRAGMA optimize = 0x10002",
417+
],
418+
11,
419+
),
454420
(["sudo", "rm", "-f", archive_location], 97),
455421
]
456422
sqlite_update_command = next(command for command in cmds if command[0][:2] == ["sudo", "sqlite3"])

0 commit comments

Comments
 (0)