1007 Commits

Author SHA1 Message Date
Ian Johnson
d3acb1f9fb Merge branch 'release/2.51' into release-2.51.7-changelog-for-2.52
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-08-27 18:04:06 -05:00
Michael Vogt
5d40d047af store: deal correctly with "assumes" from the store raw yaml
Our code did not deal with the `assumes:` field in the raw yaml
that we get from the store. This lead to the really nasty bug
that on a refresh the assumes is not checked correctly, see
https://bugs.launchpad.net/snapd/+bug/1940553
2021-08-24 14:46:24 +02:00
Ian Johnson
358da8e91f store/download_test.go: simplify test, add more comments
* We don't need to create the parent directory of exeInCorePath, since we don't
  actually need to create the exeInCorePath file at all for the test.
* We also don't need to create the interpInCorePath parent directory because it
  is created by MockCommand() since interpInCorePath is an absolute file path.
* Add a comment about the restore for where the hostXdelta3Cmd is located for
  clarity.
* Add a comment about the realism of the test and how it's not a necessity, but
  is nice to have anyways.
* Add coreInterpCmd.Restore(), even though it is largely unnecessary.
* Sanity check that the test scenario makes sense, if we didn't want deltas,
  then either they should have been disabled explicitly through the environment
  variable, or there should not have been both binaries mocked.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-14 15:54:35 -05:00
Ian Johnson
d2d692a706 store: refactor xdelta3 caching
* Make the caching of the xdelta3 command a callback function that can be
  called instead of a location, since in the case when we are executing from
  the system snap, we will have additional arguments we need to pass to the
  interpreter for the system snap in addition to calling the interpreter. This
  also ensures that the working directory the command is run in and the
  environment for the command that is returned from CommandFromSystemSnap is
  saved as well if that is needed.
* Mock snapdtool.CommandFromSystemSnap in store package so we avoid the ELF
  parsing which is architecture dependent - this is already tested in the
  snapdtool package, so testing the real codepath here too is a bit over the
  top and would make the test unnecessarily complicated when the test is
  already fairly complicated as-is.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-14 10:48:34 -05:00
Ian Johnson
a479b4840f store/store_download.go: use system snap provided xdelta3 priority + fallback
Prefer using xdelta3 from the system snap if it is available and we are able to
run the config subcommand successfully. This ensures that we try to use a known
good xdelta3 command which should always work with what the store sends down,
but does still offer the fallback of using xdelta3 from the host system if for
some reason the xdelta3 command from the system snap becomes broken at some
point. In that case, attempt using the xdelta3 command from the host system,
performing the same config check before assuming that it is usable.

This has the effect that on older systems like Centos 7 and Amazon Linux 2,
where for example xdelta3 from the distro does not support LZMA, when a delta
generated using LZMA is encountered, we will first try the system snap provided
xdelta3 which should succeed.

We also cache the result of inspecting the available xdelta3 commands, to
prevent unnecessary commands.

Finally, log more messages, namely that if applying the delta fails, log the
error condition as a message so someone with log access can provide information
as well as log if we find an unsuitable xdelta3 somewhere (either from the
system snap, or from the host system). All of these should aid in debugging
future delta issues if they happen to crop up.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2021-07-13 19:35:22 -05:00
Pawel Stolowski
26afc8f3f0 store: set ResponseHeaderTimeout on the default transport
It appears that ResponseHeaderTimeout needs to be set explicitly, no headers response from the server doesn't seem to be covered by any other timeout.

This should fix the download getting stuck issue.

For more context, see the stacktrace obtained from a system where download got stuck: https://pastebin.canonical.com/p/nZkRMTBbv3/
(the affected goroutine seems to be sitting inside for-select loop of /usr/lib/go-1.10/src/net/http/transport.go:2033)

(to play with it comment out ResponseHeaderTimeout: ... from transport.go and modify test timeout from 5 * time.Second to a huge value and it should be stuck)

* Set ResponseHeaderTimeout on the default transport.

* Use 250ms for mocked ResponseHeaderTimeout.

* Bump ResponseHeaderTimeout to 15s.

* Bump test timeout to avoid potential issues with LP builds.
2021-07-13 11:21:22 +02:00
Pawel Stolowski
c8122fc15a store: set ResponseHeaderTimeout on the default transport
It appears that ResponseHeaderTimeout needs to be set explicitly, no headers response from the server doesn't seem to be covered by any other timeout.

This should fix the download getting stuck issue.

For more context, see the stacktrace obtained from a system where download got stuck: https://pastebin.canonical.com/p/nZkRMTBbv3/
(the affected goroutine seems to be sitting inside for-select loop of /usr/lib/go-1.10/src/net/http/transport.go:2033)

(to play with it comment out ResponseHeaderTimeout: ... from transport.go and modify test timeout from 5 * time.Second to a huge value and it should be stuck)

* Set ResponseHeaderTimeout on the default transport.

* Use 250ms for mocked ResponseHeaderTimeout.

* Bump ResponseHeaderTimeout to 15s.

* Bump test timeout to avoid potential issues with LP builds.
2021-07-13 11:21:01 +02:00
Michael Vogt
ce287c4603 Merge remote-tracking branch 'upstream/master' into clearly-sections-err 2021-06-29 12:14:28 +02:00
Michael Vogt
9c8b105bf8 Merge pull request #10466 from pedronis/contact-accessor
many: turn Contact into an accessor
2021-06-29 09:30:26 +02:00
Maciej Borzecki
3adf74e9fd store: make the log with download size a debug one
The log appears is visible in the user's terminal when running `snap download`
command.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-06-28 16:10:35 +02:00
Samuele Pedroni
9242fb8256 many: turn Contact into an accessor
as later it will be derived from links and also we will have
to deal with links from store response vs snap.yaml
2021-06-25 19:10:08 +02:00
Maciej Borzecki
b9967aa462 store: make the log with download size a debug one
The log appears is visible in the user's terminal when running `snap download`
command.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2021-06-25 16:08:18 +02:00
Michael Vogt
e0c46ab4e7 store: tweak error message when store.Sections() download fails
The current error when the store.Sections() download fails is:
```
Catalog refresh failed: cannot sections...
```
which is not great. This commit changes it to:
```
Catalog refresh failed: cannot retrieve sections
```
which reads a bit better.
2021-06-25 10:05:45 +02:00
Samuele Pedroni
54e84fb8db many: fix imports order (according to gci)
had to make the comment in wrappers/services_test.go a one-liner
otherwise half of it is lost

last set of files needing changing (as per current master)
2021-06-16 09:54:31 +02:00
Samuele Pedroni
b37d6735a4 many: add SnapExists to StoreService 2021-06-14 10:04:44 +02:00
Samuele Pedroni
27184537ba store: implement Store.SnapExists
This is a more targeted/cheaper variant of SnapInfo that only
checks for existence and returns the default channel of the snap.
2021-06-14 10:04:44 +02:00
Paweł Stołowski
d09cd35c16 Fix fmt. 2021-06-07 14:31:58 +02:00
Paweł Stołowski
583ecec024 Add extra comments, tweak vsets arg name. 2021-06-07 14:31:58 +02:00
Paweł Stołowski
3f2fdd111d Extend context and action objects of SnapAction with optional
validation-sets field.
2021-06-07 14:31:58 +02:00
Paweł Stołowski
0d505d709c Fix typo in snapActionResult struct json tag. 2021-06-02 17:00:22 +02:00
Paweł Stołowski
29616a7102 Tweak 'unexpected..' log message to use uppercase, add else (thanks
pedronis).
2021-05-27 11:11:28 +02:00
Paweł Stołowski
d493baeed7 Use noticef for download size. 2021-05-27 11:03:34 +02:00
Paweł Stołowski
6e5f266557 downloadImpl: clean up error messages (no punctuation at the end, no
caputal letters). Switch to io.Seek* constants from the deprecated
os.SEEK_*. Add extra log message about download size.
2021-05-27 11:02:30 +02:00
Paweł Stołowski
96e6a60e31 Internal error if sequence is <= 0 while revision was specified. 2021-02-10 10:28:48 +00:00
Paweł Stołowski
0bb8b43beb Tweak the order of assertSeqAtJSON fields. Add missing test for
sequence-related error other than not-found (thanks pedronis).
2021-02-10 10:03:57 +00:00