-
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
chore: add a check for Instance state when cloning #570
chore: add a check for Instance state when cloning #570
Conversation
WalkthroughThe changes introduce a new error variable Changes
Assessment against linked issues
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- pkg/instance/errors.go (1 hunks)
- pkg/instance/instance.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
pkg/instance/errors.go (1)
223-223
: New error definition aligns with PR objectives.The addition of
ErrCannotCloneInstance
is consistent with the PR objectives to implement a check for the Instance state during the cloning process. This new error will allow for more specific error handling when attempting to clone an instance that is in an inappropriate state.The error message format follows the existing pattern in the file, including both the instance name and its current state. This addition enhances the error handling capabilities of the package, providing more detailed feedback for debugging and user information.
To ensure this new error is properly utilized, let's check for its usage in the codebase:
✅ Verification successful
To verify the correct usage of
ErrCannotCloneInstance
, let's inspect how it's implemented inpkg/instance/instance.go
:
Verified:
ErrCannotCloneInstance
is correctly implemented and used.The new error
ErrCannotCloneInstance
is properly defined inpkg/instance/errors.go
and is utilized appropriately inpkg/instance/instance.go
. It follows the existing error definition pattern and aligns with the PR objectives, providing specific error handling for cloning instances in inappropriate states.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usage of the new error in the codebase rg "ErrCannotCloneInstance" --type goLength of output: 276
Script:
#!/bin/bash # Retrieve the context around the usage of ErrCannotCloneInstance in instance.go rg "ErrCannotCloneInstance" pkg/instance/instance.go -A 5 -B 5Length of output: 548
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 (2)
pkg/sidecars/tshark/tshark_test.go (2)
172-175
: LGTM! Consider using a constant for the instance name.The addition of a logger to the SystemDependencies is a good practice for better debugging and tracing.
Consider using a constant for the instance name "testInstance" to improve maintainability:
+const testInstanceName = "testInstance" -testInstance, err := instance.New("testInstance", +testInstance, err := instance.New(testInstanceName,
178-179
: LGTM! Consider using a constant for the image name.Setting the image for the test instance is necessary for proper configuration.
Consider using a constant for the image name "testImage" to improve maintainability:
+const testImageName = "testImage" -err = testInstance.Build().SetImage(context.Background(), "testImage") +err = testInstance.Build().SetImage(context.Background(), testImageName)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- pkg/sidecars/tshark/tshark_test.go (2 hunks)
🧰 Additional context used
🔇 Additional comments (2)
pkg/sidecars/tshark/tshark_test.go (2)
172-181
: Summary: Test improvements align with PR objectivesThe changes to
TestTsharkClone
enhance the test setup by ensuring the test instance is properly configured and committed before cloning. This aligns well with the PR objective of adding a check for Instance state when cloning.Key improvements:
- Added a logger to SystemDependencies for better tracing.
- Set the image for the test instance.
- Committed the instance before cloning.
These changes provide a more robust test environment and should help catch any issues related to instance state during cloning.
180-181
: Excellent addition! This addresses the PR objective.Committing the instance before cloning is crucial. This change ensures that the instance is in a committed state, which directly addresses the PR objective of checking the Instance state when cloning.
To further verify the impact of this change, let's check if the
CloneWithSuffix
method in theinstance
package now includes a state check:✅ Verification successful
Verified:
CloneWithSuffix
includes the necessary state check.This ensures that the instance is in a committed or stopped state before cloning, fully addressing the PR objective of verifying the instance state during the cloning process.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify if CloneWithSuffix includes a state check # Test: Search for CloneWithSuffix implementation rg --type go -A 10 'func \(i \*Instance\) CloneWithSuffix'Length of output: 936
hello!
|
No it is not expected. something might be wrong. |
When I run the failing test === RUN TestRunSuite
time="2024-10-08T15:46:06+03:30" level=info msg="Current log level" file="log/logger.go:41" env_log_level=LOG_LEVEL log_level=info
suite_setup_test.go:53: Scope: 20241008-154533-860
=== RUN TestRunSuite/TestBuildFromGit
=== PAUSE TestRunSuite/TestBuildFromGit
=== RUN TestRunSuite/TestBuildFromGitWithModifications
=== PAUSE TestRunSuite/TestBuildFromGitWithModifications
=== CONT TestRunSuite/TestBuildFromGit
=== CONT TestRunSuite/TestBuildFromGitWithModifications
build_image_test.go:22: Creating new instance
build_image_test.go:64: Creating new instance
build_image_test.go:68: Setting git repo
build_image_test.go:26: Building the image
build_image_test.go:36: Image built
build_image_test.go:40: Starting instance
build_image_test.go:43: Instance started
build_image_test.go:45: Getting file bytes
=== NAME TestRunSuite
suite.go:59: Cleaning up knuu...
suite.go:63: Knuu is cleaned up
--- PASS: TestRunSuite (54.40s)
--- PASS: TestRunSuite/TestBuildFromGit (24.49s)
--- PASS: TestRunSuite/TestBuildFromGitWithModifications (43.83s)
PASS
ok github.com/celestiaorg/knuu/e2e/system 98.264s |
Closes #531
Summary by CodeRabbit
New Features
StateCommitted
orStateStopped
states.Documentation
Tests
Tshark
struct by adding a logger and ensuring proper configuration of the test instance before cloning.