Remote dev implement full resync
What does this MR do
- Implements full sync of workspace as covered here
- Added spec to verify the implemented logic in
module_test.go
- Since implementing full_sync requires stopping and starting workers,
Stop()
has been added to theremoteDevWorker
interface to allow an outgoing worker to cleanup as its shutting down. More concretely, it is need to stop the informer for the outgoing worker. - Replace
log
package withzap.Logger
ink8s_informer.go
- Added support for
workspace_full_sync
message type and renamed existingworkspace_updates
toworkspace_partial_sync
- Refactored the logic in
module.Run
logic to fix a bug and introducedstoppableTask
. The initial goal was to fix a bug inmodule.go
below
Bug description
- If the
cfg
channel is closed any time after L43 is in execution, the program will hang because the deferred cancel will never get to execute because of thewg.Wait()
at L59 - While I'm not sure if this can occur in production, it can and did occur in my local environment as I was debugging failing test cases
- The initial fix was straightforward i.e just put a cancel call at L58 before the
wg.Wait()
, however I refactored it into a separateStoppableTask
abstraction since it seemed like what the intent was anyway -
StoppableTask
is also re-used ink8s_informer
Edited by Hunar Khanna