[ceph]: skip ceph ops on non-enabled cluster timeout#3947
[ceph]: skip ceph ops on non-enabled cluster timeout#3947zstack-robot-1 wants to merge 2 commits into
Conversation
Skip Ceph secret creation when cluster is not Enabled to prevent reconnect timeout. Add 5-minute await timeout to FutureCompletion to prevent permanent blocking. Resolves: ZSTAC-80275 Change-Id: Iaa61109103cc5b4ee9bf86485e1777456b172b56
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough在 connectionReestablished 中按主机 clusterUuid 查询 ClusterVO;若无记录或集群状态非 ClusterState.Enabled 则记录日志并返回;否则继续创建 Ceph 密钥,等待最多 5 分钟再检查结果。 变更说明集群状态保护与超时管理
Sequence Diagram(s)sequenceDiagram
participant CephKvmExtension
participant DB as ClusterVO(dbf)
participant CephSecretCreator
participant Completion
CephKvmExtension->>DB: dbf.findByUuid(host.clusterUuid)
alt ClusterVO not found
CephKvmExtension->>CephKvmExtension: log.warn and return
else ClusterVO found but state != ClusterState.Enabled
CephKvmExtension->>CephKvmExtension: log.info and return
else ClusterState.Enabled
CephKvmExtension->>CephSecretCreator: invoke createCephSecret
CephSecretCreator->>Completion: start and await(5 minutes)
Completion->>CephKvmExtension: isSuccess / result
end
代码审查工作量估计🎯 3 (中等) | ⏱️ ~20 分钟 诗
🚥 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 docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
plugin/ceph/src/main/java/org/zstack/storage/ceph/primary/CephKvmExtension.java (1)
82-82: ⚡ Quick win将超时时间提取为具名常量,避免魔法值。
Line 82 直接写
5可读性偏弱,后续调整也容易遗漏;建议提取为类级常量。♻️ 建议修改
public class CephKvmExtension implements KVMHostConnectExtensionPoint, HostConnectionReestablishExtensionPoint { private static final CLogger logger = Utils.getLogger(CephKvmExtension.class); + private static final long SECRET_CREATION_AWAIT_TIMEOUT_MILLIS = TimeUnit.MINUTES.toMillis(5); @@ - completion.await(TimeUnit.MINUTES.toMillis(5)); + completion.await(SECRET_CREATION_AWAIT_TIMEOUT_MILLIS);As per coding guidelines "避免使用魔法值(Magic Value):直接使用未经定义的数值或字符串应替换为枚举或常量。"
🤖 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 `@plugin/ceph/src/main/java/org/zstack/storage/ceph/primary/CephKvmExtension.java` at line 82, Replace the magic literal 5 in the completion.await(TimeUnit.MINUTES.toMillis(5)) call by introducing a descriptive class-level constant (e.g., COMPLETION_AWAIT_TIMEOUT_MINUTES or TIMEOUT_MINUTES) in CephKvmExtension and use that constant in the await call (completion.await(TimeUnit.MINUTES.toMillis(COMPLETION_AWAIT_TIMEOUT_MINUTES))); ensure the constant is static final and documented so future adjustments are centralized.
🤖 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.
Nitpick comments:
In
`@plugin/ceph/src/main/java/org/zstack/storage/ceph/primary/CephKvmExtension.java`:
- Line 82: Replace the magic literal 5 in the
completion.await(TimeUnit.MINUTES.toMillis(5)) call by introducing a descriptive
class-level constant (e.g., COMPLETION_AWAIT_TIMEOUT_MINUTES or TIMEOUT_MINUTES)
in CephKvmExtension and use that constant in the await call
(completion.await(TimeUnit.MINUTES.toMillis(COMPLETION_AWAIT_TIMEOUT_MINUTES)));
ensure the constant is static final and documented so future adjustments are
centralized.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)
Review profile: CHILL
Plan: Pro
Run ID: 426ed645-091f-47b6-b49d-d76d35791157
📒 Files selected for processing (1)
plugin/ceph/src/main/java/org/zstack/storage/ceph/primary/CephKvmExtension.java
|
Comment from yaohua.wu: Review: MR !9838 — ZSTAC-80275P1 — High
P2 — Moderate
总结本 MR 针对 ZSTAC-80275(集群停用状态下重连 Ceph 主存储超时)做了两处修复:① 在 Verdict: REVISION_REQUIRED🤖 Robot Reviewer |
7139ea4 to
2dd5d63
Compare
P1: Separate null check from state check. When findByUuid returns null (cluster deleted during race with reconnect callback), the original `cluster != null && cluster.getState() != Enabled` short-circuits false and falls through to createSecret(), causing downstream errors. Now null cluster triggers early return with warn-level log. P2: Improve comment to describe the constraint technically instead of only referencing the ticket key. Resolves: ZSTAC-80275
2dd5d63 to
918a667
Compare
Resolves: ZSTAC-80275
sync from gitlab !9838