I’m looking for a way to prevent my devices from downloading updates when on a metered connection. My fleet will be connected through 4G most of the time, but WiFi will be available at times, as the device is moved around by the end user.
I want to implement some way to make sure the data consumption through 4G is limited, because this can become really expensive very quickly at 10 cents per MB (in some countries). I thought implementing the application update lock would be enough but I just noticed the line
The presence of a lockfile will ensure that your application does not get killed, but updates will still be downloaded by the supervisor, ready to be applied once the lockfile no longer exists.
This is exactly what I don’t want. When on a metered connection (which is configured as such in NetworkManager so it can be read through dbus), the supervisor should not start downloading new images. Furthermore, it should stop active downloads whenever the primary connection changes to a metered connection and resume or restart when the the primary connection is not metered anymore. When a new image is downloaded, I don’t mind it being installed, even when on a metered connection, as this doesn’t consume any more data.
I know I can pin a device to a specific release through the API, and implement some logic to make sure this only jumps to the latest version whenever the device is connected through WiFi, but this doesn’t help in case the device is then moved back to the 4G connection just after, especially with large updates.
Does anyone have any experience with implementing something like this? Is it even possible?