* o/snapstate: replace some args to doInstallComponent with a flags type
* o/snapstate: create validate-component task when installing component from the store
* o/snapstate: add arg to doInstall for components
* o/snapstate: install components from store in StoreTarget
* o/snapstate: add component fields to fakeSnappyBackend ops
* o/snapstate: add helpers for checking tasks for installing components
* o/snapstate: add testing channel that adds a component to snap that is being installed
* o/snapstate: use instance name in path to that is set for remove ops in test backend
* o/snapstate: extend doInstall to handle components
* o/snapstate: refactor addTask in doInstall to update prev pointer to eliminate manual tracking of last task
* o/snapstate: test tasks created when installing component from the store
* o/snapstate: remove component files when snap file is also ephemeral
* o/snapstate: change component types in error strings to be more clear
* o/snapstate: always install components for each snap in a consistent order
* o/snapstate: replace pointer params to doInstall with copies
* o/snapstate: unexport componentTarget
* o/snapstate: add TODOs about handling components
* o/snapstate: add comment explaining why we do not create setup-profiles task for new components when installed with snap
* o/snapstate: remove usage of new go stdlib function
* o/snapstate: fully initialize ComponentSetup in store's InstallGoal implementation
* o/snapstate: rename componentInstallFlags.SkipSecurity to SkipProfiles
* o/snapstate: move componentTarget struct
* o/snapstate: eliminate componentTarget type
* store, o/snapstate: swap out resources slice in SnapAction for flag in RefreshOptions
* o/snapstate: remove this change for now, it should not be a part of this PR
* o/snapstate: add TODO about ordering component and snap hook tasks
* o/snapstate: rename variable for readability
* store: add resources to snap action results
* store: parse resources into snap components in store responses
* store: only request resources in SnapAction if one of the actions includes resources
* snap: add function for converting a string to a ComponentType, with checks
* store: explictly ignore unknown component types
* store: remove usage of strings.CutPrefix
* store: add comment noting that resources do not have download deltas
* snap: correct doc comment on ComponentTypeFromString
* store: remove incorrect usage of description in component summary
Refreshes of essential snaps are organised to have a single reboot.
However, on classic systems with kernel/gadget snaps this means that
apps must wait for the essential snaps and therefore for a reboot. To
prevent apps from blocking until then, this change splits a refresh into
two tasksets. One with essential snaps which is still organised
according to the single reboot and another with apps and their bases
which can complete before the reboot. Some constraints on this are snapd
which is always refreshed first and apps that depend on the model base.
In those cases, we add dependencies across essential/non-essential sets.
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Skip download speed monitoring unit tests if SNAPD_SKIP_SLOW_TESTS is set. The
test is based on getting the timings right and so it becomes generally
unreliable when running in super slow environment, such as a build VM in OBS,
thus failing like so:
```
[ 2317s] ----------------------------------------------------------------------
[ 2317s] FAIL: store_download_test.go:886: storeDownloadSuite.TestTransferSpeedMonitoringWriterHappy
[ 2317s]
[ 2317s] store_download_test.go:903:
[ 2317s] c.Check(store.Cancelled(ctx), Equals, false)
[ 2317s] ... obtained bool = true
[ 2317s] ... expected bool = false
[ 2317s]
[ 2317s] store_download_test.go:904:
[ 2317s] c.Check(w.Err(), IsNil)
[ 2317s] ... value *store.transferSpeedError = &store.transferSpeedError{Speed:0} ("download too slow: 0.00 bytes/sec")
[ 2317s]
[ 2317s] store_download_test.go:907:
[ 2317s] // we should hit at least 100*5/50 = 10 measurement windows
[ 2317s] c.Assert(w.MeasuredWindowsCount() >= 10, Equals, true, Commentf("%d", w.MeasuredWindowsCount()))
[ 2317s] ... obtained bool = false
[ 2317s] ... expected bool = true
[ 2317s] ... 9
```
Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
* many: allow building without bolt using nobolt tag
Bolt is an abandoned project. Upstream is not accepting any patches.
Debian has three versions of bolt, none of which build on riscv64 due to
the lack of appropriate architecture tags.
In Debian, bolt is not built from the vendored package but instead from
the distribution package, one of three in the archive, each capturing a
different, outdated and differently patched fork.
Fortunately, bolt is not really heavily used in snapd. While we try to
address the issue regarding bolt and riscv64, we can continue to build
snapd on riscv64 without the ability to store information only used by
command-not-found helpers.
Allow advisor to fail with advisor.ErrNotSupported when snapd is built without
bolt support. Tests for the store, overlord package and the "snap advise"
command are adjusted to skip certain tests when that error is returned.
Debian-Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010686
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
* advisor: adjust error message
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
* tests: run unit tests for nobolt build tag
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
* packaging: drop bolt from debian dependencies
With the ability to build snapd without bolt support, we can drop the patch
responsible for using non-forked bolt. Bolt is really only needed by the
advisor package, which is used and consumed as a command-not-found data set.
None of that is effective on Debian, making maintenance easier.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
* packaging: do not use bolt on Debian
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
---------
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
* o/c/configcore: add store.access configurable to allow store access to be disable
* o/devicestate: expose store.access via the storeContextBackend
* overlord,o/storecontext: expose store.access via storecontext.storeContext
* store: use store.access to disable access to snap store when using methods store.Store
* configcore: add tests for validation of store.access
* store: test offline store functionality
* o/storecontext: add test case for StoreAccess
* store, o/c/configcore, o/storecontext: remove usage of online as valid value for store.access
* store: correct ErrStoreOffline message
* store: add unit test to check that http retries do not happen when store is offline
* store: rename isStoreOnline to checkStoreOnline for consistency
* store: remove outdated comment
* o/c/configcore: convert handleStoreAccess to be a fsOnlyHandler since it does not need state
* store: disable more instances of store network access
* overlord,o/storecontext: combine ProxyStoreer and StoreAccessQuerier into one interface
* o/devicestate: add test for storeContextBackend.StoreAccess
* store: modify Store.endpointURL to check if the store is offline
* o/storecontext: simplify TestStoreAccess test case
* store: make Store.assertionsEndpointURL return an error if the store is offline
* store: add more test cases for an offline store
* o/devicestate: remove outdated comment
* store: remove outdated comment
* store: fix outdated comments
* store: test that SnapAction returns an error when the store is offline
* store: clarify ErrStoreOffline message
* o/c/configcore: move store.access registration for more general use
* o/c/configcore, dirs: write config file for snap-repair in store.access handler
* cmd/snap-repair: consume snap repair config file to check if store access is offline
* overlord: remove accidental goimports change
* image: set root dir to temp dir for tests
* o/c/configcore: remove build flags from store.go
* store: rename checkStoreOnline to checkStoreOffline for consistency
* Revert "store: rename checkStoreOnline to checkStoreOffline for consistency"
This reverts commit dd07e487127964c417eeac11d1d954a5d1132469.
* cmd/snap-repair, o/c/configcore: use unexported repairConfig for configuring snap-repair
* o/c/configcore: fix broken test following type rename
* o/c/configcore: remove defined error to make future modifications less error-prone
* o/c/configcore: remove superfluous $
* store, o/devicestate, o/storecontext: change StoreAccess methods to StoreOffline methods that return a boolean indicator
* dirs, o/c/configcore: make sure to check fsOnlyContext for a different root dir
* cmd/snap-repair: move this change into a seperate PR
* o/c/configcore: fixup some comments
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* o/c/configcore: add test for setting store.access on filesystem only apply
---------
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
Replace ioutil.WriteFile with os.WriteFile since the former has been
deprecated since go1.16 and simply calls the latter.
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
* snap, store: avoid invalid snap edited links from store
* snap, store: extend unit tests
* snap, store, o/snapstate: remove temporary comments
* store: add test case for empty link from store
* snap, store: changed how edited links from store are normalized
"held" is supported starting v54 of the store API. Some store proxies might
be running older versions of the store which will fail with: "Additional
properties are not allowed ('held' was unexpected)".
This approach retries bad requests, with the new knowledge of the store
version parsed from the response header ""Snap-Store-Version"" and removes
the "held" field if store version is less than v54.
This approach is generic and can be used for other new fields using
minStoreVersion(storeVer, <MIN_VER>).
* o/snapstate: make debug message consistent and store version check explicit
* o/snapstate: check Snap-Store-Version header is valid for retry logic and fix typo in test name
* o/snapstate: extract refresh hold retrieval into a helper function
* o/snapstate: move effectiveRefreshHold to autorefresh.go
* o/snapstate: bump store api requirement to v55 for held field support
* v55 includes bug fixes related to held field
Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
The store option that controls whether requests carry the "Scheduled"
header will soon be on for non-continued auto-refreshes. This renames
the field to avoid a mismatch between its name and when it's set.
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
* image, store/tooling: fix how validation-sets and required revision was set for snaps that were controlled by validation-sets. Mirror how it's done for the snap validate --refresh.
* image: fix unit tests and optimize a bit how many times we call validationSetsAndRevisionForSnap
* image: wrong revision in comment
* image: review feedback, add TODO around missing logic for optional snaps, and add unit test for conflict logic that is now added
* image: review feedback, be a bit more consistent in naming between keys and actual validation-set objects
* image: pass validation-sets to store functions
* image: get fetched validation set assertions and use them for keys to store
* image: add additional check to unit test
* image: move seed database into imageSeeder structure
* image: fix unit test
* store: Return categories in find results
This allows clients to show the categories as snapcraft.io does.
Fixes https://bugs.launchpad.net/snapd/+bug/1838786
* Remove unnecessary CategoryInfos type
* Only show categories when using --verbose
* Add tests for snap info printing categories
* Update cmd/snap/cmd_info.go
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* Update cmd/snap/cmd_info.go
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* v1 store API doesn't return categories
* Drop category information from snap info
Other snap commands don't support categories yet, this change should be part of that.
* Add /v2/categories and support /v2/find?category=foo
* Add note that section is deprecated
* Update client/packages.go
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* Update daemon/api_categories.go
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* Update daemon/api_categories.go
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* Update daemon/api_categories.go
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* Update store/store.go
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* Update store/details_v2.go
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* Update client/packages.go
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
* Improve test error message
* Drop copy/pasted comments that doesn't seem relevant
* Remove unused import
* Reorder CategoryInfo struct
* Fix accepted content type for store v2/snaps/categories request
* Set APILevel for v2/snaps/categories request
* Update accept string used to get data for store test
* Make /v2/categories return objects not just strings
---------
Co-authored-by: Miguel Pires <miguelpires94@gmail.com>