-
Notifications
You must be signed in to change notification settings - Fork 0
<fix>[vm]: add conditional stop target precheck #4673
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,5 +13,7 @@ | |
| */ | ||
| public enum HostAllocationPurpose { | ||
| ALLOCATE, | ||
| LIST_CANDIDATES | ||
| LIST_CANDIDATES, | ||
| HA_PRECHECK, | ||
| HA_START | ||
|
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Expect explicit handling for the new allocation purposes.
rg -n -C 5 '\b(HostAllocationPurpose|HA_PRECHECK|HA_START|LIST_CANDIDATES|ALLOCATE)\b' --glob '*.java' .Repository: MatheMatrix/zstack Length of output: 14381 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- changed files ---'
git diff --stat
printf '%s\n' '--- all purpose references ---'
rg -n -C 4 '\b(HostAllocationPurpose|HA_PRECHECK|HA_START|LIST_CANDIDATES|ALLOCATE|getPurpose\(\)|setPurpose\()\b' \
--glob '!target/**' --glob '!build/**' .
printf '%s\n' '--- purpose-related control flow ---'
rg -n -C 8 'getPurpose\(\)|HostAllocationPurpose\.[A-Z_]+|switch\s*\([^)]*purpose|switch\s*\([^)]*Purpose' \
--glob '*.java' --glob '*.groovy' --glob '*.kt' --glob '*.xml' .Repository: MatheMatrix/zstack Length of output: 50374 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- exact new enum references ---'
rg -n -C 3 'HA_PRECHECK|HA_START' --glob '!target/**' --glob '!build/**' . || true
printf '%s\n' '--- HostAllocationPurpose references ---'
rg -n -C 3 'HostAllocationPurpose' --glob '*.java' --glob '*.groovy' --glob '*.kt' . || true
printf '%s\n' '--- candidate-host message flow ---'
rg -n -C 6 'GetVmStartingCandidateClustersHostsMsg|HostAllocatorSpec\.fromAllocationMsg|fromAllocationMsg\(' \
--glob '*.java' --glob '*.groovy' --glob '*.kt' . || true
printf '%s\n' '--- purpose consumers and branches ---'
rg -n -C 8 'getPurpose\(\)|setPurpose\(|HostAllocationPurpose\.[A-Z_]+' \
header compute plugin kvm --glob '*.java' --glob '*.groovy' --glob '*.kt' 2>/dev/null || true
printf '%s\n' '--- enum serialization/conversion hooks ---'
rg -n -C 5 'enum.*HostAllocationPurpose|valueOf\(.*Purpose|Enum\.valueOf|ObjectMapper|Jackson|Gson|serialize|deserialize|toJson|fromJson' \
header compute plugin kvm --glob '*.java' --glob '*.groovy' --glob '*.kt' 2>/dev/null || trueRepository: MatheMatrix/zstack Length of output: 50375 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import subprocess
files = subprocess.check_output(["git", "ls-files"], text=True).splitlines()
suffixes = {".java", ".groovy", ".kt", ".xml", ".json"}
terms = (
"HA_PRECHECK",
"HA_START",
"HostAllocationPurpose",
"GetVmStartingCandidateClustersHostsMsg",
)
for term in terms:
print(f"--- {term} ---")
hits = []
for name in files:
path = Path(name)
if path.suffix not in suffixes:
continue
try:
lines = path.read_text(errors="ignore").splitlines()
except OSError:
continue
for number, line in enumerate(lines, 1):
if term in line:
hits.append((name, number, line.strip()))
for name, number, line in hits:
print(f"{name}:{number}:{line}")
print(f"count={len(hits)}")
print("--- candidate-host handlers ---")
for name in files:
path = Path(name)
if path.suffix != ".java":
continue
try:
text = path.read_text(errors="ignore")
except OSError:
continue
if "GetVmStartingCandidateClustersHostsMsg" not in text:
continue
lines = text.splitlines()
for number, line in enumerate(lines, 1):
if "GetVmStartingCandidateClustersHostsMsg" in line:
start = max(1, number - 12)
end = min(len(lines), number + 30)
print(f"\n{name}:{number}")
for i in range(start, end + 1):
print(f"{i}:{lines[i-1]}")
PYRepository: MatheMatrix/zstack Length of output: 40219 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import subprocess
files = [Path(x) for x in subprocess.check_output(["git", "ls-files"], text=True).splitlines()]
def show(term, allowed_suffixes={".java"}):
print(f"--- {term} ---")
count = 0
for path in files:
if path.suffix not in allowed_suffixes:
continue
try:
lines = path.read_text(errors="ignore").splitlines()
except OSError:
continue
for number, line in enumerate(lines, 1):
if term in line:
print(f"{path}:{number}:{line.strip()}")
count += 1
print(f"count={count}")
show("HostAllocatorSpec")
show("DesignatedAllocateHostMsg")
show("getPurpose()")
show("HostAllocationPurpose.")
show("switch (spec.getPurpose")
show("switch (msg.getPurpose")
print("--- allocator files containing purpose logic ---")
for path in files:
if path.suffix != ".java" or "allocator" not in str(path).lower():
continue
try:
lines = path.read_text(errors="ignore").splitlines()
except OSError:
continue
matches = [
(number, line.strip())
for number, line in enumerate(lines, 1)
if "purpose" in line.lower()
]
if matches:
print(path)
for number, line in matches[:40]:
print(f" {number}:{line}")
PYRepository: MatheMatrix/zstack Length of output: 17634 补齐 两个枚举值目前仅在 🤖 Prompt for AI Agents |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
补充运行状态的 API 操作白名单。
Line 856将APIGetVmStartingCandidateClustersHostsMsg传给validateOperationByState。但compute/src/main/java/org/zstack/compute/vm/AbstractVmInstance.java的VmInstanceState.Running白名单只包含GetVmStartingCandidateClustersHostsMsg,不包含APIGetVmStartingCandidateClustersHostsMsg。因此,运行中的 VM 调用该 API 时会在Line 857到Line 860直接返回SysErrors.OPERATION_ERROR,不会发送内部查询消息。这与本 PR 允许运行中 VM 查询启动候选主机的目标不一致。请将
APIGetVmStartingCandidateClustersHostsMsg.class.getName()加入VmInstanceState.Running的允许操作列表,并覆盖 Running 与 Stopped 状态测试。建议修复
allowedOperations.addState(VmInstanceState.Running, + APIGetVmStartingCandidateClustersHostsMsg.class.getName(), GetVmStartingCandidateClustersHostsMsg.class.getName(),🤖 Prompt for AI Agents