k3s/pkg/controller/volume/attachdetach/cache
Jing Xu 14cad206f5 Fix race conditino in setting node statusUpdateNeeded flag
This PR fixes the race condition in setting node statusUpdateNeeded flag
in master's attachdetach controller. This flag is used to indicate
whether a node status has been updated by the node_status_updater or
not. When updater finishes update a node status, it is set to false.
When the node status is changed such as volume is detached or new volume
is attached to the node, the flag is set to true so that updater can
update the status again. The previous workflow has a race condition as
follows
1. updater gets the currently attached volume list from the node which needs to be
updated.
2. A new volume A is attached to the same node right after 1 and set the
flag to TRUE
3. updater updates the node attached volume list (which does not include volume A) and then set the flag to FALSE.
The result is that volume A will be never added to the attached volume
list so at node side, this volume is never attached.

So in this PR, the flag is set to FALSE when updater tries to get the
attached volume list (as in an atomic operation). So in the above
example, after step 2, the flag will be TRUE again, in step 3, updater
does not set the flag if updates is sucessful. So after that, flag is
still TRUE and in next round of update, the node status will be updated.

This PR also changes a unit test due to the workflow changes
2016-09-22 14:02:30 -07:00
..
actual_state_of_world.go Fix race conditino in setting node statusUpdateNeeded flag 2016-09-22 14:02:30 -07:00
actual_state_of_world_test.go Fix race conditino in setting node statusUpdateNeeded flag 2016-09-22 14:02:30 -07:00
desired_state_of_world.go Post event message for volume attachment 2016-09-01 16:24:36 -07:00
desired_state_of_world_test.go Reorganize volume controllers and manager 2016-07-01 18:50:25 -07:00