Skip to content

Commit 5b1a087

Browse files
committed
Switch to using a persistent folder for RAUC bundle downloads
1 parent 9b84713 commit 5b1a087

4 files changed

Lines changed: 26 additions & 8 deletions

File tree

base/default.nix

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,25 @@ with lib;
6262
User = "root";
6363
RestartSec = "10s";
6464
Restart = "always";
65+
ExecStartPre = "-${pkgs.writeShellScript "clear-state" ''
66+
rm -rf /var/lib/playos-controller/*
67+
rm -rf /var/lib/playos-controller/.*
68+
''}";
69+
StateDirectory = "playos-controller";
6570
};
6671
wantedBy = [ "multi-user.target" ];
6772
requires = [ "connman.service" ];
6873
after = [ "rauc.service" "connman.service" ];
6974
};
7075

76+
# Use the persistent partition for storing controller state only to avoid
77+
# storing the RAUC bundles in memory (tmpfs)
78+
playos.storage.persistentFolders."/var/lib/playos-controller" = {
79+
mode = "0755";
80+
user = "root";
81+
group = "root";
82+
};
83+
84+
7185
};
7286
}

controller/server/update_client.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ module type UpdateClientDeps = sig
1616
val get_proxy : unit -> Uri.t option Lwt.t
1717
end
1818

19-
let make_deps ?(download_dir = "/tmp") get_proxy base_url :
20-
(module UpdateClientDeps) =
19+
let make_deps ?download_dir get_proxy base_url : (module UpdateClientDeps) =
2120
(module struct
2221
let base_url = base_url
2322

2423
let get_proxy = get_proxy
2524

26-
let download_dir = download_dir
25+
let download_dir =
26+
let fallback_download_dir = "/tmp" in
27+
(* STATE_DIRECTORY is set by systemd when running controller as a service *)
28+
let state_dir = Sys.getenv_opt "STATE_DIRECTORY" in
29+
let state_or_fallback =
30+
state_dir |> Option.value ~default:fallback_download_dir
31+
in
32+
download_dir |> Option.value ~default:state_or_fallback
2733
end
2834
)
2935

testing/disk/default.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
, rescueSystem
99
, systemImage
1010

11-
, # Size of data partition in MiB
12-
dataPartSizeMiB ? 400
11+
, # The data partition needs to be big enough to store at least a single RAUC
12+
# bundle, which currently is ~1.4GB, + other cached/persisted stuff
13+
dataPartSizeMiB ? 2000
1314
}:
1415
with lib;
1516
let

testing/release-validation.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ pkgs.testers.runNixOSTest {
139139
virtualisation.qemu.networkingOptions = lib.mkOverride 0 [ ];
140140
virtualisation.sharedDirectories = lib.mkOverride 0 { };
141141

142-
# Note: this has to be at least 2x bundle size, otherwise
143-
# the bundle download will not fit into /tmp (which is defined
144-
# as 50% of RAM)!
145142
virtualisation.memorySize = lib.mkForce 4096;
146143

147144
virtualisation.vlans = [ 1 ];

0 commit comments

Comments
 (0)