The multipart stdlib writes formdata file parts (above a limit) to
/tmp and that could exceed the available space on devices using tmpfs.
The files would then be copied from /tmp to /var/lib/snapd/snaps.
This change adds a custom form reader that reads non-file parts into
memory and writes file parts directly to /var/lib/snapd/snaps.
https://bugs.launchpad.net/snapd/+bug/1950190
this splits /v2/snaps GET and POST tests out of api_test.go
to api_snaps_test.go and api_sideload_n_try_test.go
api.go itself isn't split yet similarly but to clean test writing
two changes were made
* introduction of snapInstruction.dispatchForMany used in postSnaps
as well
* changed trySnap signature
some imports in api_snaps_test.go are commented out atm,
they were copied from api_test.go and most of them will likely
come back soon
APIBaseSuite will be used for a while both from daemon
an daemon_test, so opt to make some field exported
for now at least
also use AddCleanup more and correctly
some cleanups in api_users_test.go in preparation to make
live in daemon_test
This PR finalizes changes to the semantics of services as follows:
- when units for services are created on snap install/refresh (in link handler), systemd units are only created on disk but not immediately enabled.
- units are enabled later on start-snap-services. These two changes are reflected in wrappers/services.go and changes to AddSnapServies and StartServices.
- service commands executed from snap and snapctl are handled by new service-control-task. This unifies service handling for these commands as there are no ad-hoc calls to systemctl, but everything goes through wrappers. There is one task per snap in case of service commands affecting multiple snaps. The task carries snap name and affected services (if the list is empty, then all services of the snap are considered).
- for compatibility with old snapd though, old-style exec-command tasks are created alongside new type of tasks, but they have ignore flag set on them so new snapd skips them (logic for that landed already in cmdstate).
- disabled/enabled services are tracked with ServicesDisabledByHooks/ServicesEnabledByHooks in SnapState. This is needed for hooks that run between link-snap and start-snap-services, and may effect state of the services.
The test checks that flag set in installInstruction is transferred to
snapstate.Flags. This time for the snapUpdate code-path.
Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>