8 Commits

Author SHA1 Message Date
Maciej Borzecki
61d7eba0cd daemon, cmd/snapd: propagate context (#14130)
* daemon: establish a cancelation chain for incoming API requests

Establish a cancelation chain for incoming API requests, to ensure orderly
shutdown. This prevents a situation in which an API request, such as notices
wait can block snapd shtudown for a long time.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* daemon: return 500 when the request context gets canceled

Request's can be canceled based on the code actually issuing a cancel on the
associted context, hence an Internal Server Error seems more appropriate.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* o/snapstate: leave TODOs about using caller provided context

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* daemon: pass down request context where possible

Pass the context from the API request further down.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* daemon: set context in snap instruction for many-snap operation

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* daemon: pass context as an explicit parameter to request handlers

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* daemon: pass context

Thanks to @ZeyadYasser

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* daemon: comment on Start() taking a context.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* daemon: add unit tests targeting context passed to Start()

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

* daemon: drop unit test for hijacked context

The test isn't very useful. Another option to trigger this would be to call
Stop() without a prior call to Start(), but this segfaults on
d.standbyOpinions.Stop(), so it'c clear this needs a followup fix or callign
Stop() this way isn't supported.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>

---------

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-06-28 14:54:52 +02:00
Samuele Pedroni
716b13b5f9 daemon: simplify SyncResponse
it doesn't take Meta anymore
2021-06-03 13:49:26 +02:00
Samuele Pedroni
d1142a0f26 daemon: switch api_find.go/api_sections.go to apiError
also introduce BadQuery error responder for use in both
2021-06-01 18:48:44 +02:00
James Henstridge
eebe1636b2 Merge remote-tracking branch 'upstream/master' into daemon-access-check 2021-04-07 17:02:42 +08:00
Samuele Pedroni
d0a7d7f357 daemon: rename getStore to storeFrom 2021-03-16 11:42:38 +01:00
Samuele Pedroni
926de177e3 daemon: change getStore(*Command) -> getStore(*Daemon)
this helps avoiding passing *Command around which complicates exposing
helpers if they actually want to be tested

with this we don't need to export ThemesCmd to the tests anymore
2021-03-16 11:42:38 +01:00
James Henstridge
885de6ed72 Merge remote-tracking branch 'upstream/master' into daemon-access-check 2021-01-04 15:28:41 +08:00
Samuele Pedroni
0c2c351efe daemon: split out sections support to api_sections.go
apparently this had no tests so far, added a TODO for now
2020-12-08 09:53:13 +01:00