-
Notifications
You must be signed in to change notification settings - Fork 683
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
Adds shared memory into extended resources #6193
base: master
Are you sure you want to change the base?
Adds shared memory into extended resources #6193
Conversation
Signed-off-by: Thomas J. Fan <[email protected]>
Code Review Agent Run #6a4c77Actionable Suggestions - 6
Additional Suggestions - 3
Review Details
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6193 +/- ##
========================================
Coverage 37.08% 37.08%
========================================
Files 1318 1318
Lines 132707 132811 +104
========================================
+ Hits 49208 49256 +48
- Misses 79244 79299 +55
- Partials 4255 4256 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Thomas J. Fan <[email protected]>
Changelist by BitoThis pull request implements the following key changes.
|
errorMsg: "/dev/shm is already mounted in container", | ||
}, | ||
{ | ||
name: "Mount path already in container", |
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.
The test case name Mount path already in container
appears to be duplicated at line 2483. Consider using a more descriptive name that reflects the actual test scenario of invalid size limit parsing.
Code suggestion
Check the AI-generated fix before applying
name: "Mount path already in container", | |
name: "Invalid size limit format", |
Code Review Run #6a4c77
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
var quantity resource.Quantity | ||
if test.sharedVolume.GetSizeLimit() != "" { | ||
quantity, err = resource.ParseQuantity(test.sharedVolume.GetSizeLimit()) | ||
assert.NoError(t, err) | ||
} |
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.
Consider initializing quantity
to a zero value before the conditional block. Currently if GetSizeLimit()
returns an empty string, quantity
remains uninitialized when used in the assertion.
Code suggestion
Check the AI-generated fix before applying
var quantity resource.Quantity | |
if test.sharedVolume.GetSizeLimit() != "" { | |
quantity, err = resource.ParseQuantity(test.sharedVolume.GetSizeLimit()) | |
assert.NoError(t, err) | |
} | |
var quantity resource.Quantity | |
quantity = resource.Quantity{} | |
if test.sharedVolume.GetSizeLimit() != "" { | |
quantity, err = resource.ParseQuantity(test.sharedVolume.GetSizeLimit()) | |
assert.NoError(t, err) | |
} |
Code Review Run #6a4c77
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
// Size limit for shared memory. If not set, then the shared memory is equal | ||
// to the allocated memory. | ||
// +optional | ||
string size_limit = 3; |
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.
Consider using a more specific type like k8s.io/apimachinery/pkg/api/resource.Quantity
for size_limit
instead of string
to ensure proper validation of memory size values.
Code suggestion
Check the AI-generated fix before applying
string size_limit = 3; | |
k8s.io.apimachinery.pkg.api.resource.Quantity size_limit = 3; |
Code Review Run #6a4c77
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
if extendedResources.GetSharedMemory() != nil { | ||
err = ApplySharedMemory(podSpec, primaryContainerName, extendedResources.GetSharedMemory()) |
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.
Consider adding validation for SharedMemory
fields before applying the override. The MountPath
and MountName
fields should be validated to ensure they contain valid values.
Code suggestion
Check the AI-generated fix before applying
if extendedResources.GetSharedMemory() != nil { | |
err = ApplySharedMemory(podSpec, primaryContainerName, extendedResources.GetSharedMemory()) | |
if extendedResources.GetSharedMemory() != nil { | |
shm := extendedResources.GetSharedMemory() | |
if shm.MountPath == "" || shm.MountName == "" { | |
return nil, nil, fmt.Errorf("shared memory mount path and name must be specified") | |
} | |
if !strings.HasPrefix(shm.MountPath, "/") { | |
return nil, nil, fmt.Errorf("shared memory mount path must be absolute") | |
} | |
err = ApplySharedMemory(podSpec, primaryContainerName, extendedResources.GetSharedMemory()) |
Code Review Run #6a4c77
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
if extendedResources.GetSharedMemory() != nil { | ||
err = ApplySharedMemory(podSpec, primaryContainerName, extendedResources.GetSharedMemory()) | ||
if err != nil { | ||
return nil, nil, err |
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.
Consider checking if primaryContainerName
is empty before using it in ApplySharedMemory()
. An empty container name could cause issues with shared memory configuration.
Code suggestion
Check the AI-generated fix before applying
if extendedResources.GetSharedMemory() != nil { | |
err = ApplySharedMemory(podSpec, primaryContainerName, extendedResources.GetSharedMemory()) | |
if err != nil { | |
return nil, nil, err | |
if extendedResources.GetSharedMemory() != nil { | |
if primaryContainerName == "" { | |
return nil, nil, fmt.Errorf("primary container name cannot be empty when configuring shared memory") | |
} | |
err = ApplySharedMemory(podSpec, primaryContainerName, extendedResources.GetSharedMemory()) | |
if err != nil { | |
return nil, nil, err |
Code Review Run #6a4c77
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
@@ -429,6 +490,14 @@ | |||
ApplyGPUNodeSelectors(podSpec, extendedResources.GetGpuAccelerator()) | |||
} | |||
|
|||
// Shared memory volume | |||
if extendedResources.GetSharedMemory() != nil { | |||
err = ApplySharedMemory(podSpec, primaryContainerName, extendedResources.GetSharedMemory()) |
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.
Consider checking the return value from ApplySharedMemory()
before proceeding. The error handling could be more explicit.
Code suggestion
Check the AI-generated fix before applying
err = ApplySharedMemory(podSpec, primaryContainerName, extendedResources.GetSharedMemory()) | |
if err := ApplySharedMemory(podSpec, primaryContainerName, extendedResources.GetSharedMemory()); err != nil { | |
return nil, nil, fmt.Errorf("failed to apply shared memory: %w", err) | |
} |
Code Review Run #6a4c77
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Code Review Agent Run #5bb8beActionable Suggestions - 0Review Details
|
Tracking issue
Towards #6142
Why are the changes needed?
This PR adds shared memory as an extend resource, that is made available through
@task(shared_memory)
. For the simple case, you can have@task(shared_memory=True)
, which means: "memory backed volumes are sized to node allocatable memory". Otherwise, you can setshared_memory="2Gi"
to specify the value.What changes were proposed in this pull request?
This PR adds
shared_memory
to the IDL and the implementation to get it to work.How was this patch tested?
Unit tests were added to this PR and tested with flytekit changes:
Then I used kubectl to make sure that the pod spec was correct.
Summary by Bito
This PR implements shared memory support in Flyte's extended resources by introducing a new SharedMemory message type in the IDL with configurable mount options. The implementation includes protobuf definitions and pod helper functionality for Kubernetes pods, utilizing getter methods for shared volume mount properties. The changes enable tasks to request and configure memory-backed volumes with either default node allocatable memory or custom size specifications across multiple language bindings including Go, JavaScript/TypeScript, and Python.Unit tests added: True
Estimated effort to review (1-5, lower is better): 5