-
Notifications
You must be signed in to change notification settings - Fork 109
232 lines (210 loc) · 8.1 KB
/
Copy pathgke-connectivity-smoke.yml
File metadata and controls
232 lines (210 loc) · 8.1 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: GKE Connectivity Smoke
on:
push:
paths:
- ".github/workflows/gke-connectivity-smoke.yml"
pull_request:
paths:
- ".github/workflows/gke-connectivity-smoke.yml"
workflow_dispatch:
inputs:
project_id:
description: "GCP project ID. Defaults to vars.GCP_PROJECT_ID."
required: false
type: string
cluster_name:
description: "GKE cluster name. Defaults to vars.GKE_CLUSTER_NAME."
required: false
type: string
cluster_location:
description: "GKE cluster zone or region. Defaults to vars.GKE_CLUSTER_LOCATION."
required: false
type: string
workload_identity_provider:
description: "Workload Identity Provider. Defaults to vars.GCP_WORKLOAD_IDENTITY_PROVIDER."
required: false
type: string
node_pool:
description: "Existing GKE node pool to verify."
required: true
default: "v6e-4x4-perf-accuracy-tests"
type: string
namespace:
description: "Namespace for Kubernetes RBAC checks."
required: true
default: "default"
type: string
run_workload:
description: "Create and run a short multi-host TPU Kubernetes Job."
required: true
default: false
type: boolean
concurrency:
group: gke-connectivity-smoke-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
id-token: write
jobs:
connectivity:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
PROJECT_ID: ${{ inputs.project_id || vars.GCP_PROJECT_ID }}
CLUSTER_NAME: ${{ inputs.cluster_name || vars.GKE_CLUSTER_NAME }}
CLUSTER_LOCATION: ${{ inputs.cluster_location || vars.GKE_CLUSTER_LOCATION }}
WORKLOAD_IDENTITY_PROVIDER: ${{ inputs.workload_identity_provider || vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }}
NODE_POOL: ${{ inputs.node_pool || 'v6e-4x4-perf-accuracy-tests' }}
NAMESPACE: ${{ inputs.namespace || 'default' }}
RUN_WORKLOAD: ${{ inputs.run_workload || github.event_name == 'push' }}
WORKLOAD_NAME: gke-tpu-smoke-${{ github.run_id }}
steps:
- name: Validate smoke test configuration
shell: bash
run: |
set -euo pipefail
missing=0
for name in PROJECT_ID CLUSTER_NAME CLUSTER_LOCATION WORKLOAD_IDENTITY_PROVIDER NODE_POOL NAMESPACE; do
if [[ -z "${!name}" ]]; then
echo "::error::${name} is required. Set the workflow input or the matching repository variable."
missing=1
fi
done
if [[ "${missing}" -ne 0 ]]; then
exit 1
fi
echo "project=${PROJECT_ID}"
echo "cluster=${CLUSTER_NAME}"
echo "location=${CLUSTER_LOCATION}"
echo "node_pool=${NODE_POOL}"
echo "namespace=${NAMESPACE}"
- name: Authenticate to Google Cloud
if: env.SERVICE_ACCOUNT == ''
uses: google-github-actions/auth@v3
with:
project_id: ${{ env.PROJECT_ID }}
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
- name: Authenticate to Google Cloud with service account
if: env.SERVICE_ACCOUNT != ''
uses: google-github-actions/auth@v3
with:
project_id: ${{ env.PROJECT_ID }}
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v3
with:
version: ">= 490.0.0"
project_id: ${{ env.PROJECT_ID }}
- name: Verify GKE node pool through GCP API
shell: bash
run: |
set -euo pipefail
gcloud container node-pools describe "${NODE_POOL}" \
--project="${PROJECT_ID}" \
--cluster="${CLUSTER_NAME}" \
--location="${CLUSTER_LOCATION}" \
--format="table(name,status,config.machineType,autoscaling.enabled,autoscaling.minNodeCount,autoscaling.maxNodeCount)"
- name: Get GKE credentials
uses: google-github-actions/get-gke-credentials@v3
with:
project_id: ${{ env.PROJECT_ID }}
cluster_name: ${{ env.CLUSTER_NAME }}
location: ${{ env.CLUSTER_LOCATION }}
- name: Verify Kubernetes access
shell: bash
run: |
set -euo pipefail
kubectl cluster-info
kubectl auth can-i get nodes
kubectl auth can-i create jobs --namespace "${NAMESPACE}"
kubectl auth can-i create services --namespace "${NAMESPACE}"
kubectl get nodes -l "cloud.google.com/gke-nodepool=${NODE_POOL}" -o wide
- name: Run multi-host TPU workload smoke test
if: env.RUN_WORKLOAD == 'true'
shell: bash
run: |
set -euo pipefail
cat > /tmp/tpu-smoke.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
name: ${WORKLOAD_NAME}-headless
namespace: ${NAMESPACE}
spec:
clusterIP: None
selector:
job-name: ${WORKLOAD_NAME}
---
apiVersion: batch/v1
kind: Job
metadata:
name: ${WORKLOAD_NAME}
namespace: ${NAMESPACE}
spec:
completionMode: Indexed
parallelism: 4
completions: 4
backoffLimit: 0
activeDeadlineSeconds: 2400
ttlSecondsAfterFinished: 600
template:
spec:
subdomain: ${WORKLOAD_NAME}-headless
restartPolicy: Never
nodeSelector:
cloud.google.com/gke-tpu-accelerator: tpu-v6e-slice
cloud.google.com/gke-tpu-topology: 4x4
cloud.google.com/gke-nodepool: ${NODE_POOL}
tolerations:
- key: google.com/tpu
operator: Equal
value: present
effect: NoSchedule
containers:
- name: tpu-smoke
image: us-docker.pkg.dev/cloud-tpu-images/jax-ai-image/tpu:jax0.8.1-rev1
command:
- /bin/bash
- -lc
- |
set -euxo pipefail
echo "pod=$(hostname)"
echo "job_index=${JOB_COMPLETION_INDEX:-unknown}"
ls -la /dev/vfio || true
sleep 120
resources:
requests:
google.com/tpu: "4"
limits:
google.com/tpu: "4"
EOF
kubectl apply -f /tmp/tpu-smoke.yaml
kubectl get job "${WORKLOAD_NAME}" --namespace "${NAMESPACE}" -o wide
kubectl wait --for=condition=Ready pod \
--selector="job-name=${WORKLOAD_NAME}" \
--namespace "${NAMESPACE}" \
--timeout=30m
kubectl logs --selector="job-name=${WORKLOAD_NAME}" \
--namespace "${NAMESPACE}" \
--all-containers=true \
--prefix=true
kubectl wait --for=condition=complete "job/${WORKLOAD_NAME}" \
--namespace "${NAMESPACE}" \
--timeout=5m
- name: Diagnose TPU workload failure
if: failure() && env.RUN_WORKLOAD == 'true'
shell: bash
run: |
set -euo pipefail
kubectl get pods --namespace "${NAMESPACE}" --selector="job-name=${WORKLOAD_NAME}" -o wide || true
kubectl describe pods --namespace "${NAMESPACE}" --selector="job-name=${WORKLOAD_NAME}" || true
kubectl logs --namespace "${NAMESPACE}" --selector="job-name=${WORKLOAD_NAME}" --all-containers=true --prefix=true || true
- name: Cleanup TPU workload smoke test
if: always() && env.RUN_WORKLOAD == 'true'
shell: bash
run: |
set -euo pipefail
kubectl delete job "${WORKLOAD_NAME}" --namespace "${NAMESPACE}" --ignore-not-found=true
kubectl delete service "${WORKLOAD_NAME}-headless" --namespace "${NAMESPACE}" --ignore-not-found=true