Skip to content

fix(upgrade): compare incoming version in updateAgentVersion#3879

Open
zstack-robot-2 wants to merge 1 commit into5.5.16from
sync/xinhao.huang/fix/ZSTAC-84886
Open

fix(upgrade): compare incoming version in updateAgentVersion#3879
zstack-robot-2 wants to merge 1 commit into5.5.16from
sync/xinhao.huang/fix/ZSTAC-84886

Conversation

@zstack-robot-2
Copy link
Copy Markdown
Collaborator

Background

UpgradeChecker.updateAgentVersion early-returned when DB.expectVersion equals DB.currentVersion, ignoring the new version reported by ping. Once a host record reached the stable current == expect state, any subsequent ping bringing a different version was silently dropped — breaking grayscale upgrade version tracking.

This also explains the intermittent failure of premium_premium_kvm_upgrade_GrayscaleUpgradeCase: when HostTracker's background ping happened to fire between enabling GRAYSCALE_UPGRADE and overriding the KVM_PING simulator, it created a stable VO row, after which the test's manually issued ping carrying version=4.7.21 was dropped by the buggy early-return, and the assertion currentVersion == "4.7.21" failed.

Fix

Compare DB current/expect against the incoming parameters instead of comparing DB fields to each other; update both fields together so expectVersion stays in sync with dbf.getDbVersion().

Jira

Resolves: ZSTAC-84886

sync from gitlab !9759

UpgradeChecker.updateAgentVersion early-returned when DB.expectVersion
equals DB.currentVersion, ignoring the new version reported by ping.
Once a host record reached the stable current==expect state, any
subsequent ping bringing a different version was silently dropped,
breaking grayscale upgrade tracking and causing GrayscaleUpgradeCase to
fail intermittently when HostTracker's background ping created the
stable record before the test mutated the simulator.

Compare DB current/expect against the incoming parameters instead, and
update both fields together so expectVersion stays in sync with
dbf.getDbVersion().

Resolves: ZSTAC-84886

Change-Id: I63636b6f696b6463756f656c627367617a6d6a79
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent 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: f1f556fa-43f8-42bc-b56f-2beabbcac7ec

📥 Commits

Reviewing files that changed from the base of the PR and between 3b7611c and 8c6f544.

📒 Files selected for processing (1)
  • core/src/main/java/org/zstack/core/upgrade/UpgradeChecker.java

演练

updateAgentVersion 方法的逻辑已修改。现在仅当传入的两个值都与存储的字段匹配时,才判定为"无变化"。新实现会记录原始值、同时更新当前版本和期望版本字段、记录变更日志,并始终执行数据库更新操作。

变更

内聚体 / 文件 摘要
版本检查逻辑优化
core/src/main/java/org/zstack/core/upgrade/UpgradeChecker.java
修改 updateAgentVersion 方法的比较逻辑,改为同时验证当前版本和期望版本两个字段是否需要更新,确保期望版本字段也能被正确更新,并增加日志记录原始值和新值。

评估代码审查工作量

🎯 2 (简单) | ⏱️ ~8 分钟

🐰 竖起长耳朵,我看到了妙处

两个版本字段,如今齐声共舞,

期望不再被遗忘在角落,

更新的日志,记录了每次变革,

小小的修正,大大的完整!✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题遵循 [scope]: 格式,包含 'fix[upgrade]: compare incoming version in updateAgentVersion',长度 60 字符,在 72 字符限制内。
Description check ✅ Passed 描述清晰地阐述了问题背景、修复方案和相关 Jira 问题,与变更集完全相关。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/xinhao.huang/fix/ZSTAC-84886

Review rate limit: 4/5 reviews remaining, refill in 12 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant