Fix mirror loading failure when a mirror has an invalid credential - #1316
Conversation
Motivation: - The SSH host key verification change made SshGitMirror's constructor throw a MirrorException whenever the credential is not an SshKeyCredential (e.g. a missing credential that resolves to Credential.NONE). Modifications: - Wrap the per-mirror MirrorConverter.convertToMirror call in handleAllMirrors with a try/catch that logs a warning and skips the bad mirror (returns null) instead of failing the whole list. Result: - A mirror with an invalid or missing credential no longer prevents the rest of the project's mirrors from being loaded and scheduled; only the bad mirror is skipped with a warning.
📝 WalkthroughWalkthrough
ChangesMirror Config Resilience and Test Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@server/src/main/java/com/linecorp/centraldogma/server/internal/storage/repository/DefaultMetaRepository.java`:
- Around line 191-193: In the DefaultMetaRepository class, change the
logger.debug call to logger.warn in the exception handler that logs when a
mirror configuration fails to convert to a mirror. This ensures that when a
mirror is intentionally skipped due to a conversion error, operators are
notified at the warn level in production logs without requiring debug logging to
be enabled, making production incidents visible.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 925ea8e7-8ad5-4463-8b94-4921fdec9e22
📒 Files selected for processing (2)
it/mirror/src/test/java/com/linecorp/centraldogma/it/mirror/git/ZoneAwareMirrorTest.javaserver/src/main/java/com/linecorp/centraldogma/server/internal/storage/repository/DefaultMetaRepository.java
| logger.debug("Failed to convert a mirror configuration to a mirror. " + | ||
| "project: {}, mirror: {}", parent().name(), mirrorConfig, | ||
| e); |
There was a problem hiding this comment.
Use warning-level logging when skipping malformed mirrors.
This path intentionally drops a mirror config; logging it at debug can make production incidents invisible unless debug is enabled. Promote this to warn so operators are notified when a mirror is skipped.
Proposed change
- logger.debug("Failed to convert a mirror configuration to a mirror. " +
- "project: {}, mirror: {}", parent().name(), mirrorConfig,
- e);
+ logger.warn("Skipping malformed mirror configuration. " +
+ "project: {}, mirror: {}", parent().name(), mirrorConfig,
+ e);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| logger.debug("Failed to convert a mirror configuration to a mirror. " + | |
| "project: {}, mirror: {}", parent().name(), mirrorConfig, | |
| e); | |
| logger.warn("Skipping malformed mirror configuration. " + | |
| "project: {}, mirror: {}", parent().name(), mirrorConfig, | |
| e); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@server/src/main/java/com/linecorp/centraldogma/server/internal/storage/repository/DefaultMetaRepository.java`
around lines 191 - 193, In the DefaultMetaRepository class, change the
logger.debug call to logger.warn in the exception handler that logs when a
mirror configuration fails to convert to a mirror. This ensures that when a
mirror is intentionally skipped due to a conversion error, operators are
notified at the warn level in production logs without requiring debug logging to
be enabled, making production incidents visible.
Motivation:
Modifications:
Result: