-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce 4096 byte Sector Size Minimum for Rounding LV Sizes on Creation and Resizing #844
Conversation
4fa3e94
to
a0fec57
Compare
Hi @jakobmoellerdev, Thank you for your PR! Looks like a reasonable change to me. Before we start a review of the implementation, let me discuss the implementation strategy. I agree that we introduce LV size limitation to fit into the 4096 byte alignment. But I'm not sure it would be reasonable to implement this logic in lvmd. The lvmd creates LVs with the size decided by the topolvm-controller based on the
So, I'll suggest the following strategy:
Additionally, we might need to round up the size when the topolvm-controller adds requests to Pods. |
Thanks for the input. Agreed that we can change the approach to make it better fit into the CSI Spec. I just checked CapacityRange and it seems like there are two components to it: RequiredBytes and LimitBytes. I suggest we use your approach then and do the following logic:
Towards your point of
Could you tell me what needs to change and why here? Then I will implement accordingly. Not sure what this means right now (maybe you mean the resource extensions on the Pod) |
7852e3a
to
62de718
Compare
I changed my mind. Let's leave it as is. When the scheduler decides a node to which allocate Pods, it would be better to know the accurate size of the LVs to create as much as possible. However, since the discrepancy is at most 4096 bytes, we can leave it as it is until it becomes a problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 433 to 442 in 976abaf
// if requestBytes is 0, default to max(1Gi, limitBytes>0) | |
// 1. if limitBytes is 0, default to 1Gi | |
// 2. if limitBytes is greater than 1Gi, default to 1Gi | |
// 3. if limitBytes is less than 1Gi, default to limitBytes | |
if requestBytes == 0 { | |
if limitBytes > 0 && topolvm.DefaultSize > limitBytes { | |
return limitBytes, nil | |
} | |
return topolvm.DefaultSize, nil | |
} |
Take care of the case where requestByte == 0
and limitByte < 4096
. It is not allowed now. It might be better not to use early returns and force return values always pass the "round up logic".
topolvm/driver/controller_test.go
Lines 32 to 38 in 976abaf
v, err := convertRequestCapacityBytes(0, 10) | |
if err != nil { | |
t.Error("should not be error") | |
} | |
if v != 10 { | |
t.Errorf("should be the limit capacity by default if 0 is supplied and limit is smaller than 1Gi: %d", v) | |
} |
Then this test case needs to be fixed.
8440dbc
to
df54049
Compare
@jakobmoellerdev |
Signed-off-by: Jakob Möller <jmoller@redhat.com>
df54049
to
c10420e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@pluser mind taking a look over this one now that first review has passed? |
This PR adds a 4096 Minimum Size limitation for all Logical Volumes that are created. The reason is that if one decides to use byte level precision on a PVC, that byte amount is now passed through to lvcreate. However if this byte-amount is not a multiple of the sector size (for most machines either 512, 1024 or 4096) then LVM will throw an error like
In this case, we should round down in order to allow for a PVC creation with slightly different Size than the one requested as this is much better than getting rejected the PVC scheduling.
The code is now changed to automatically round down or up (based on wether the limit or the request bytes are used and which one is larger). For edge cases during rounding we introduce new error cases.
Note that even though the 4KiB limit here is important for validation, the size might in the end still be rounded up to the nearest physical extent size (4MiB by default)