Fix volume creation race + refactor (User)VolumeConfigController#12122
Fix volume creation race + refactor (User)VolumeConfigController#12122talos-bot merged 1 commit intosiderolabs:mainfrom
Conversation
6ce183d to
a666610
Compare
301aaa5 to
3f43ff9
Compare
79b3412 to
ab822d2
Compare
that one is flaky if it fails saying 'locking failed'... |
c97176d to
ae80b65
Compare
| } | ||
|
|
||
| var ( | ||
| userVolumeTransformer = func(c configconfig.Config) ([]volumeResource, error) { |
There was a problem hiding this comment.
dumb question, what is the benefit of this vs.
func userVolumeTransformer(c configconfig.Config) ([]volumeResource, error)There was a problem hiding this comment.
I don't think we need this right now, but we could also move these functions into internal/... sub-package, make them public, so we could unit-test them in isolation as well
this might provide some better grouping, remove some code from this package into smaller sub-packages
There was a problem hiding this comment.
I thought about doing that too! I think I have a branch locally with a change similar to that + some unit tests, but then I decided I had to draw a line somewhere and leave that for another PR 😅
I'll push those changes anyway so I don't forget.
There was a problem hiding this comment.
dumb question, what is the benefit of this vs.
No real benefit (at least, I don't think there is), just style – I'm happy to change it to either form. I think had it this way initially to kind of emphasize the fact that these should be grouped together. I also thought about adding a dummy type ConfigResourceTransformer struct{} that just does these, which is good for grouping, but I don't love the unnecessary bloat.
Moving these to another package like you suggested is a good approach, so I'll do that (in a separate PR, if that's alright).
|
/m |
1a2efbf to
4c22a9b
Compare
|
/m |
Previously, system volumes (`META`, `STATE`, etc.) were created by `VolumeConfigController` and user volumes were created by `UserVolumeConfigController`. This resulted in these controllers racing to create volumes, which could cause partitions to be created in an incorrect order. This patch fixes this potential race by merging these two controllers into a single controller, and refactoring a lot of the similar code paths into one single pipeline for volume config handling. Signed-off-by: Laura Brehm <laurabrehm@hey.com>
4c22a9b to
43f4e31
Compare
|
/m |
This is a regression introduced in siderolabs#12122 and siderolabs#12141. Without this, only `kubelet` holds `/var/mnt`, so on kubelet restart, Talos tries to unmount it, cascading into unmount of all user volumes, which shouldn't be the case. Fixes siderolabs#12797 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
This is a regression introduced in siderolabs#12122 and siderolabs#12141. Without this, only `kubelet` holds `/var/mnt`, so on kubelet restart, Talos tries to unmount it, cascading into unmount of all user volumes, which shouldn't be the case. Fixes siderolabs#12797 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
This is a regression introduced in siderolabs#12122 and siderolabs#12141. Without this, only `kubelet` holds `/var/mnt`, so on kubelet restart, Talos tries to unmount it, cascading into unmount of all user volumes, which shouldn't be the case. Fixes siderolabs#12797 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
This is a regression introduced in siderolabs#12122 and siderolabs#12141. Without this, only `kubelet` holds `/var/mnt`, so on kubelet restart, Talos tries to unmount it, cascading into unmount of all user volumes, which shouldn't be the case. Fixes siderolabs#12797 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit e5b0eb0)
Pull Request
Fixes #11992
What? (description)
Merges
(System)VolumeConfigandUserVolumeConfigcontrollers into a single controller, w/ extensive refactors:VolumeConfig) for system+user volumeshandleCustomVolumeConfig(nowcreateVolume) for both as wellvolumeResourceto replace all the arguments passed tohandleCustomConfig/createVolumeuser_volume_config_test.gointovolume_config_test.gor.StartTrackingOutput/safe.CleanupOutputslogic, and reused the custom logic from theUserVolumeConfigcontroller for keeping track ofVolumeConfigs/removing unused ones (added a label,block.SystemVolumeLabelfor tracking)Additionally, a small, internal
volumeConfigBuilderconvenience wrapper for buildingVolumeConfigresource modifier funcs is added:Why? (reasoning)
Merging
VolumeConfigandUserVolumeConfigcontrollers removes the race condition between system and user volume config creation, and these controllers are quite similar already.Acceptance
Please use the following checklist:
make conformance)make fmt)make lint)make docs)make unit-tests)