Repository navigation
Expand file tree
/
Copy pathobserve-longhorn-namespace-inventory.yaml
More file actions
90 lines (87 loc) · 3.49 KB
/
Copy pathobserve-longhorn-namespace-inventory.yaml
File metadata and controls
90 lines (87 loc) · 3.49 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
---
name: Observe Longhorn Namespace Inventory
"on":
workflow_dispatch:
inputs:
confirm:
description: "Type exactly: observe-longhorn-namespace-inventory"
required: true
type: string
permissions: {}
jobs:
observe:
name: Calibrate complete namespace metadata reads
runs-on: ubuntu-latest
timeout-minutes: 10
environment: prod
permissions:
contents: read
concurrency:
group: prod-deploy
cancel-in-progress: false
queue: max
env:
LONGHORN_NAMESPACE_CONFIRM: ${{ inputs.confirm }}
steps:
- name: Require confirmed first attempt on main
shell: bash
env:
DISPATCH_REF: ${{ github.ref }}
run: |
set -euo pipefail
[[ "${DISPATCH_REF}" == refs/heads/main && "${GITHUB_RUN_ATTEMPT}" == 1 ]]
[[ "${LONGHORN_NAMESPACE_CONFIRM}" == observe-longhorn-namespace-inventory ]]
- name: Checkout reviewed source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
ref: ${{ github.sha }}
- name: Require current main before credentials
env:
GH_TOKEN: ${{ github.token }}
run: ./scripts/verify-prod-recovery-source.sh "${GITHUB_SHA}"
- name: Setup Go
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version-file: go.mod
cache: false
- name: Test metadata bounds and credential refusals
run: go test -race -count=1 -timeout=3m ./internal/namespaceinventory ./scripts/observe-longhorn-namespace-inventory
- name: Install verified Kubernetes client
shell: bash
env:
KUBECTL_VERSION: v1.36.2
KUBECTL_SHA256: 1e9045ec32bea85da43de85f0065358529ea7c7a152eca78154fba5b58c27d82
run: |
set -euo pipefail
kubectl_path="${RUNNER_TEMP}/longhorn-namespace-inventory-kubectl"
curl -fsSL --retry 3 --retry-all-errors --retry-delay 5 --retry-max-time 120 --connect-timeout 10 --max-time 120 "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" -o "${kubectl_path}"
printf '%s %s\n' "${KUBECTL_SHA256}" "${kubectl_path}" | sha256sum --check
sudo install "${kubectl_path}" /usr/local/bin/kubectl
- name: Restore production kubeconfig in memory
shell: bash
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
run: |
set -euo pipefail
test -n "${KUBE_CONFIG}"
umask 077
credential_dir=$(mktemp -d /dev/shm/longhorn-namespace-inventory.XXXXXX)
printf '%s' "${KUBE_CONFIG}" >"${credential_dir}/kubeconfig"
printf 'KUBECONFIG=%s/kubeconfig\nLONGHORN_NAMESPACE_CREDENTIAL_DIR=%s\n' "${credential_dir}" "${credential_dir}" >>"${GITHUB_ENV}"
- name: Select stable production API endpoint
env:
HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }}
run: ./scripts/use-prod-stable-api-endpoint.sh
- name: Observe fixed Longhorn namespace metadata
env:
GH_TOKEN: ${{ github.token }}
run: go run ./scripts/observe-longhorn-namespace-inventory
- name: Remove runner credentials
if: ${{ always() }}
shell: bash
run: |
set -euo pipefail
if [[ "${LONGHORN_NAMESPACE_CREDENTIAL_DIR:-}" =~ ^/dev/shm/longhorn-namespace-inventory\.[A-Za-z0-9]+$ ]]; then
rm -rf -- "${LONGHORN_NAMESPACE_CREDENTIAL_DIR}"
fi