balena-labs-projects / rosetta-at-home

80 stars 17 forks source link

Investigate ways to improve power management for old laptops #16

Open chrisys opened 4 years ago

chrisys commented 4 years ago

With the current implementation of power-management, there are cases where if a laptop is closed and that container stops (for reasons such as update), the device could fall into a sleep state.

To quote @rahul-thakoor "if the power-management service dies, the lock for the file descriptor is released and the action is removed!"

rahul-thakoor commented 4 years ago

This is currently achieved using dbus and systemd inhibit locks. We are using handle-lid-switch in block mode which inhibits the low-level handling of the systemd hardware lid switch.

From the documentation,

Inhibit() returns a single value, a file descriptor that encapsulates the lock. As soon as the file descriptor is closed (and all its duplicates) the lock is automatically released. If the client dies while the lock is taken the kernel automatically closes the file descriptor so that the lock is automatically released.

The current problem is the container creating the lock can die for e.g during an update and cause the lock to be released.

chrisys commented 4 years ago

This should be resolved by setting RESIN_SUPERVISOR_UPDATE_STRATEGY to hand-over

rahul-thakoor commented 4 years ago

Tested on device running intel-nuc image