Skip to content

Commit

Permalink
rbd: do not try to run resizefs on an encrypted BlockMode volume
Browse files Browse the repository at this point in the history
When a volume has AccessType=Block and is encrypted with LUKS, a resize
of the filesystem on the (decrypted) block-device is attempted. This
should not be done, as the application that requested the Block volume
is the only authoritive reader/writer of the data.

In particular VirtualMachines that use RBD volumes as a disk, usually
have a partition table on the disk, instead of only a single filesystem.
The `resizefs` command will not be able to resize the filesystem on the
block-device, as it is a partition table.

When `resizefs` fails during NodeStageVolume, the volume is unstaged and
an error is returned.

Resizing an encrypted block-device requires `cryptsetup resize` so that
the LUKS header on the RBD-image is updated with the correct size. But
there is no need to call `resizefs` in this case.

Fixes: #3945
Signed-off-by: Niels de Vos <ndevos@ibm.com>
(cherry picked from commit f60a358)
  • Loading branch information
nixpanic authored and mergify[bot] committed Jul 4, 2023
1 parent d6d66d5 commit 06bcf92
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/rbd/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,14 @@ func resizeNodeStagePath(ctx context.Context,
if err != nil {
return status.Error(codes.Internal, err.Error())
}

// If this is a AccessType=Block volume, do not attempt
// filesystem resize. The application is in charge of the data
// on top of the raw block-device, we can not assume there is a
// filesystem at all.
if isBlock {
return nil
}
}
// check stagingPath needs resize.
ok, err = resizer.NeedResize(devicePath, stagingTargetPath)
Expand Down

0 comments on commit 06bcf92

Please sign in to comment.