Skip to content

Commit f4878c4

Browse files
committed
remove user volumes backed by tmpfs
1 parent ed9f986 commit f4878c4

4 files changed

Lines changed: 3 additions & 44 deletions

File tree

internal/app/machined/pkg/controllers/block/internal/volumes/locate.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ func LocateAndProvision(ctx context.Context, logger *zap.Logger, volumeContext M
3737

3838
return nil
3939
case block.VolumeTypeMemory:
40-
// memory volumes are always ready, but need size set from parameters
41-
// Extract size from mount parameters
40+
// memory volumes are always ready, but need size from parameters
4241
for _, param := range volumeContext.Cfg.TypedSpec().Mount.Parameters {
4342
if param.Name == "size" && param.String != nil {
4443
var size uint64
@@ -95,7 +94,6 @@ func LocateAndProvision(ctx context.Context, logger *zap.Logger, volumeContext M
9594
for _, diskCtx := range volumeContext.Disks {
9695
if dv.ParentDevPath != "" && diskCtx.Disk.DevPath == dv.ParentDevPath {
9796
matchContext["disk"] = diskCtx.Disk
98-
// Add system_disk to context (needed for VolumeLocator expressions that reference disk)
9997
if val, ok := diskCtx.SystemDisk.Get(); ok {
10098
matchContext["system_disk"] = val
10199
}
@@ -105,7 +103,6 @@ func LocateAndProvision(ctx context.Context, logger *zap.Logger, volumeContext M
105103

106104
if dv.ParentDevPath == "" && diskCtx.Disk.DevPath == dv.DevPath {
107105
matchContext["disk"] = diskCtx.Disk
108-
// Add system_disk to context (needed for VolumeLocator expressions that reference disk)
109106
if val, ok := diskCtx.SystemDisk.Get(); ok {
110107
matchContext["system_disk"] = val
111108
}

internal/app/machined/pkg/controllers/block/internal/volumes/volumeconfig/user_volumes.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,7 @@ func UserVolumeTransformer(c configconfig.Config) ([]VolumeResource, error) {
125125
WithConvertEncryptionConfiguration(userVolumeConfig.Encryption()).
126126
WriterFunc()
127127

128-
case block.VolumeTypeMemory:
129-
userVolumeResource.TransformFunc = NewBuilder().
130-
WithType(block.VolumeTypeMemory).
131-
WithMount(block.MountSpec{
132-
TargetPath: userVolumeConfig.Name(),
133-
ParentID: constants.UserVolumeMountPoint,
134-
SelinuxLabel: constants.EphemeralSelinuxLabel,
135-
FileMode: 0o755,
136-
UID: 0,
137-
GID: 0,
138-
Parameters: []block.ParameterSpec{
139-
{
140-
Type: block.FSParameterTypeStringValue,
141-
Name: "size",
142-
String: pointer.To(fmt.Sprintf("%d", cmp.Or(userVolumeConfig.Provisioning().MinSize().ValueOrZero(), MinUserVolumeSize))),
143-
},
144-
},
145-
}).
146-
WriterFunc()
147-
148-
case block.VolumeTypeTmpfs, block.VolumeTypeSymlink, block.VolumeTypeOverlay, block.VolumeTypeExternal:
128+
case block.VolumeTypeTmpfs, block.VolumeTypeSymlink, block.VolumeTypeOverlay, block.VolumeTypeExternal, block.VolumeTypeMemory:
149129
fallthrough
150130

151131
default:

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,7 @@ func (ctrl *MountController) handleMemoryMountOperation(
445445

446446
logger = logger.With(zap.String("mount_request.id", mountRequest.Metadata().ID()))
447447

448-
// mount hasn't been done yet
449448
if !ok {
450-
// Extract size from mount parameters
451449
var sizeOpt string
452450

453451
for _, param := range volumeStatus.TypedSpec().MountSpec.Parameters {
@@ -477,7 +475,6 @@ func (ctrl *MountController) handleMemoryMountOperation(
477475
return fmt.Errorf("failed to mount tmpfs at %s: %w", mountTarget, err)
478476
}
479477

480-
// Apply SELinux label if specified
481478
if volumeStatus.TypedSpec().MountSpec.SelinuxLabel != "" {
482479
if err := selinux.SetLabel(mountTarget, volumeStatus.TypedSpec().MountSpec.SelinuxLabel); err != nil {
483480
unix.Unmount(mountTarget, 0) //nolint:errcheck
@@ -486,7 +483,6 @@ func (ctrl *MountController) handleMemoryMountOperation(
486483
}
487484
}
488485

489-
// Update ownership and permissions if specified
490486
if !mountRequest.TypedSpec().ReadOnly && !mountRequest.TypedSpec().Detached {
491487
if err := ctrl.updateTargetSettings(mountTarget, volumeStatus.TypedSpec().MountSpec); err != nil {
492488
unix.Unmount(mountTarget, 0) //nolint:errcheck
@@ -500,7 +496,6 @@ func (ctrl *MountController) handleMemoryMountOperation(
500496
zap.String("target", mountTarget),
501497
)
502498

503-
// Store the mount context
504499
ctrl.activeMounts[mountRequest.Metadata().ID()] = &mountContext{
505500
point: nil, // No mount.Point for direct unix.Mount
506501
readOnly: mountRequest.TypedSpec().ReadOnly,

pkg/machinery/config/types/block/user_volume_config.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,7 @@ func (s *UserVolumeConfigV1Alpha1) Validate(validation.RuntimeMode, ...validatio
272272
warnings = append(warnings, extraWarnings...)
273273
validationErrors = errors.Join(validationErrors, extraErrors)
274274

275-
case block.VolumeTypeMemory:
276-
if !s.ProvisioningSpec.IsZero() {
277-
validationErrors = errors.Join(validationErrors, errors.New("provisioning spec is invalid for volumeType memory"))
278-
}
279-
280-
if !s.EncryptionSpec.IsZero() {
281-
validationErrors = errors.Join(validationErrors, errors.New("encryption spec is invalid for volumeType memory"))
282-
}
283-
284-
if !s.FilesystemSpec.IsZero() {
285-
validationErrors = errors.Join(validationErrors, errors.New("filesystem spec is invalid for volumeType memory"))
286-
}
287-
288-
case block.VolumeTypeTmpfs, block.VolumeTypeSymlink, block.VolumeTypeOverlay, block.VolumeTypeExternal:
275+
case block.VolumeTypeTmpfs, block.VolumeTypeSymlink, block.VolumeTypeOverlay, block.VolumeTypeExternal, block.VolumeTypeMemory:
289276
fallthrough
290277

291278
default:

0 commit comments

Comments
 (0)