Merge ~pwlars/testflinger-agent/+git/testflinger-agent-charm:avoid-permission-problems-restart-file into ~canonical-hw-cert/testflinger-agent/+git/testflinger-agent-charm:main

Proposed by Paul Larson
Status: Merged
Approved by: Paul Larson
Approved revision: 221f11468bdef96c5ce07a6558aada4fb58b45b6
Merged at revision: 8bb6e28b9fea5d48637b08d616fd4c886170e0ad
Proposed branch: ~pwlars/testflinger-agent/+git/testflinger-agent-charm:avoid-permission-problems-restart-file
Merge into: ~canonical-hw-cert/testflinger-agent/+git/testflinger-agent-charm:main
Diff against target: 18 lines (+5/-2)
1 file modified
src/charm.py (+5/-2)
Reviewer Review Type Date Requested Status
Sheila Miguez (community) Approve
Review via email: mp+431593@code.launchpad.net

Description of the change

Avoid permission problems that could occur, and it's pointless to recreate this anyway since it already exists

To post a comment you must log in.
Revision history for this message
Sheila Miguez (codersquid) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/charm.py b/src/charm.py
2index d3bfde8..4dbd939 100755
3--- a/src/charm.py
4+++ b/src/charm.py
5@@ -170,8 +170,11 @@ class TestflingerAgentCharm(CharmBase):
6
7 def _signal_restart_agent(self):
8 """Signal testflinger-agent to restart when it's not busy"""
9- restart_file = f"/tmp/TESTFLINGER-DEVICE-RESTART-{self.app.name}"
10- open(restart_file, mode="w").close()
11+ restart_file = PosixPath(
12+ f"/tmp/TESTFLINGER-DEVICE-RESTART-{self.app.name}")
13+ if restart_file.exists():
14+ return
15+ restart_file.open(mode="w").close()
16 shutil.chown(restart_file, "ubuntu", "ubuntu")
17
18 def _write_config_files(self):

Subscribers

People subscribed via source and target branches