-
Notifications
You must be signed in to change notification settings - Fork 0
implement rbd lock related commands #197
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
2e5a26d to
443b696
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.
Pull request overview
This PR implements RBD lock management functionality by adding commands to add, remove, and list locks on RBD images. It introduces a Command interface abstraction to enable testable code through dependency injection, refactors existing RBD operations to use this pattern, and includes comprehensive unit tests using gomock.
- Adds LockAdd, LockRm, and LockLs methods to RBDRepository with full unit test coverage
- Introduces Command interface with mock generation for testable command execution
- Refactors existing snapshot operations (CreateSnapshot, RemoveSnapshot, ListSnapshots) to use the new command abstraction
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/model/repository.go | Adds RBDLock model and RBDImageLocker interface defining lock operations |
| internal/infrastructure/ceph/command.go | Introduces Command interface and implementation for abstracting command execution |
| internal/infrastructure/ceph/command_mock.go | Generated mock implementation of Command interface for testing |
| internal/infrastructure/ceph/rbd.go | Implements lock operations (LockAdd, LockRm, LockLs) and refactors existing methods to use Command interface |
| internal/infrastructure/ceph/rbd_test.go | Adds comprehensive unit tests for lock operations using mocked Command interface |
| Makefile | Adds mock generation target and integrates it into test workflow |
| versions.mk | Defines MOCKGEN_VERSION extracted from go.mod |
| go.mod | Adds go.uber.org/mock dependency and updates golang.org/x dependencies |
| go.sum | Updates checksums for new and updated dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9183ea9 to
4544b2a
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.
Pull request overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
internal/controller/finbackup_controller.go:605
- If
CreateSnapshotfails after successfully acquiring the lock (line 602), the lock will not be released because the function returns early at line 604. This can leave the volume permanently locked. Consider wrapping the snapshot creation in a defer or ensuring unlock is called in error cases.
err = r.snapRepo.CreateSnapshot(rbdPool, rbdImage, snapName)
if err != nil {
return nil, fmt.Errorf("failed to create snapshot: %w", err)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
c09bbc9 to
fa14ad9
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.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
internal/controller/finbackup_controller.go:601
- If
CreateSnapshotfails on line 598, the lock acquired on line 591 will not be released, leading to a lock leak. The unlock operation should be added in an error handling path or using defer to ensure it's called even if snapshot creation fails.
err = r.snapRepo.CreateSnapshot(rbdPool, rbdImage, snapName)
if err != nil {
return nil, fmt.Errorf("failed to create snapshot: %w", err)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fa14ad9 to
292c455
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.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
41a07ea to
02186ef
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.
Pull request overview
Copilot reviewed 18 out of 19 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c2c5192 to
e2613df
Compare
Signed-off-by: Yuji Ito <[email protected]>
Signed-off-by: Yuji Ito <[email protected]>
e2613df to
58e52b9
Compare
Signed-off-by: Yuji Ito <[email protected]>
675bfde to
7200099
Compare
Signed-off-by: Yuji Ito <[email protected]>
7200099 to
e17884c
Compare
No description provided.