-
-
Notifications
You must be signed in to change notification settings - Fork 231
feature(lxc): enable root disk resize without recreate. recreate container if mount points are added, deleted or changed in size #2321
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Alexander Petermann <alex@petermann.dev>
Signed-off-by: Alexander Petermann <alex@petermann.dev>
Signed-off-by: Alexander Petermann <alex@petermann.dev>
Summary of ChangesHello @lexxxel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request adds a valuable feature for resizing LXC container root disks. The overall approach is sound, but I've identified a few critical issues in the resource update logic that could lead to runtime panics or silent failures. My review comments focus on adding necessary error handling, ensuring safe access to pointer fields to prevent panics, and correcting flawed comparison logic. I've also included a suggestion to improve consistency in one of the new data structures. Addressing these points will significantly improve the robustness of the implementation.
|
I implemented the resize path that increases the root disk without a forced replacement. However, in case the new disk should be smaller than the current disk, I do 'just' return an error. It would make sense to trigger a |
Signed-off-by: Alexander Petermann <alex@petermann.dev>
|
/gemini review |
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.
Code Review
This pull request introduces a valuable feature to allow resizing the root disk of an LXC container without forcing a recreation of the resource. The implementation is largely on the right track, but I've identified a few critical issues that need to be addressed. These include an unhandled error which could lead to an inconsistent state, potential nil pointer dereferences that could cause the provider to panic, and a logic bug in change detection for the quota property. I've provided specific code suggestions to resolve these problems. Additionally, I've included a minor suggestion to improve an error message for better clarity.
|
/gemini review |
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.
Code Review
This pull request introduces a valuable feature to allow resizing the root disk of an LXC container without forcing a recreation of the resource. The overall approach is sound, but I've identified a couple of critical issues in the update logic that could lead to panics or silent error swallowing. Additionally, I've provided a suggestion to improve the resource lifecycle by handling disk shrinking at the plan stage, as hinted by a TODO in the code.
Signed-off-by: Alexander Petermann <alex@petermann.dev>
|
/gemini review |
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.
Code Review
This pull request enables resizing the root disk for LXC containers without forcing a recreation of the container. The changes involve removing ForceNew from the disk schema, adding a custom diff function to handle disk shrinking by forcing a new resource, and updating the container update logic to call the new resize API endpoint. The implementation is mostly correct, but I've found a few issues, including a bug that would cause unnecessary API calls, some leftover debugging code, and a potential Go version compatibility issue. My review comments provide suggestions to address these points.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: Alexander Petermann <alex@petermann.dev>
|
/gemini review |
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.
Code Review
This pull request introduces the ability to resize an LXC container's root disk without forcing a new container resource. This is achieved by removing ForceNew from the disk schema and adding update logic to handle resizing. The changes also include a custom diff function to prevent disk shrinking by forcing a new resource in that case.
My review includes two main points:
- A high-severity bug in the update logic where disk sizes are compared by pointer instead of by value, which would lead to unnecessary API calls.
- A medium-severity suggestion to clean up the custom diff function by removing debug code and a confusing
ForceNewcall.
Overall, the changes are well-structured and address the intended feature. After addressing the identified issues, the PR should be in good shape.
…er a recreate Signed-off-by: Alexander Petermann <alex@petermann.dev>
49d343d to
79ddf1a
Compare
|
/gemini review |
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.
Code Review
This pull request enables resizing the root disk of an LXC container without forcing a new resource, which is a great enhancement. The changes involve removing ForceNew from the disk size attribute, adding a CustomizeDiff to handle disk shrinking, and implementing the resize logic in the containerUpdate function. The approach is sound, but I've identified two critical issues. One is the use of Go 1.22-specific syntax, which could cause compilation failures on older Go versions. The other is a potential nil pointer dereference in the update logic when checking the old disk size. Please address these issues to ensure the stability and compatibility of this new feature.
|
|
||
| oldSize := containerConfig.RootFS.Size | ||
| size := types.DiskSizeFromGigabytes(int64(diskBlock[mkDiskSize].(int))) | ||
| if *oldSize > *size { |
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.
There is a potential nil pointer dereference here. oldSize is of type *types.DiskSize and can be nil if the size property is not returned by the Proxmox API for the container's rootfs. Dereferencing it with *oldSize on this line will cause a panic. You should add a nil check for oldSize before dereferencing it.
| if *oldSize > *size { | |
| if oldSize != nil && *oldSize > *size { |
Signed-off-by: Alexander Petermann <alex@petermann.dev>
|
Okay, we'd need to rebase this, after the previous PR got merged. |
|
Yes and I will clean it up too. Will take me untill Tuesday unfortunately. |
Contributor's Note
/docsfor any user-facing features or additions./fwprovider/testsfor any new or updated resources / data sources.make exampleto verify that the change works as expected.This PR is an addition to #2319. So please do merge #2319 before reviewing this PR!
Proof of Work
Community Note
Closes #1435
After some playing around with mount points, I also documented and fixed #2322