Skip to content

Commit e5b0eb0

Browse files
committed
fix: hold user volumes root mountpoint
This is a regression introduced in #12122 and #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 #12797 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 8a0e797 commit e5b0eb0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

internal/app/machined/pkg/controllers/block/volume_config.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ func (ctrl *VolumeConfigController) Run(ctx context.Context, r controller.Runtim
9292
return nil
9393
}
9494

95+
// create a volume mount request for the root user volume mount point
96+
// to keep it alive and prevent it from being torn down
97+
if err := safe.WriterModify(ctx, r,
98+
block.NewVolumeMountRequest(block.NamespaceName, constants.UserVolumeMountPoint),
99+
func(v *block.VolumeMountRequest) error {
100+
v.TypedSpec().Requester = ctrl.Name()
101+
v.TypedSpec().VolumeID = constants.UserVolumeMountPoint
102+
103+
return nil
104+
},
105+
); err != nil {
106+
return fmt.Errorf("error creating volume mount request for user volume mount point: %w", err)
107+
}
108+
95109
machineCfg, encryptionMeta, err := ctrl.loadConfiguration(ctx, r)
96110
if err != nil {
97111
return err

internal/app/machined/pkg/controllers/block/volume_config_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ func TestVolumeConfigSuite(t *testing.T) {
8282
}
8383

8484
func (suite *VolumeConfigSuite) TestReconcileDefaults() {
85+
// user volume mount point should be hold mounted all the time to prevent cascading unmounts on kubelet restart
86+
ctest.AssertResource(suite, constants.UserVolumeMountPoint, func(*block.VolumeMountRequest, *assert.Assertions) {})
87+
8588
// no machine config, default config which only searches for
8689
ctest.AssertResource(suite, constants.MetaPartitionLabel, func(r *block.VolumeConfig, asrt *assert.Assertions) {
8790
asrt.Empty(r.TypedSpec().Provisioning)

0 commit comments

Comments
 (0)