k8s VM tests: wait for the store's active node after the unseal
The tests waited on `bao status`, which answers once the node is unsealed and before raft has elected it, so the first policy write raced the election and failed with "local node not active but active cluster node not found". `unseal_bao` unseals and then waits for sys/leader to say the node is the leader; the four tests that bootstrap the store use it at both unseal sites. Closes #6807
This commit is contained in:
parent
b7ce9ce661
commit
622b4fff96
1 changed files with 23 additions and 15 deletions
|
|
@ -60,6 +60,21 @@ def wait_images(node: QemuMachine, timeout: int = 120) -> None:
|
|||
)
|
||||
|
||||
|
||||
def unseal_bao(node: QemuMachine, init_file: str, timeout: int = 120) -> None:
|
||||
"""Unseals the store with the key `bao operator init` saved in `init_file`,
|
||||
then waits until the store's node is the active one. `bao status` answers
|
||||
as soon as the node is unsealed, before raft has elected it, and a write
|
||||
in that gap fails with "local node not active but active cluster node not
|
||||
found"."""
|
||||
node.succeed(f"bao operator unseal \"$(jq -r '.unseal_keys_b64[0]' {init_file})\"")
|
||||
# `sys/leader` needs no token. The answer is the bare object, or under
|
||||
# `.data` where the client wraps it.
|
||||
node.wait_until_succeeds(
|
||||
"bao read -format=json sys/leader | jq -e '(.data // .).is_self == true'",
|
||||
timeout=timeout,
|
||||
)
|
||||
|
||||
|
||||
def pod(node: QemuMachine, name: str) -> dict:
|
||||
return json.loads(kube(node, f"get pod {name} -o json"))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue