Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions .github/workflows/k8s-native-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1442,6 +1442,7 @@ jobs:
--set csiConfig.simplybk.ip="http://simplyblock-webappapi.simplyblock:5000" \
--set prometheus.server.persistentVolume.storageClass=${SC_NAME} \
--set controlplane.observability.enabled=true \
--set operatorMetrics.enabled=true \
--set opensearch.persistence.storageClass=${SC_NAME} \
--set controlplane.observability.minio.storageClass=${SC_NAME} \
$TLS_FLAGS $CSI_FLAGS
Expand Down Expand Up @@ -2778,13 +2779,25 @@ jobs:
# error rather than a no-op.
BAO_NS=vault
BAO_POD=openbao-0
# Every bao call needs an address on OpenBao's certificate and a
# token. The pod's own BAO_ADDR is https://127.0.0.1:8200, which the
# certificate carries no IP SAN for, and an exec carries no token:
# on run 45100042373 every call below exited 2, the seal wait ran
# its full five minutes, and the gateway got no IAM at all.
# setup-kms.sh talks to the same address and leaves the root token
# in ./openbao-init.txt. Tracing stays off while the token is in
# scope.
set +x
BAO_ADDR_IN=https://openbao.vault.svc:8200
BAO_ROOT=$(grep -E '^Initial Root Token:' ./openbao-init.txt 2>/dev/null | awk '{print $NF}' || true)
bao_exec() { kubectl exec -i -n $BAO_NS $BAO_POD -- env BAO_ADDR=$BAO_ADDR_IN BAO_TOKEN="$BAO_ROOT" bao "$@"; }
if ! kubectl get pod $BAO_POD -n $BAO_NS >/dev/null 2>&1; then
echo "::warning title=no OpenBao::OpenBao is not deployed, so the gateway serves its root account alone. TC-S3-006 reports itself not applicable rather than failing."
else
# The openbao-unsealer Deployment created earlier keeps this true;
# the wait is for the case where this step runs before it has acted.
for i in $(seq 1 30); do
SEALED=$(kubectl exec -n $BAO_NS $BAO_POD -- sh -c 'bao status -format=json 2>/dev/null || true' | grep -o '"sealed":[^,]*' | head -1 || true)
SEALED=$(bao_exec status -format=json 2>/dev/null | grep -o '"sealed":[^,]*' | head -1 || true)
echo "openbao: ${SEALED:-unknown} ($i/30)"
case "$SEALED" in *false*) break;; esac
sleep 10
Expand All @@ -2802,24 +2815,26 @@ jobs:
echo 'path "secret/metadata/s3" { capabilities = ["read","list"] }' >> /tmp/s3-policy.hcl
cat /tmp/s3-policy.hcl

kubectl cp /tmp/s3-policy.hcl $BAO_NS/$BAO_POD:/tmp/s3-policy.hcl || true
kubectl exec -n $BAO_NS $BAO_POD -- sh -c 'bao secrets enable -path=secret -version=2 kv' 2>&1 | tail -1 || true
kubectl exec -n $BAO_NS $BAO_POD -- sh -c 'bao auth enable approle' 2>&1 | tail -1 || true
kubectl exec -n $BAO_NS $BAO_POD -- sh -c 'bao policy write simplyblock-s3-policy /tmp/s3-policy.hcl' 2>&1 | tail -1 || true
kubectl exec -n $BAO_NS $BAO_POD -- sh -c 'bao write auth/approle/role/simplyblock-s3 token_policies=simplyblock-s3-policy token_ttl=1h token_max_ttl=24h' 2>&1 | tail -1 || true

ROLE_ID=$(kubectl exec -n $BAO_NS $BAO_POD -- sh -c 'bao read -field=role_id auth/approle/role/simplyblock-s3/role-id 2>/dev/null' || true)
SECRET_ID=$(kubectl exec -n $BAO_NS $BAO_POD -- sh -c 'bao write -f -field=secret_id auth/approle/role/simplyblock-s3/secret-id 2>/dev/null' || true)
if [ -n "${ROLE_ID:-}" ] && [ -n "${SECRET_ID:-}" ]; then
bao_exec secrets enable -path=secret -version=2 kv 2>&1 | tail -1 || true
bao_exec auth enable approle 2>&1 | tail -1 || true
bao_exec policy write simplyblock-s3-policy - < /tmp/s3-policy.hcl 2>&1 | tail -1 || true
bao_exec write auth/approle/role/simplyblock-s3 token_policies=simplyblock-s3-policy token_ttl=1h token_max_ttl=24h 2>&1 | tail -1 || true

ROLE_ID=$(bao_exec read -field=role_id auth/approle/role/simplyblock-s3/role-id 2>/dev/null || true)
SECRET_ID=$(bao_exec write -f -field=secret_id auth/approle/role/simplyblock-s3/secret-id 2>/dev/null || true)
# The gateway verifies OpenBao's certificate, which the chart's own
# CA signed, so it is handed that CA alongside the endpoint.
BAO_CA=$(kubectl exec -n $BAO_NS $BAO_POD -- cat /openbao/tls/ca.crt 2>/dev/null || true)
if [ -n "${ROLE_ID:-}" ] && [ -n "${SECRET_ID:-}" ] && [ -n "${BAO_CA:-}" ]; then
# set +x around these two deliberately. A role_id and a secret_id
# together ARE the gateway's IAM credential, and this workflow's
# trace is readable by anyone who can see the run.
set +x
kubectl create secret generic simplyblock-s3-iam -n $NS --from-literal=VGW_IAM_VAULT_ENDPOINT_URL=https://openbao-0.openbao-internal.vault.svc:8200 --from-literal=VGW_IAM_VAULT_SECRET_STORAGE_PATH=s3 --from-literal=VGW_IAM_VAULT_MOUNT_PATH=secret --from-literal=VGW_IAM_VAULT_ROLE_ID="$ROLE_ID" --from-literal=VGW_IAM_VAULT_ROLE_SECRET="$SECRET_ID" --dry-run=client -o yaml | kubectl apply -f - >/dev/null
kubectl create secret generic simplyblock-s3-iam -n $NS --from-literal=VGW_IAM_VAULT_ENDPOINT_URL=$BAO_ADDR_IN --from-literal=VGW_IAM_VAULT_SECRET_STORAGE_PATH=s3 --from-literal=VGW_IAM_VAULT_MOUNT_PATH=secret --from-literal=VGW_IAM_VAULT_ROLE_ID="$ROLE_ID" --from-literal=VGW_IAM_VAULT_ROLE_SECRET="$SECRET_ID" --from-literal=VGW_IAM_VAULT_SERVER_CERT="$BAO_CA" --dry-run=client -o yaml | kubectl apply -f - >/dev/null
set -x
echo "Secret/simplyblock-s3-iam written (values not echoed)"
else
echo "::warning title=no AppRole credential::could not read the AppRole role_id/secret_id, so the gateway falls back to its root account only"
echo "::warning title=no AppRole credential::could not read the AppRole role_id/secret_id or OpenBao's CA, so the gateway falls back to its root account only"
fi
fi

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/k8s-native-stress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,7 @@ jobs:
--set csiConfig.simplybk.ip="http://simplyblock-webappapi.simplyblock:5000" \
--set prometheus.server.persistentVolume.storageClass=${SC_NAME} \
--set controlplane.observability.enabled=true \
--set operatorMetrics.enabled=true \
--set opensearch.persistence.storageClass=${SC_NAME} \
--set controlplane.observability.minio.storageClass=${SC_NAME} \
$TLS_FLAGS $CSI_FLAGS
Expand Down
65 changes: 58 additions & 7 deletions e2e/e2e_tests/objectstore/test_objectstore_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,40 +709,83 @@ def run(self):

# ── TC-S3-021: kill one pod ─────────────────────────────────────
pods = s3.gateway_pods(self.k8s_utils, self.STORE)
existing = {p[0] for p in pods}
victim, victim_node, _, _ = pods[0]
delivered_before = s3.delivered_nodes(s3.s3bucket(self.k8s_utils, name))
self.k8s_utils._exec_kubectl(
f"kubectl delete pod {victim} -n {self.ns} --wait=false")

# Any new Ready pod is the replacement, wherever it landed. M-01 does
# not ask for the same node, and the gateway Deployment could not
# honor it: required pod anti-affinity on hostname and no
# nodeSelector, so while the victim is terminating its node is the
# one place the replacement may not go.
deadline = time.time() + 600
replacement = None
while time.time() < deadline:
rows = [p for p in s3.gateway_pods(self.k8s_utils, self.STORE)
if p[0] != victim and p[3] and p[1] == victim_node]
if p[0] not in existing and p[3]]
if rows:
replacement = rows[0]
break
time.sleep(5)
if not replacement:
self._log_gateway_placement()
raise s3.S3EvidenceError(
f"[TC-S3-021] no replacement gateway pod became Ready on "
f"{victim_node} within 10 minutes")
f"[TC-S3-021] no replacement for gateway pod {victim} (on "
f"{victim_node}) became Ready within 10 minutes")
new_node = replacement[1]
same_node = new_node in delivered_before
self.logger.info(
"[TC-S3-021] replacement %s on %s; bucket was delivered to %s",
replacement[0], new_node, delivered_before)

if not same_node:
# A node the bucket never reached needs a delivery before the pod
# can serve it. That delivery is the operator's job, so wait for
# the bucket's own status to name the node.
deadline = time.time() + 300
while time.time() < deadline:
if new_node in s3.delivered_nodes(
s3.s3bucket(self.k8s_utils, name)):
break
time.sleep(5)
else:
self._log_gateway_placement()
raise s3.S3EvidenceError(
f"[TC-S3-021] the replacement pod {replacement[0]} landed "
f"on {new_node}, which the bucket was not delivered to, "
f"and 5 minutes later status.mountDeliveredNodes still "
f"does not name it: "
f"{s3.delivered_nodes(s3.s3bucket(self.k8s_utils, name))}")

got = client.call(self.pod_cfg(replacement[2]), "get_object",
bucket=name, key="seed.bin", size=16 * 1024 ** 2,
seed="tc021")
if got.get("status") != 200 or not got.get("match"):
self._log_gateway_placement()
raise s3.S3EvidenceError(
f"[TC-S3-021] the replacement pod {replacement[0]} cannot "
f"serve a bucket that was already delivered to its node: "
f"{got}. M-01's claim is that the delivery is targeted at the "
f"node, not the pod, so no re-delivery is needed.")
f"[TC-S3-021] the replacement pod {replacement[0]} on "
f"{new_node} cannot serve a bucket "
+ ("that was already delivered to its node: "
if same_node else "the operator reports delivered there: ")
+ f"{got}. M-01's claim is that the delivery is targeted at "
f"the node, not the pod.")

after = s3.scrape_operator_metrics(self.k8s_utils)
deliveries_after = s3.metric_total(
after, s3.METRIC_DELIVERY_CALLS, operation="DeliverBucket")
redelivered = deliveries_after - deliveries_before
self.logger.info("[TC-S3-021] DeliverBucket calls across the kill: %s",
redelivered)
# "No re-delivery" is M-01's claim only for a pod that comes back on a
# node that already had the bucket. A new node needs one.
if same_node and redelivered:
self.logger.error(
"[TC-S3-021] FINDING: the replacement came back on %s, which "
"already had the bucket, and the operator still made %s "
"DeliverBucket call(s). M-01 says the delivery is per node.",
new_node, redelivered)

# ── TC-S3-022: a rolling update, under traffic ──────────────────
# Traffic during the roll, so the question is "what does a client
Expand Down Expand Up @@ -801,6 +844,8 @@ def drive():
self.record("tc021_pod_kill_and_roll", {
"replicas": replicas,
"killed_pod": victim, "node": victim_node,
"replacement_pod": replacement[0], "replacement_node": new_node,
"replacement_on_delivered_node": same_node,
"deliver_calls_across_kill": redelivered,
"roll_seconds": round(roll_seconds, 1),
"reads_ok": oks, "reads_failed": len(errors),
Expand All @@ -813,3 +858,9 @@ def drive():
"A multi-replica roll should be invisible to a client.",
replicas, len(errors), errors[:10])
self.logger.info("[TC-S3-021/022] PASS")

def _log_gateway_placement(self):
"""Log where every gateway pod is, so a placement failure is visible."""
self.k8s_utils._exec_kubectl(
f"kubectl get pods -n {self.ns} -l {s3.GATEWAY_LABEL}={self.STORE} "
f"-o wide")
Loading
Loading