Skip to content

Commit 3fc96ad

Browse files
committed
work on cache CI
1 parent 92cb732 commit 3fc96ad

3 files changed

Lines changed: 54 additions & 23 deletions

File tree

.github/actions/setup-nix/action.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@ runs:
4242
shell: bash
4343
run: |
4444
mkdir -p ~/.ssh
45-
echo "${{ inputs.nixbuild_key }}" > ~/.ssh/id_ed25519
46-
chmod 600 ~/.ssh/id_ed25519
47-
echo -e "Host *\n\tStrictHostKeyChecking no" | sudo tee -a ~/.ssh/config > /dev/null
45+
echo "${{ inputs.nixbuild_key }}" > ~/.ssh/nixbuild_key
46+
chmod 600 ~/.ssh/nixbuild_key
47+
{
48+
echo "Host eu.nixbuild.net"
49+
echo " IdentityFile ~/.ssh/nixbuild_key"
50+
echo "Host *"
51+
echo " StrictHostKeyChecking no"
52+
} >> ~/.ssh/config
53+
chmod 644 ~/.ssh/config
4854

.github/workflows/ci.yaml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ jobs:
6767
- name: Create Kind cluster
6868
uses: helm/kind-action@main
6969

70+
- name: Setup upterm session
71+
uses: owenthereal/action-upterm@v1
72+
with:
73+
limit-access-to-actor: true
74+
wait-timeout-minutes: 5
75+
7076
- name: Clean runner
7177
run: |
7278
# Remove cache because permissions can get fucked up preventing kluctl from creating it's cache directory
@@ -99,28 +105,43 @@ jobs:
99105
echo "=== Node pod logs ==="
100106
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1
101107
102-
- name: Debug on failure
108+
- name: Cluster state all
103109
if: failure()
104110
run: |
105-
echo "=== Cluster state ==="
106-
kubectl get all -A
111+
echo "=== Cluster state all ==="
112+
kubectl get all -A || true
107113
108-
echo "=== Cache pod logs ==="
109-
kubectl logs -l app.kubernetes.io/name=cache -n nix-csi --tail -1 || true
114+
- name: Cluster state configmaps
115+
if: failure()
116+
run: |
117+
echo "=== Cluster configmaps ==="
118+
kubectl get configmaps -A || true
119+
120+
- name: Cluster state secrets
121+
if: failure()
122+
run: |
123+
kubectl get secrets -A || true
110124
111-
echo "=== Cache pod describe ==="
125+
- name: Cache
126+
if: failure()
127+
run: |
128+
kubectl logs -l app.kubernetes.io/name=cache -n nix-csi --tail -1 || true
112129
kubectl describe pod -l app.kubernetes.io/name=cache-n nix-csi || true
113130
114-
echo "=== Node pod logs ==="
131+
- name: Node
132+
if: failure()
133+
run: |
115134
kubectl logs -l app.kubernetes.io/name=csi -n nix-csi --tail -1 || true
116-
117-
echo "=== Node pod describe ==="
118135
kubectl describe pod -l app.kubernetes.io/name=csi -n nix-csi || true
119136
120-
echo "=== Init pod logs ==="
137+
- name: Init
138+
if: failure()
139+
run: |
121140
kubectl logs -l app.kubernetes.io/name=init -n nix-csi --tail -1 || true
122141
123-
echo "=== Events ==="
142+
- name: Events
143+
if: failure()
144+
run: |
124145
kubectl get events -n nix-csi --sort-by='.lastTimestamp'
125146
126147
test-kind-nocache:

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
};

0 commit comments

Comments
 (0)