This commit is contained in:
@@ -584,13 +584,18 @@ gcr_vm_rebuild_request() {
|
||||
'{image:$image, user_data:$user_data}')" || return 1
|
||||
gcr_hcloud_req POST "/servers/$rebuild_vm_id/actions/rebuild" \
|
||||
"$rebuild_payload" || return 1
|
||||
jq -er --arg vm "$rebuild_vm_id" \
|
||||
rebuild_action_id="$(jq -er --arg vm "$rebuild_vm_id" \
|
||||
'.action
|
||||
| select((.id | type) == "number")
|
||||
| select(.command == "rebuild")
|
||||
| select(.command == "rebuild_server")
|
||||
| select(.status == "running" or .status == "success")
|
||||
| select([.resources[]? | select(.type == "server") | (.id | tostring)] == [$vm])
|
||||
| .id' "$GCR_LAST_BODY"
|
||||
| .id' "$GCR_LAST_BODY")" || {
|
||||
gcr_log warn --ns=hcloud \
|
||||
"rebuild response validation failed server=$rebuild_vm_id expected_command=rebuild_server"
|
||||
return 1
|
||||
}
|
||||
printf '%s' "$rebuild_action_id"
|
||||
}
|
||||
|
||||
# Prints running or success. Provider-reported errors and malformed/mismatched
|
||||
@@ -605,11 +610,15 @@ gcr_vm_rebuild_action_status() {
|
||||
--arg action "$rebuild_action_id" \
|
||||
'.action
|
||||
| select((.id | tostring) == $action)
|
||||
| select(.command == "rebuild")
|
||||
| select(.command == "rebuild_server")
|
||||
| select([.resources[]? | select(.type == "server") | (.id | tostring)] == [$vm])
|
||||
| .status
|
||||
| select(. == "running" or . == "success" or . == "error")' \
|
||||
"$GCR_LAST_BODY")" || return 1
|
||||
"$GCR_LAST_BODY")" || {
|
||||
gcr_log warn --ns=hcloud \
|
||||
"rebuild action validation failed server=$rebuild_vm_id action=$rebuild_action_id expected_command=rebuild_server"
|
||||
return 1
|
||||
}
|
||||
[ "$rebuild_status" != error ] || return 1
|
||||
printf '%s' "$rebuild_status"
|
||||
}
|
||||
@@ -620,7 +629,7 @@ gcr_vm_verify_rebuilt() {
|
||||
verify_vm_id="$1"; verify_type="$2"; verify_location="$3"
|
||||
verify_arch="$4"; verify_image="$5"
|
||||
gcr_hcloud_req GET "/servers/$verify_vm_id" || return 1
|
||||
jq -er --arg vm "$verify_vm_id" --arg type "$verify_type" \
|
||||
verify_ip="$(jq -er --arg vm "$verify_vm_id" --arg type "$verify_type" \
|
||||
--arg location "$verify_location" --arg arch "$verify_arch" \
|
||||
--arg image "$verify_image" \
|
||||
'.server
|
||||
@@ -628,10 +637,15 @@ gcr_vm_verify_rebuilt() {
|
||||
| select(.status == "running")
|
||||
| select((.server_type.name // "") == $type)
|
||||
| select((.server_type.architecture // "") == $arch)
|
||||
| select((.datacenter.location.name // "") == $location)
|
||||
| select((.location.name // .datacenter.location.name // "") == $location)
|
||||
| select((.image.id | tostring) == $image)
|
||||
| .public_net.ipv4.ip
|
||||
| select(type == "string" and length > 0)' "$GCR_LAST_BODY"
|
||||
| select(type == "string" and length > 0)' "$GCR_LAST_BODY")" || {
|
||||
gcr_log warn --ns=hcloud \
|
||||
"rebuilt server validation failed server=$verify_vm_id expected_type=$verify_type expected_location=$verify_location expected_arch=$verify_arch expected_image=$verify_image"
|
||||
return 1
|
||||
}
|
||||
printf '%s' "$verify_ip"
|
||||
}
|
||||
|
||||
# Stop idle runners so Gitea cannot schedule work before atomic reuse claim.
|
||||
|
||||
Reference in New Issue
Block a user