241 Commits

Author SHA1 Message Date
Philip Meulengracht
e5c7631709 dirs,snap/sysparams: review feedback
check file-permissions and contents for the actual written file instead of mocking the write, add missing dots
2023-03-02 12:25:44 +01:00
Philip Meulengracht
367cd28628 snap/sysparams: introduce the sysparams package which is a helper for managing the system-params file which is used for homedirs configuration. 2023-03-02 12:25:44 +01:00
Philip Meulengracht
978b090415 many: a bit of code cleanup 2022-07-13 09:28:30 +02:00
Philip Meulengracht
550cf6d8bd overlord/snapstate: implement support for storing data onto ubuntu-save partition on a per-snap basis 2022-07-13 09:28:29 +02:00
Michael Vogt
e7df2b7a7e Revert "overlord,snap: add support for per-snap storage on ubuntu-save"
This reverts commit 8b1b0c44d9

It was merged accidently and prematurely.
2022-07-12 17:44:44 +02:00
Philip Meulengracht
8b1b0c44d9 overlord,snap: add support for per-snap storage on ubuntu-save
* interfaces/apparmor: add permissions for per-snap directory on ubuntu-save path

* overlord/snapstate: implement support for storing data onto ubuntu-save partition on a per-snap basis

* tests/nested/core/save-data: fix shellcheck warning

* many: a bit of code cleanup

* tests/nested/core/save-data: cleanup spread test

* many: fix unit tests that were failing, add additional unit test for new handlers

* tests/main/snap-env: fix spread test after adding a new ENV variable

* overlord/snapstate: minor cleanup

* overlord/snapstate: review feedback

remove the ubuntu-save task, move some of the functionality into the backend, add unit tests

* multiple: more changes, fix unit tests

* overlord/snapstate: additional unit tests

* tests: remove check that is no longer the case for non core platforms
2022-07-12 17:37:38 +02:00
Miguel Pires
7726a875ee dirs: fix formatting
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-07-12 13:48:09 +01:00
Alberto Mardegan
3c8bcee5eb dirs: remove unused SnapAppArmorAdditionalDir
The code using this variable got removed in 2016 with commit
c30beb3879.
2022-07-12 13:53:57 +02:00
Michael Vogt
aab86567dc Merge pull request #11038 from valentindavid/valentindavid/completion-writable-dir
many: install bash completion files in writable directory
2022-07-05 17:09:20 +02:00
Philip Meulengracht
db727242a2 overlord/ifacestate: fix path for journal redirect 2022-06-15 15:07:58 +02:00
Valentin David
a1cb7ae352 many: Install bash completion files in writable directory
Snapd installs bash completion files from snaps in
`/usr/share/bash-completion/completions` which in some distributions
is a read-only filesystem.

Instead of installing them in `/usr` we can install them within
`/var/lib/snapd` which should always be writable.

Because `/var/lib/snapd/desktop` is already in `XDG_DATA_DIRS`, we can
save the files there.

Because bash-completion 2.1 and prior do not support `XDG_DATA_DIRS`,
on older distributions, the legacy path
`/usr/share/bash-completion/completions` will still be used.
2022-06-03 10:38:37 +02:00
Philip Meulengracht
f25bbb4f09 dirs: add systemd root dir 2022-05-23 09:28:37 +02:00
Maciej Borzecki
a659de589a dirs: add /run dir
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2022-04-25 16:36:34 +02:00
Alberto Mardegan
97b3172313 dirs: remove unused SnapMetaDir variable
This is unused, and we do not have any "meta" dir under
"/var/lib/snapd/" since Snappy was removed in 2016 with commit
82c1b27bfe.
2022-03-16 09:33:25 +03:00
Miguel Pires
49913e30c8 dirs: rename ExposedHome const 2022-02-25 10:25:40 +00:00
Miguel Pires
09da26c79e dirs: improve documentation
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2022-02-23 13:01:38 +00:00
Miguel Pires
2415303172 o/snapstate: add ~/Snap init related to backend 2022-02-18 20:03:59 +00:00
Ian Johnson
bfe39efb39 Revert "o/servicestate: quota group error should be more explanative when memory cgroup is disabled"
This reverts commit d5eb40d189.

PR #11003 unfortunately introduced a regression on systems where the memory
cgroup was disabled because now servicestate.AllQuotas would return an error,
but we need to be able to access at least the quota group information in the
state in order to compute what options to generate services with in a few
places:

* in the ensure loop of the servicestate manager (runs all the time)
* in link-snap tasks (for snap installs/refreshes)
* in config tasks (for specifically the vitality-rank config setting)
* in discard-snap tasks (for snap removes)

So when the memory cgroup is disabled, all of the above things fail, including
catastrophically not being able to update the snapd snap (since snap refreshes
are now also broken), meaning that a user's device could not be fixed unless
they first re-enable the memory cgroup.

This will be un-reverted when we have added sufficient tests to demonstrate
that this memory cgroup check can be done in such a way without breaking this
functionality.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2022-02-03 10:48:47 -06:00
burak
d5eb40d189 o/servicestate: quota group error should be more explanative when memory cgroup is disabled
* added check for memory group statud (enabled/disabled) before any quota commands for bug: 1945370

* added check for memory group statud (enabled/disabled) before any quota commands for bug: 1945370

* moved the memory cgroup status check to servicestate

* removed memory cgroup check on the client

* merge error

* Update cmd/snap/cmd_quota.go

Co-authored-by: Maciej Borzecki <maciek.borzecki@gmail.com>

* Update overlord/servicestate/quota_control.go

Co-authored-by: Maciej Borzecki <maciek.borzecki@gmail.com>

* Update overlord/servicestate/quota_control.go

Co-authored-by: Maciej Borzecki <maciek.borzecki@gmail.com>

* updated the error flow structure

* fixed merge issue

* updated message for invalid configuration size and removed indentation

* Update overlord/servicestate/quota_control.go

Co-authored-by: Ian Johnson <person.uwsome@gmail.com>

* Update overlord/servicestate/quota_control.go

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

* moved cgroups file to dirs & made changes to the PR based on reviews

* added default file to make sure other tests using from global root don't fail

* updated the malformed cgroup test to have only 3 fields and minor changes

* corrected the quota control group size

* Update overlord/servicestate/quota_control.go

Co-authored-by: Maciej Borzecki <maciek.borzecki@gmail.com>

* Apply suggestions from code review

Co-authored-by: Maciej Borzecki <maciek.borzecki@gmail.com>

* removed unused import

* added test case for missing memory line

* removed the extra import coming from the use of check prefix

* updated variable names in test to remove _ prefix

* merged the latest master

Co-authored-by: Maciej Borzecki <maciek.borzecki@gmail.com>
Co-authored-by: Ian Johnson <person.uwsome@gmail.com>
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
2022-02-01 14:52:49 +01:00
Michael Vogt
c398a020ce devicestate: ensure permissions of /var/lib/snapd/void are correct
* devicestate: ensure permissions of /var/lib/snapd/void are correct

During the testflinger testing I saw some failures in the
`tests/main/cwd` test where the permissions of the
`/var/lib/snapd/void` directory are incorrect. On systems that
use packaging tools we force the permissions to be 0111 on each
refresh (see `debian/snapd.postinst`). However no such mechanism
exists on core devices. So if for some reason the permissions get
corrupted they never get fixed.

This commit adds code that ensures the permissions are fixed
automatically here too.
2022-01-27 21:18:32 +01:00
Alexey Shabalin
3535aa85a9 dirs: add altlinux to altDirDistros
Signed-off-by: Alexey Shabalin <a.shabalin@gmail.com>
2022-01-27 17:47:16 +03:00
Michael Vogt
167d216af8 Merge pull request #11146 from mardy/restore-snapd-failover-test
overlord: fix issue with concurrent execution of two snapd processes
2022-01-10 15:53:58 +01:00
Michael Vogt
3d76b0f16d Merge pull request #11118 from alfonsosanchezbeato/add-tmpfssize-opt
o/configstate/configcore: add tmpfs.size option
2021-12-17 12:09:12 +01:00
Alberto Mardegan
a956893aa0 overlord: hold a file lock to avoid concurrent snapstate access
There can be situations where there exist two snapd processes in the
system: that's the case when one of them is invoked as a subprocess by
the snap-failure systemd unit (which runs cmd/snap-failure/cmd_snap.go),
which we refer to as the "ephimeral snapd", and the other one is the
new, repaired snapd which is started by the ephimeral one. When this
happens, we do not want both of these processes to operate on the
snapstate at the same time; therefore, create a file-based lock to make
the accesses mutually exclusive.

A file-based lock will cause the second process to block and wait until
the lock is released (which can happen either as a result of an explicit
release operation, or at the termination of the process holding it). The
process starting snapd therefore needs to invoke the "systemctl start
snapd.service" command in non-blocking mode, or it would get itself
blocked, too.

Fixes: https://bugs.launchpad.net/snapd/+bug/1952404
2021-12-13 13:12:33 +03:00
Alberto Mardegan
0ba3dad616 interfaces/kmod/backend: add code for modprobe setup 2021-12-06 11:28:01 +03:00