<fix>[host]: Supports returning cpuCoreNum when getting capacity#4105
<fix>[host]: Supports returning cpuCoreNum when getting capacity#4105ZStack-Robot wants to merge 16 commits into
Conversation
DBImpact Resolves: ZSTAC-81065 Change-Id: I6563736d6769787876777a63796b697474617a66
…plit-brain When a management node departs, its VM skip-trace entries were immediately removed. If VMs were still being started by kvmagent, the next VM sync would falsely detect them as Stopped and trigger HA, causing split-brain. Fix: transfer departed MN skip-trace entries to an orphaned set with 10-minute TTL instead of immediate deletion. VMs in the orphaned set remain skip-traced until the TTL expires or they are explicitly continued, preventing false HA triggers during MN restart scenarios. Resolves: ZSTAC-80821 Change-Id: I3222e260b2d7b33dc43aba0431ce59a788566b34 Conflicts: plugin/kvm/src/main/java/org/zstack/kvm/KvmVmSyncPingTask.java
…anup Resolves: ZSTAC-80821 Change-Id: I59284c4e69f5d2ee357b1836b7c243200e30949a
Resolves: ZSTAC-80821 Change-Id: Ia9a9597feceb96b3e6e22259e2d0be7bde8ae499
<fix>[ha]: defer skip-trace list cleanup on MN departure to prevent split-brain See merge request zstackio/zstack!9626
<fix>[conf]: bump version to 4.8.37 See merge request zstackio/zstack!9608
DBImpact Change-Id: I7473677a7265777a616f6d706776706e67626173
Resolves: ZSTAC-69124 Change-Id: I616e64727376796e696d6f6779776e7378727076 (cherry picked from commit 85c9b9a)
stdout and stderr will both write into ssh output Resolves: ZSTAC-69124 Change-Id: I6b68767166687072756e64776d6d6377746a6a6a (cherry picked from commit 5bf5b0a)
top is unused after storage migration even if its snapshot referenced by other volumes. only skip trash volume when its snapshots are inner snapshot. Resolves: ZSTAC-71514 Change-Id: I636b6d726d6c757478737869726f6a777a736663 (cherry picked from commit 866b137)
If fast cloning is performed on the data volume, it will result in image cache filtering error, further causing the image cache to be unable to be cleared Resolves/Related: ZSTAC-71233 Change-Id: I6d716679646d74726e69726b7968636667746b6f (cherry picked from commit ff9bf21)
|
Warning Review limit reached
More reviews will be available in 18 minutes and 6 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (32)
Walkthrough该PR扩展主机容量跟踪系统以支持CPU核心数字段,从KVM代理采集、消息传递、模型映射到数据库持久化的完整链路;同时为License实体添加配额类型字段,并调整License容量请求的资源类型验证规则。 ChangesHost Capacity and License Enhancements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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)
Comment |
Resolves: ZSTAC-76704 Change-Id: I6d66726c636e6e707076667772707a7578777379 (cherry picked from commit 6efc547)
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 `@conf/db/upgrade/V4.8.36__schema.sql`:
- Line 47: Alter the HostCapacityVO change to explicitly target the zstack
schema and follow a safe migration: add zstack.HostCapacityVO.cpuCoreNum as int
unsigned NULL DEFAULT 0, run a backfill query to populate historical rows (e.g.,
set cpuCoreNum = 0 where NULL), then alter zstack.HostCapacityVO to modify
cpuCoreNum to NOT NULL DEFAULT 0; also replace the SSOClientAttributeVO
timestamp defaults that use '0000-00-00 00:00:00' by setting
SSOClientAttributeVO.createDate and SSOClientAttributeVO.lastOpDate to DEFAULT
CURRENT_TIMESTAMP (and add ON UPDATE CURRENT_TIMESTAMP for lastOpDate if
intended) to remove the forbidden zero-date defaults.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 131f1c6c-6f5f-4042-a1be-49086eced651
📒 Files selected for processing (11)
compute/src/main/java/org/zstack/compute/allocator/HostAllocatorManagerImpl.javaconf/db/upgrade/V4.8.36__schema.sqlheader/src/main/java/org/zstack/header/allocator/HostCapacityInventory.javaheader/src/main/java/org/zstack/header/allocator/HostCapacityVO.javaheader/src/main/java/org/zstack/header/allocator/HostCapacityVO_.javaheader/src/main/java/org/zstack/header/cluster/ReportHostCapacityMessage.javaplugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.javaplugin/kvm/src/main/java/org/zstack/kvm/KVMHost.javasdk/src/main/java/org/zstack/sdk/LicenseInventory.javasdk/src/main/java/org/zstack/sdk/license/api/server/RequestLicenseCapacityAction.javatest/src/test/groovy/org/zstack/test/integration/kvm/capacity/CheckHostCapacityWhenAddHostCase.groovy
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
|
||
| ALTER TABLE `zstack`.`LicenseHistoryVO` ADD COLUMN `quotaType` varchar(64) DEFAULT 'None'; | ||
| ALTER TABLE HostCapacityVO ADD cpuCoreNum int unsigned NOT NULL DEFAULT 0; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n 'ALTER TABLE.*HostCapacityVO|cpuCoreNum|NOT NULL' conf/db/upgrade/V4.8.36__schema.sqlRepository: MatheMatrix/zstack
Length of output: 1659
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="conf/db/upgrade/V4.8.36__schema.sql"
echo "=== file line count ==="
wc -l "$FILE"
echo "=== context around cpuCoreNum add (lines 35-70) ==="
nl -ba "$FILE" | sed -n '35,70p'
echo "=== all occurrences of DEFAULT '0000-00-00 00:00:00' ==="
rg -n "DEFAULT '0000-00-00 00:00:00'" "$FILE" || true
echo "=== occurrences of HostCapacityVO in this file ==="
rg -n "HostCapacityVO" "$FILE" || true
echo "=== occurrences of SSOClientAttributeVO in this file ==="
rg -n "SSOClientAttributeVO" "$FILE" || trueRepository: MatheMatrix/zstack
Length of output: 238
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="conf/db/upgrade/V4.8.36__schema.sql"
echo "=== file line count ==="
wc -l "$FILE"
echo "=== context around cpuCoreNum add (lines 35-70) ==="
nl -ba "$FILE" | sed -n '35,70p'
echo "=== all occurrences of DEFAULT '0000-00-00 00:00:00' ==="
rg -n "DEFAULT '0000-00-00 00:00:00'" "$FILE" || true
echo "=== occurrences of HostCapacityVO in this file ==="
rg -n "HostCapacityVO" "$FILE" || true
echo "=== occurrences of SSOClientAttributeVO in this file ==="
rg -n "SSOClientAttributeVO" "$FILE" || trueRepository: MatheMatrix/zstack
Length of output: 238
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="conf/db/upgrade/V4.8.36__schema.sql"
echo "=== context around cpuCoreNum add (lines 35-70) ==="
cat -n "$FILE" | sed -n '35,70p'
echo "=== all occurrences of DEFAULT '0000-00-00 00:00:00' ==="
rg -n "DEFAULT '0000-00-00 00:00:00'" "$FILE" || true
echo "=== occurrences of HostCapacityVO in this file ==="
rg -n "HostCapacityVO" "$FILE" || true
echo "=== occurrences of SSOClientAttributeVO in this file ==="
rg -n "SSOClientAttributeVO" "$FILE" || trueRepository: MatheMatrix/zstack
Length of output: 2270
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="conf/db/upgrade/V4.8.36__schema.sql"
echo "=== context around cpuCoreNum add (lines 35-70) ==="
cat -n "$FILE" | sed -n '35,70p'
echo "=== all occurrences of DEFAULT '0000-00-00 00:00:00' ==="
rg -n "DEFAULT '0000-00-00 00:00:00'" "$FILE" || true
echo "=== occurrences of HostCapacityVO in this file ==="
rg -n "HostCapacityVO" "$FILE" || true
echo "=== occurrences of SSOClientAttributeVO in this file ==="
rg -n "SSOClientAttributeVO" "$FILE" || trueRepository: MatheMatrix/zstack
Length of output: 2270
修复 conf/db/upgrade/V4.8.36__schema.sql:补齐 zstack schema、对历史数据先回填再收敛 NOT NULL,并移除 DEFAULT '0000-00-00 00:00:00'
-
第47行当前写法
ALTER TABLE HostCapacityVO ... ADD cpuCoreNum ... NOT NULL DEFAULT 0未显式限定zstackschema,且未按规范先处理历史数据再收敛为NOT NULL,存在升级风险。🛠 建议修正
-ALTER TABLE HostCapacityVO ADD cpuCoreNum int unsigned NOT NULL DEFAULT 0; +ALTER TABLE `zstack`.`HostCapacityVO` ADD COLUMN `cpuCoreNum` int unsigned DEFAULT NULL; +UPDATE `zstack`.`HostCapacityVO` SET `cpuCoreNum` = 0 WHERE `cpuCoreNum` IS NULL; +ALTER TABLE `zstack`.`HostCapacityVO` MODIFY COLUMN `cpuCoreNum` int unsigned NOT NULL DEFAULT 0;
-
第60-61行:
SSOClientAttributeVO.lastOpDate与SSOClientAttributeVO.createDate使用DEFAULT '0000-00-00 00:00:00',违反禁用项要求,应替换为DEFAULT CURRENT_TIMESTAMP(并与ON UPDATE语义一致)。
📝 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.
| ALTER TABLE HostCapacityVO ADD cpuCoreNum int unsigned NOT NULL DEFAULT 0; | |
| ALTER TABLE `zstack`.`HostCapacityVO` ADD COLUMN `cpuCoreNum` int unsigned DEFAULT NULL; | |
| UPDATE `zstack`.`HostCapacityVO` SET `cpuCoreNum` = 0 WHERE `cpuCoreNum` IS NULL; | |
| ALTER TABLE `zstack`.`HostCapacityVO` MODIFY COLUMN `cpuCoreNum` int unsigned NOT NULL DEFAULT 0; |
🤖 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 `@conf/db/upgrade/V4.8.36__schema.sql` at line 47, Alter the HostCapacityVO
change to explicitly target the zstack schema and follow a safe migration: add
zstack.HostCapacityVO.cpuCoreNum as int unsigned NULL DEFAULT 0, run a backfill
query to populate historical rows (e.g., set cpuCoreNum = 0 where NULL), then
alter zstack.HostCapacityVO to modify cpuCoreNum to NOT NULL DEFAULT 0; also
replace the SSOClientAttributeVO timestamp defaults that use '0000-00-00
00:00:00' by setting SSOClientAttributeVO.createDate and
SSOClientAttributeVO.lastOpDate to DEFAULT CURRENT_TIMESTAMP (and add ON UPDATE
CURRENT_TIMESTAMP for lastOpDate if intended) to remove the forbidden zero-date
defaults.
1b8944f to
c442200
Compare
<fix>[backport]: cherry-pick fixes to 4.8.38 (ZSTAC-69412, ZSTAC-74250) See merge request zstackio/zstack!9997
<fix>[imagecache]: fix unable to clear image cache See merge request zstackio/zstack!9999
fix(storage): markSnapshotAsVolume before delete origin volume bits See merge request zstackio/zstack!9998
Resolves: ZSTAC-77257 Change-Id: I737577257765547655441897574646678757a7a734578 (cherry picked from commit 9c99f99)
|
Comment from gitlab: 自上次添加REVIEWED标签(2026-05-27 18:08:48.000Z)后, 有新的COMMIT更新(2026-05-28 10:15:28.669Z), 所以移除了REVIEWED标签 |
c442200 to
115ac2b
Compare
Backport to 4.8.36.
Original MR: http://dev.zstack.io:9080/zstackio/zstack/-/merge_requests/8458
Resolves: ZSTAC-78594
sync from gitlab !10001