Skip to content
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

fix: change misleading error message to warning level #3316

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

derekbit
Copy link
Member

@derekbit derekbit commented Dec 6, 2024

Which issue(s) this PR fixes:

Issue longhorn/longhorn#9916

When new replicas are created, the following error messages are emitted in the longhorn-manager. Empty timestamp is expected in this case, so the error messages are misleading.

What this PR does / why we need it:

Special notes for your reviewer:

Additional documentation or context

@derekbit derekbit requested a review from c3y1huang December 6, 2024 06:05
Copy link

coderabbitai bot commented Dec 6, 2024

Walkthrough

The pull request introduces enhancements to the volume controller, focusing on error handling, logging, and volume state management. Key modifications include refining error logging to use warning levels for specific conditions, improving the logic for volume state transitions, and enhancing the management of replicas. These changes aim to ensure that the volume controller operates more robustly and provides clearer logging for operations related to volume and replica management.

Changes

File Change Summary
controller/volume_controller.go - Improved error handling in syncVolume, handleErr, and cleanupReplicas methods.
- Enhanced volume state management in ReconcileVolumeState.
- Adjusted logging to use log.Warnf for specific errors instead of log.Errorf.
- Updated cleanup logic for replicas to ensure safe removal based on operational context.

Assessment against linked issues

Objective Addressed Explanation
Change misleading error message to warning level (#9916)

Possibly related PRs


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@derekbit derekbit requested a review from mantissahz December 6, 2024 06:05
When new replicas are created, the following error messages are emitted in the
longhorn-manager. Empty timestamp is expected in this case, so the error messages
are misleading.

Longhorn 9916

Signed-off-by: Derek Su <derek.su@suse.com>
@derekbit
Copy link
Member Author

derekbit commented Dec 6, 2024

@mergify backport v1.7.x v1.6.x

@derekbit derekbit self-assigned this Dec 6, 2024
Copy link

mergify bot commented Dec 6, 2024

backport v1.7.x v1.6.x

✅ Backports have been created

Copy link

@coderabbitai coderabbitai bot left a 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)
controller/volume_controller.go (2)

Line range hint 991-992: Refactor Suggestion: Simplify Switch Case Blocks

In the reconcileAttachDetachStateMachine function, consider refactoring the switch statement at lines 991-992 for improved readability. Grouping similar cases or extracting logic into helper functions can enhance maintainability.


Line range hint 3311-3311: Enhance Log Message with Additional Context

At line 3311, the log message uses log.Warnf("%v", err). Consider adding context to the log message to aid in debugging, such as:

-log.Warnf("%v", err)
+log.Warnf("Failed to process volume %v: %v", v.Name, err)
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c233d72 and 1c60b79.

📒 Files selected for processing (1)
  • controller/volume_controller.go (1 hunks)
🔇 Additional comments (7)
controller/volume_controller.go (7)

752-755: Appropriate Use of Warnf for Logging

At lines 752-755, the logging statement has been changed to use log.Warnf instead of log.Errorf. This adjustment correctly lowers the severity level of the log message, aligning with the intent to change misleading error messages to warning level.


Line range hint 882-889: Ensure Correct Handling of Volume Robustness

At lines 882-889, the code appropriately updates the volume's robustness status and conditions when the volume is not in a faulted state. This ensures that the robustness is set to Unknown unless the volume is faulted, in which case it checks for restore requirements.


Line range hint 1000-1004: Correct Event Logging on Volume Detachment

At lines 1000-1004, the code correctly logs an event when a volume has been detached. This provides valuable information for monitoring and auditing volume state changes.


Line range hint 1048-1050: Proper Event Logging on Volume Attachment

At lines 1048-1050, an event is recorded when the volume is attached to a node. This ensures transparency and traceability of volume operations.


Line range hint 2969-2970: Confirm Log Request Mechanism

At lines 2969-2970, setting e.Spec.LogRequested = true and r.Spec.LogRequested = true requests logs from the engine and replicas. Verify that this mechanism functions as intended and does not introduce excessive logging or performance issues.


Line range hint 3010-3014: Graceful Handling of Update Conflicts

At lines 3010-3014, the code checks for conflicts when updating resources and re-queues the volume if a conflict is detected. This ensures that transient conflicts are handled gracefully without causing failures in the reconciliation loop.


Line range hint 1686-1688: Verify the Existence of the Priority Class

At lines 1686-1688, the code sets the PriorityClassName for the Pod if the priorityClass is not empty. Ensure that the specified priority class exists in the cluster to prevent scheduling issues.

Run the following script to verify that the priority class exists:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants