pulumi/pkg/util/nosleep
Thomas Gummerer 0626aa3261
try to prevent systems from going to sleep during pulumi operations (#17675)
Most operations that pulumi does are long running operations.  At the
same time modern computers have sometimes pretty agressive power
saving methods.  These are however not great while a pulumi operation
is running, as interrupting an operation in the middle can lead to
half set up resources, and leases timing out.

In particular we have a lease with the pulumi service that needs to be
renewed quicker than every 5 minutes.  If the computer running the
update goes to sleep, cloud infrastructure might get set up, but never
stored in the state (see https://github.com/pulumi/pulumi/issues/7094).

We can help the users here and make a best effort to prevent the
system from going to sleep.  Various operating systems have different
APIs for this.  Unfortunately I couldn't find a package that wraps
this neatly, so I implemented this taking inspiration from the wakepy
python package:
https://wakepy.readthedocs.io/stable/methods-reference.html#wakepy-methods.

We ignore all errors in setting up this power management, since it may
not be available in some environments, but pulumi will continue
functioning (mostly) correctly no matter if this is set up or not.

For now this is only implemented for updates going through the cloud
backend, though there's nothing preventing us from extending it to the
DIY backend as well.

Hopefully fixes https://github.com/pulumi/pulumi/issues/7094 in
conjunction with https://github.com/pulumi/pulumi/pull/17519

Addresses part of https://github.com/pulumi/pulumi/issues/10279
2024-11-05 19:08:59 +00:00
..
darwin.go try to prevent systems from going to sleep during pulumi operations (#17675) 2024-11-05 19:08:59 +00:00
nosleep.go try to prevent systems from going to sleep during pulumi operations (#17675) 2024-11-05 19:08:59 +00:00
unix.go try to prevent systems from going to sleep during pulumi operations (#17675) 2024-11-05 19:08:59 +00:00
windows.go try to prevent systems from going to sleep during pulumi operations (#17675) 2024-11-05 19:08:59 +00:00