Skip to content

Commit 4ddff7a

Browse files
committed
Small refactoring of retention
1 parent 93ee6d9 commit 4ddff7a

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var runCmd = &cobra.Command{
7979
gcRootsDir := path.Join(cfg.StateDir, "gcroots")
8080
broker := brokerPkg.New()
8181
broker.Start()
82-
store, err := storePkg.New(broker, storeFilename, gcRootsDir, cfg.Retention.MaxBootEntries, cfg.Retention.MaxDeploymentEntries)
82+
store, err := storePkg.New(broker, storeFilename, gcRootsDir, cfg.Retention.KeepBootEntries, cfg.Retention.KeepDeploymentEntries)
8383
if err != nil {
8484
logrus.Error(err)
8585
os.Exit(1)

docs/howtos.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,30 @@ services.comin = {
9595

9696
Please note this is currently not supported by for nix-darwin configurations.
9797

98-
## Profile retention policy
99-
100-
comin tracks deployments in order to manage system profiles. This
101-
allows to control the number of boot entries and the number of Nix
102-
store roots. It is then possible to control the size of the Nix store
103-
(by activating the `nix.gc.automatic` module).
104-
105-
First of all, comin preserves the booted system in the boot entries menu.
106-
107-
You can then control the number of boot entries and the number of
108-
previous deployments kept in the comin deployment history. Two
109-
configuration options allow to control the retention:
110-
111-
- `retention.max_boot_entries`: the maximum number of last boot entries
112-
- `retention.max_deployment_entries`: the maximum number of last
113-
deployment entries in the comin deployment history
114-
98+
## Deployments and profiles retention policy
99+
100+
comin tracks deployments in its persisent storage. It uses this list
101+
to add and remove system profiles which are consumed by bootloaders to install
102+
boot menu entries.
103+
104+
The goal of the retention policy is to
105+
1. keep the currently booted system, in order to always be able to rollback on reboot
106+
2. keep the currently switched system
107+
3. keep a configuration quantity of successful deployments leading to a boot menu entries (typically, `boot` and `switch` deployments).
108+
This is configuration thanks to `retention.keepBootEntries`
109+
4. keep a configuration quantity of deployments to provide an history to the user
110+
This is configuration thanks to `retention.keepDeploymentEntries`
111+
112+
Thanks to this retention policy, you could then enable the
113+
`nix.gc.automatic` module to automatically clean up your Nix store,
114+
while preserving a configurable gcroot history.
115+
116+
Note that your bootloader entries shows one more entries than the ones
117+
listed by `comin deployment list`. This is currently a comin
118+
implementation limitation. Comin first creates a deployment, deploys it and
119+
if it has been successfully deployed, it can remove older deployments,
120+
accordingly to the retention policy. However, when it removes the
121+
deployment, it currently doesn't reinstall the bootloader.
115122

116123
## What happen on /var/lib/comin deletion
117124

@@ -125,6 +132,6 @@ the consequencies:
125132
CVEs.
126133
- comin no longer knows the deployment history. On the next
127134
deployment, it would then no longer able to generate boot entries
128-
for previous deployments. So, even if you delete the
135+
for previous deployments. However, if you delete the
129136
`/var/lib/comin` directory, the current booted entry would still be
130137
present in the boot menu.

internal/types/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ type Confirmer struct {
5656
}
5757

5858
type Retention struct {
59-
MaxBootEntries int `yaml:"max_boot_entries"`
60-
MaxDeploymentEntries int `yaml:"max_deployment_entries"`
59+
KeepBootEntries int `yaml:"keep_boot_entries"`
60+
KeepDeploymentEntries int `yaml:"keep_deployment_entries"`
6161
}
6262

6363
type Configuration struct {

nix/module-options.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,18 @@ in {
305305
default = {};
306306
type = submodule {
307307
options = {
308-
max_boot_entries = mkOption {
308+
keep_boot_entries = mkOption {
309309
type = int;
310310
default = 2;
311311
description = ''
312-
The maximum number of boot entries to keep. note that the booted system is always preserved in the boot menu.
312+
The number of boot entries to keep.
313313
'';
314314
};
315-
max_deployment_entries = mkOption {
315+
keep_deployment_entries = mkOption {
316316
type = int;
317-
default = 5;
317+
default = 3;
318318
description = ''
319-
The maximum number of deployments entries to keep.
319+
The number of deployments to keep.
320320
'';
321321
};
322322
};

0 commit comments

Comments
 (0)