-
Notifications
You must be signed in to change notification settings - Fork 35
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
feat(storage): throw error when file(s) are to large for a configMap) #587
Conversation
Signed-off-by: Smuu <[email protected]>
WalkthroughThe changes introduced in this pull request enhance error handling in the instance management functionality. New error variables have been added to the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
smart!
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
pkg/instance/storage.go (1)
54-60
: Consider making the file size limit configurableThe 1MB size limit is currently hardcoded. Consider making this configurable through a constant or configuration parameter for better flexibility.
+const maxCommittedFileSize = 1024 * 1024 // 1MB + func (s *storage) AddFile(src string, dest string, chown string) error { // ... if srcInfo.Size() > maxCommittedFileSize { return ErrFileTooLargeCommitted.WithParams(src) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
pkg/instance/errors.go
(2 hunks)pkg/instance/storage.go
(3 hunks)
🔇 Additional comments (2)
pkg/instance/errors.go (1)
Line range hint 218-230
: LGTM: Well-defined error types for file size limits
The new error types are well-structured and provide clear messages for:
- PersistentVolumeClaim operations
- File size checks
- Total files size limit
pkg/instance/storage.go (1)
334-337
: LGTM: Proper error handling for volume claim creation
The error wrapping is well-implemented and follows the established pattern in the codebase.
Signed-off-by: Smuu <[email protected]>
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
pkg/instance/storage.go (1)
60-61
: Enhance error messages with file size detailsIncluding the actual file size and the maximum allowed size in the error messages for
ErrFileTooLargeCommitted
andErrTotalFilesSizeTooLarge
would provide clearer feedback to users and aid in debugging.For example:
- return ErrFileTooLargeCommitted.WithParams(src) + return ErrFileTooLargeCommitted.WithParams(src, srcInfo.Size(), maxTotalFilesBytes) - return ErrTotalFilesSizeTooLarge.WithParams(dstPath) + return ErrTotalFilesSizeTooLarge.WithParams(dstPath, size, maxTotalFilesBytes)Ensure the error constructors are updated to accept and display these additional parameters.
Also applies to: 299-300
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
pkg/instance/storage.go
(4 hunks)
🔇 Additional comments (4)
pkg/instance/storage.go (4)
19-19
: Defining a constant for maximum total file size
Defining maxTotalFilesBytes
as a constant improves maintainability and makes it easier to adjust the limit in the future if needed.
56-62
: Enforce individual file size limit in AddFile
method
Adding a check to ensure that each source file does not exceed maxTotalFilesBytes
enhances error handling by preventing oversized files from being added.
286-301
: Implement cumulative file size check in addFileToInstance
method
Calculating the total size of all files and enforcing a cumulative size limit ensures that the aggregate size stays within the allowed threshold, which improves stability.
336-339
: Improved error wrapping in deployVolume
method
Wrapping the error when creating persistent volume claims provides more context and improves error reporting, aiding in troubleshooting.
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.
Nice one, thanks!
Overview
Summary by CodeRabbit
New Features
Bug Fixes
Documentation