Skip to content

Commit 4edecf0

Browse files
committed
work on cache CI
1 parent 41c0cad commit 4edecf0

3 files changed

Lines changed: 61 additions & 21 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,52 @@ jobs:
9999
echo "=== Node pod logs ==="
100100
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1
101101
102-
- name: Debug on failure
102+
- name: Cluster state all
103103
if: failure()
104104
run: |
105-
echo "=== Cluster state ==="
106-
kubectl get all -A
105+
echo "=== Cluster state all ==="
106+
kubectl get all -A || true
107107
108-
echo "=== Cache pod logs ==="
109-
kubectl logs -l app.kubernetes.io/name=cache -n nix-csi --tail -1 || true
108+
- name: Cluster state configmaps
109+
if: failure()
110+
run: |
111+
echo "=== Cluster configmaps ==="
112+
kubectl get configmaps -A || true
110113
111-
echo "=== Cache pod describe ==="
114+
- name: Cluster state secrets
115+
if: failure()
116+
run: |
117+
kubectl get secrets -A || true
118+
119+
- name: Cache
120+
if: failure()
121+
run: |
122+
kubectl logs -l app.kubernetes.io/name=cache -n nix-csi --tail -1 || true
112123
kubectl describe pod -l app.kubernetes.io/name=cache-n nix-csi || true
113124
114-
echo "=== Node pod logs ==="
125+
- name: Node
126+
if: failure()
127+
run: |
115128
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1 || true
116-
117-
echo "=== Node pod describe ==="
118129
kubectl describe pod -l app.kubernetes.io/name=csi -n nix-csi || true
119130
120-
echo "=== Init pod logs ==="
131+
- name: Init
132+
if: failure()
133+
run: |
121134
kubectl logs -l app.kubernetes.io/name=init -n nix-csi --tail -1 || true
122135
123-
echo "=== Events ==="
136+
- name: Events
137+
if: failure()
138+
run: |
124139
kubectl get events -n nix-csi --sort-by='.lastTimestamp'
125140
141+
- name: Troubleshoot with upterm
142+
if: failure()
143+
uses: owenthereal/action-upterm@main
144+
with:
145+
limit-access-to-actor: true
146+
wait-timeout-minutes: 5
147+
126148
test-kind-nocache:
127149
needs: build
128150
runs-on: ubuntu-latest
@@ -184,3 +206,10 @@ jobs:
184206
185207
echo "=== Events ==="
186208
kubectl get events -n nix-csi --sort-by='.lastTimestamp'
209+
210+
- name: Troubleshoot with upterm
211+
if: failure()
212+
uses: owenthereal/action-upterm@main
213+
with:
214+
limit-access-to-actor: true
215+
wait-timeout-minutes: 5

kubenix/secret.nix

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,34 @@ in
6161
};
6262
};
6363
ConfigMap.init-scripts = {
64-
data.init-secrets = # bash
64+
data.init-secrets = let
65+
kc = "kubectl -n ${cfg.namespace}";
66+
in
67+
# bash
6568
''
69+
set -x
6670
mkdir -p /tmp/{ssh-key,nix-key,ssh-auth}
67-
if ! kubectl get secret ssh-key &>/dev/null || ! kubectl get configmap ssh-dynauth &>/dev/null; then
71+
if ! ${kc} get secret ssh-key &>/dev/null || ! ${kc} get configmap ssh-dynauth &>/dev/null; then
6872
# Create ssh secret
6973
ssh-keygen -t ed25519 -C "" -N "" -f /tmp/ssh-key/id_ed25519
70-
kubectl delete --ignore-not-found secret ssh-key
71-
kubectl create secret generic ssh-key --from-file=/tmp/ssh-key
74+
${kc} delete --ignore-not-found secret ssh-key
75+
${kc} create secret generic ssh-key --from-file=/tmp/ssh-key
7276
7377
# Create pubkey configmap
7478
cp /tmp/ssh-key/id_ed25519.pub /tmp/ssh-auth/authorized_keys
7579
echo "* $(cat /tmp/ssh-key/id_ed25519.pub)" > /tmp/ssh-auth/ssh_known_hosts
76-
kubectl delete --ignore-not-found configmap ssh-dynauth
77-
kubectl create configmap ssh-dynauth --from-file=/tmp/ssh-auth
80+
${kc} delete --ignore-not-found configmap ssh-dynauth
81+
${kc} create configmap ssh-dynauth --from-file=/tmp/ssh-auth
7882
fi
7983
80-
if ! kubectl get secret nix-key &>/dev/null; then
84+
if ! ${kc} get secret nix-key &>/dev/null; then
8185
# create nix binary cache key
8286
nix-store --generate-binary-cache-key \
8387
nix-cache-1 \
8488
/tmp/nix-key/nix_ed25519 \
8589
/tmp/nix-key/nix_ed25519.pub
86-
kubectl delete --ignore-not-found secret nix-key
87-
kubectl create secret generic nix-key --from-file=/tmp/nix-key
90+
${kc} delete --ignore-not-found secret nix-key
91+
${kc} create secret generic nix-key --from-file=/tmp/nix-key
8892
fi
8993
'';
9094
};

liximage.nix

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,16 @@ rec {
4242
set -x
4343
mkdir /tmp
4444
rsync --archive ${fakeNss}/ /
45+
46+
# Check if we can SSH to nix-cache
47+
EXTRA_SUBSTITUTERS="local?trusted=true"
48+
if ssh nix@nix-cache true 2>/dev/null; then
49+
EXTRA_SUBSTITUTERS="$EXTRA_SUBSTITUTERS ssh-ng://nix@nix-cache?trusted=true"
50+
fi
51+
4552
nix \
4653
build \
47-
--extra-substituters "local?trusted=true ssh-ng://nix@nix-cache?trusted=true" \
54+
--extra-substituters "$EXTRA_SUBSTITUTERS" \
4855
--max-jobs auto \
4956
--option sandbox false \
5057
--store /nix-volume \

0 commit comments

Comments
 (0)