Merge ~troyanov/maas:agent-create-rundir into maas:master

Proposed by Anton Troyanov
Status: Merged
Approved by: Anton Troyanov
Approved revision: 59c39829115c278d81d2685ee6e2f5ce92a55e7e
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~troyanov/maas:agent-create-rundir
Merge into: maas:master
Diff against target: 26 lines (+13/-1)
1 file modified
src/maasagent/cmd/maas-agent/main.go (+13/-1)
Reviewer Review Type Date Requested Status
Christian Grabowski Approve
MAAS Lander Approve
Jacopo Rota Pending
Review via email: mp+466627@code.launchpad.net

Commit message

fix(agent): create runDir if it doesn't exist

Description of the change

For SNAP install this folder is created by chrony, because chrony will create a
full path as defined for the PID file in the config [0]

We should not rely on chrony

if "SNAP" in os.environ:
    run_dir = get_maas_run_path()
    lines.append(f"dumpdir {run_dir / _NTP_DIR_NAME}")
    lines.append(f"pidfile {run_dir / _NTP_PID_NAME}")
    lines.append(f"bindcmdaddress {run_dir / _NTP_SOCK_NAME}")

[0]: src/provisioningserver/ntp/config.py

To post a comment you must log in.
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b agent-create-rundir lp:~troyanov/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: 59c39829115c278d81d2685ee6e2f5ce92a55e7e

review: Approve
Revision history for this message
Christian Grabowski (cgrabowski) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasagent/cmd/maas-agent/main.go b/src/maasagent/cmd/maas-agent/main.go
2index c6b7f01..64faca8 100644
3--- a/src/maasagent/cmd/maas-agent/main.go
4+++ b/src/maasagent/cmd/maas-agent/main.go
5@@ -150,8 +150,20 @@ func Run() int {
6 return 1
7 }
8
9+ runDir := getRunDir()
10+
11+ _, err = os.Stat(runDir)
12+ if os.IsNotExist(err) {
13+ err = os.Mkdir(runDir, os.ModeDir|0755)
14+ }
15+
16+ if err != nil {
17+ log.Error().Err(err).Send()
18+ return 1
19+ }
20+
21 powerService := power.NewPowerService(cfg.SystemID, &workerPool)
22- httpProxyService := httpproxy.NewHTTPProxyService(getRunDir(), cache)
23+ httpProxyService := httpproxy.NewHTTPProxyService(runDir, cache)
24
25 workerPool = *worker.NewWorkerPool(cfg.SystemID, temporalClient,
26 worker.WithMainWorkerTaskQueueSuffix("agent:main"),

Subscribers

People subscribed via source and target branches