-
Notifications
You must be signed in to change notification settings - Fork 308
116 lines (101 loc) · 4.09 KB
/
Copy pathk8s-chaos.yml
File metadata and controls
116 lines (101 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# Kubernetes (kind) chaos scenarios. Gated: runs only when the chaos harness,
# the engine, or the docker artifacts change, plus a nightly cron schedule and
# on demand — it is deliberately off the per-PR critical path, since the
# process-based chaos harness already covers HA on every PR.
name: k8s-chaos
on:
pull_request:
paths:
- "chaos-testing/**"
- "ballista/**"
- "Cargo.toml"
- "Cargo.lock"
- "rust-toolchain.toml"
- "dev/docker/chaos.Dockerfile"
- "dev/build-chaos-docker.sh"
- ".github/workflows/k8s-chaos.yml"
# docs-only changes cannot affect this job; exclusions are applied last
- "!**/*.md"
schedule:
# Nightly cron (not the Rust nightly toolchain — this job builds with stable).
- cron: "0 6 * * *"
workflow_dispatch:
concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true
# Minimal token: this job only reads the repository.
permissions:
contents: read
env:
# Pinned tool versions, installed via curl to avoid marketplace actions that
# must be on the ASF allowlist.
KIND_VERSION: v0.30.0
KUBECTL_VERSION: v1.31.4
CLUSTER_NAME: ballista-chaos
CHAOS_FIXTURE_DIR: /tmp/ballista-chaos-fixtures
jobs:
k8s-chaos:
name: kind chaos scenarios
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
with:
fetch-depth: 1
- name: Install protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Setup Rust toolchain
run: |
rustup update stable
rustup toolchain install stable
rustup default stable
- uses: swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 #2.9.1
- name: Install kind and kubectl
run: |
curl -fsSLo ./kind "https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64"
curl -fsSLo ./kubectl "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
chmod +x ./kind ./kubectl
sudo mv ./kind ./kubectl /usr/local/bin/
- name: Create kind cluster
run: |
mkdir -p "${CHAOS_FIXTURE_DIR}"
kind create cluster --name "${CLUSTER_NAME}" --config chaos-testing/k8s/kind-config.yaml
- name: Build the chaos image
run: ./dev/build-chaos-docker.sh
- name: Load the chaos image into kind
run: kind load docker-image ballista-chaos:test --name "${CLUSTER_NAME}"
- name: Run the kind chaos scenarios
env:
CHAOS_BACKEND: kind
# Keep namespaces on failure so the diagnostics step below can collect
# logs — teardown would otherwise delete them. The runner is ephemeral.
CHAOS_KEEP_NS: "1"
run: |
cargo test -p ballista-chaos --features k8s --test k8s -- --test-threads=1 --nocapture
- name: Dump cluster state on failure
if: failure()
run: |
kubectl get pods -A -o wide || true
for ns in $(kubectl get ns -o name | grep chaos- || true); do
kubectl logs -n "${ns#namespace/}" -l app=ballista-scheduler --tail=-1 || true
kubectl logs -n "${ns#namespace/}" -l app=ballista-executor --all-containers --tail=-1 || true
done