Skip to content

Conversation

@iPraveenParihar
Copy link
Contributor

Describe what this PR does

util: explicitly set the Luks2 header size

The LUKS2 header size is variable and it can be adjusted
on creation by using the --luks2-metadata-size and
--luks2-keyslots-size options. By default, the header size is
16MiB.

This commit explicitly uses the options to define the default
header size.

Ref 10.10: https://gitlab.com/cryptsetup/cryptsetup/-/blob/main/FAQ.md

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Reviewed the developer guide on Submitting a Pull Request
  • Pending release notes updated with breaking and/or notable changes for the next major release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

Show available bot commands

These commands are normally not required, but in case of issues, leave any of
the following bot commands in an otherwise empty comment in this PR:

  • /retest ci/centos/<job-name>: retest the <job-name> after unrelated
    failure (please report the failure too!)

@iPraveenParihar iPraveenParihar force-pushed the encryption/luks2-explicit-header-size branch from bbb07c4 to 22ce1d4 Compare June 25, 2025 06:52
@iPraveenParihar
Copy link
Contributor Author

/test ci/centos/mini-e2e/k8s-1.33

@iPraveenParihar iPraveenParihar force-pushed the encryption/luks2-explicit-header-size branch from 22ce1d4 to ffee6f6 Compare June 25, 2025 08:59
@iPraveenParihar
Copy link
Contributor Author

passed e2e logs

@iPraveenParihar iPraveenParihar marked this pull request as ready for review June 25, 2025 08:59
@iPraveenParihar iPraveenParihar force-pushed the encryption/luks2-explicit-header-size branch from ffee6f6 to a035b30 Compare June 25, 2025 09:07
return 0, fmt.Errorf("failed to get %s metadata on image %s: %w", luks2HeaderSizeKey, ri, err)
}

return 0, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be default size ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the name implies, getLuksHeaderSizeMetadata() is intended to return the LUKS2 header size only if it's explicitly set in the image metadata. If the metadata key is missing, it returns 0. It's the responsibility of the caller to interpret this and decide whether to fall back to the default LUKS2 header size (cryptsetup.DefaultLuks2HeaderSize, 16 MiB) or take another action.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, you need to adjust your comment appropriately And in that case, the default LUKS2 header // size is used, which is 16 MiB.

Copy link
Contributor

@Rakshith-R Rakshith-R Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the default value needs to be returned in this function itself to avoid confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 yea, that needs to be removed to avoid confusion.

// on creation by using the `--luks2-metadata-size` and
// `--luks2-keyslots-size` options. By default, the header size is
// 16MiB.
DefaultLuks2HeaderSize = 16 * helpers.MiB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a separate comment for this one, explaining older images do have this set in image metadata.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed PTAL.

@iPraveenParihar iPraveenParihar force-pushed the encryption/luks2-explicit-header-size branch 2 times, most recently from 4cf929f to 2172248 Compare June 25, 2025 10:00
@iPraveenParihar iPraveenParihar force-pushed the encryption/luks2-explicit-header-size branch 2 times, most recently from 47889b3 to 709d14b Compare June 25, 2025 11:50
Rakshith-R
Rakshith-R previously approved these changes Jun 25, 2025
Copy link
Contributor

@Rakshith-R Rakshith-R left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@Rakshith-R Rakshith-R requested a review from a team June 25, 2025 12:16
Copy link
Member

@nixpanic nixpanic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small improvement to prevent potential bugs when calling the new getLuksHeaderSizeMetadata() function.

@iPraveenParihar iPraveenParihar force-pushed the encryption/luks2-explicit-header-size branch from 709d14b to b4e6f86 Compare June 25, 2025 13:26
@mergify mergify bot dismissed Rakshith-R’s stale review June 25, 2025 13:27

Pull request has been modified.

@iPraveenParihar iPraveenParihar requested a review from nixpanic June 25, 2025 13:33
@Rakshith-R Rakshith-R requested a review from a team June 25, 2025 13:36
@nixpanic
Copy link
Member

@Mergifyio rebase

The LUKS2 header size is variable and it can be adjusted
on creation by using the `--luks2-metadata-size` and
`--luks2-keyslots-size` options. By default, the header size is
16MiB.

This commit explicitly uses the options to define the default
header size.

Ref 10.10: https://gitlab.com/cryptsetup/cryptsetup/-/blob/main/FAQ.md

Signed-off-by: Praveen M <[email protected]>
@mergify
Copy link
Contributor

mergify bot commented Jun 25, 2025

rebase

✅ Branch has been successfully rebased

@nixpanic nixpanic force-pushed the encryption/luks2-explicit-header-size branch from b4e6f86 to 6cfe178 Compare June 25, 2025 15:12
@nixpanic
Copy link
Member

@Mergifyio queue

@mergify
Copy link
Contributor

mergify bot commented Jun 25, 2025

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at d0003aa

@mergify mergify bot added the ok-to-test Label to trigger E2E tests label Jun 25, 2025
@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.31

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/upgrade-tests-cephfs

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.31

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/upgrade-tests-rbd

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.31

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.32

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/k8s-e2e-external-storage/1.33

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.32

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e-helm/k8s-1.33

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.32

@ceph-csi-bot
Copy link
Collaborator

/test ci/centos/mini-e2e/k8s-1.33

@ceph-csi-bot ceph-csi-bot removed the ok-to-test Label to trigger E2E tests label Jun 25, 2025
@mergify mergify bot merged commit d0003aa into ceph:devel Jun 25, 2025
36 of 37 checks passed
@mergify
Copy link
Contributor

mergify bot commented Jun 25, 2025

This pull request has been removed from the queue for the following reason: pull request branch update failed.

The pull request can't be updated.

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

oldMetadataDEK = ".rbd.csi.ceph.com/dek"

// luks2 header size metadata key.
luks2HeaderSizeKey = "rbd.csi.ceph.com/luks2HeaderSize"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this metadata key to be present on all the clones/snapshots and also across cluster when mirroring is enabled?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants