thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
219 stars 54 forks source link

support caching artifacts for child devices/services #2798

Open reubenmiller opened 5 months ago

reubenmiller commented 5 months ago

Is your feature improvement request related to a problem? Please describe.

Installing firmware/software/configuration on child devices requires the child device to download the given url directly from the internet, or via the c8y proxy service (which requires internet). Both of these downloads means that the child device needs to support retries and resuming of the download which is sometimes not feasible for devices such as microcontrollers.

Describe the solution you'd like

thin-edge.io should support a mechanism where the child device can request thin-edge.io to download and cache the artifact so that the child device only has to download the artifact via a local cache.

The caching mechanism should be supported on any of the commands (e.g. firmware/software/configuration).

Describe alternatives you've considered

Additional context

didier-wenzek commented 3 months ago

The PR introducing support for log and config operation workflows, also introduced a regression bypassing file cache for config update.

We must re-introduce this ability:

Proposal

Introduce a new file_cache operation:

Pros:

Cons:

Alternatives:

  1. Make this operation a plain operation only available on the main device.
    • In that case, the workflow mechanism must be extended with the ability to trigger an operation on another device
  2. Use a request / response pattern with two topics te/device/main///req/file-cache and te/device/main///res/file-cache
    • The workflow mechanism must be extended to trigger such operation.
  3. Extend the file transfer service with a POST command to upload a remote resource and to make it available locally.
    • But then how to tell the requester that the resource has been fully downloaded and is locally available?
    • By keeping the connection open till ready?
    • With a combination of 202 (Accepted) and polling?
    • With a combination of 202 (Accepted) and MQTT messaging ?
reubenmiller commented 3 months ago

This is not a true command: there is no capability message and its execution model is unusual (handled by the main agent whatever the requesting device).

Technically, there is nothing stopping the component from publishing a capability message, as that would have the benefit of formerly declaring the ability to provide a caching functionality, so that components know whether they should try to create the operation message or not