Repository navigation
239 lines (223 loc) · 8.02 KB
/
Copy pathload.yml
File metadata and controls
239 lines (223 loc) · 8.02 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
233
234
235
236
237
238
239
name: Load
on:
workflow_call:
inputs:
duration:
description: 'Duration ("s" for seconds (the default), "m" for minutes, "h" for hours) for each collector process to run'
required: true
default: '1h'
type: string
delay_start:
description: 'Maximum delay in seconds before starting each collector'
required: true
default: '10'
type: string
numprocs:
description: 'Number of collector processes to run'
required: true
default: '5'
type: string
collector_version:
description: 'Version of the collector to use'
required: false
type: string
collector_config_artifact:
description: 'Name of the artifact containing the collector configuration'
required: true
type: string
matrix:
description: 'Matrix of parallel jobs to run'
required: true
default: '[0,1,2,3,4,5,6,7,8,9]'
type: string
secrets:
ENCRYPTION_KEY:
required: true
description: 'Encryption key for GPG decryption'
global_monitoring_otlp_endpoint:
required: true
description: 'OTLP endpoint URL for monitoring telemetry from the OpenTelemetry collectors'
global_monitoring_api_key:
required: true
description: 'API key for the monitoring OTLP endpoint'
jobs:
load:
name: Load
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
parallel: ${{ fromJSON(inputs.matrix) }}
steps:
- name: Determine Collector Version
id: determine-collector-version
run: |
COLLECTOR_VERSION="${{ inputs.collector_version || vars.DEFAULT_COLLECTOR_VERSION }}"
echo "collector_version=$COLLECTOR_VERSION" >> $GITHUB_OUTPUT
echo "Determined collector version: $COLLECTOR_VERSION"
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 1
- name: Install OpenTelemetry Collector
run: |
curl -sL -o otelcol-contrib.deb https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v${{ steps.determine-collector-version.outputs.collector_version }}/otelcol-contrib_${{ steps.determine-collector-version.outputs.collector_version }}_linux_amd64.deb
sudo dpkg -i otelcol-contrib.deb
rm otelcol-contrib.deb
- name: Configure Monitoring of the Runner
env:
MONITORING_OTLP_ENDPOINT: ${{ secrets.global_monitoring_otlp_endpoint }}
MONITORING_API_KEY: ${{ secrets.global_monitoring_api_key }}
ITERATION: ${{ matrix.parallel }}
run: |
if [ -z "${MONITORING_OTLP_ENDPOINT}" ]; then
echo "MONITORING_OTLP_ENDPOINT is not set, skipping monitoring"
exit 0
fi
cat > loadmon.yaml << EOF
receivers:
hostmetrics:
collection_interval: 30s
scrapers:
cpu:
metrics:
system.cpu.utilization:
enabled: true
system.cpu.logical.count:
enabled: true
disk:
filesystem:
load:
memory:
metrics:
system.memory.utilization:
enabled: true
network:
processes:
processors:
transform:
metric_statements:
- set(resource.attributes["host.name"], "loadtelcol-${ITERATION}")
- set(resource.attributes["instance"], "${ITERATION}")
resourcedetection:
detectors: ["system"]
system:
hostname_sources: ["os"]
resource_attributes:
host.name:
enabled: true
host.id:
enabled: false
host.arch:
enabled: true
host.ip:
enabled: true
host.mac:
enabled: true
host.cpu.vendor.id:
enabled: true
host.cpu.family:
enabled: true
host.cpu.model.id:
enabled: true
host.cpu.model.name:
enabled: true
host.cpu.stepping:
enabled: true
host.cpu.cache.l2.size:
enabled: true
os.description:
enabled: true
os.type:
enabled: true
exporters:
otlp:
endpoint: ${MONITORING_OTLP_ENDPOINT}
headers:
authorization: ApiKey ${MONITORING_API_KEY}
service:
pipelines:
metrics:
receivers: [hostmetrics]
processors: [resourcedetection,transform]
exporters: [otlp]
telemetry:
logs:
level: warn
metrics:
level: none
EOF
- name: Validate Monitoring Config
run: |
if [ ! -s loadmon.yaml ]; then
exit 0
fi
/usr/bin/otelcol-contrib --config loadmon.yaml validate
- name: Start Monitoring the Runner
run: |
if [ ! -s loadmon.yaml ]; then
exit 0
fi
nohup /usr/bin/otelcol-contrib --config loadmon.yaml > /dev/null 2>&1 &
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
cache: 'pip'
- name: Install Supervisor
run: |
python -m venv .venv
source .venv/bin/activate
pip install supervisor
- name: Configure Supervisor
env:
DURATION: ${{ inputs.duration }}
DELAY_START: ${{ inputs.delay_start }}
NUMPROCS: ${{ inputs.numprocs }}
run: ./generate-supervisord-config.sh
- name: Download Collector Config
uses: actions/download-artifact@v4
with:
name: ${{ inputs.collector_config_artifact }}
path: .
- name: Configure OpenTelemetry Collectors
run: |
echo ${{ secrets.ENCRYPTION_KEY }} | gpg --pinentry-mode loopback --passphrase-fd 0 --decrypt -o config.yaml config.yaml.gpg
- name: Validate Collector Config
run: |
/usr/bin/otelcol-contrib --config config.yaml validate
- name: Start OpenTelemetry Collectors
env:
ITERATION: ${{ matrix.parallel }}
run: |
mkdir -p logs
# Calculate timeout: duration + delay_start + buffer
# Convert duration to seconds (handles s, m, h, d suffixes)
duration="${{ inputs.duration }}"
if [[ "$duration" =~ ^[0-9]+s$ ]]; then
duration_seconds=${duration%s}
elif [[ "$duration" =~ ^[0-9]+m$ ]]; then
duration_seconds=$((${duration%m} * 60))
elif [[ "$duration" =~ ^[0-9]+h$ ]]; then
duration_seconds=$((${duration%h} * 3600))
elif [[ "$duration" =~ ^[0-9]+d$ ]]; then
duration_seconds=$((${duration%d} * 86400))
else
# Assume seconds if no suffix
duration_seconds=$duration
fi
delay_seconds=${{ inputs.delay_start }}
timeout_seconds=$((duration_seconds + delay_seconds + 120))
echo "Running collectors with timeout ${timeout_seconds}s (duration: ${duration_seconds}s, delay: ${delay_seconds}s)"
source .venv/bin/activate && timeout ${timeout_seconds}s supervisord -c supervisord.ini || true
- name: Sample Error Logs
if: always()
run: |
ls -1S logs/*.err.log | head -5 | xargs tail
- name: Upload Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: logs-${{ matrix.parallel }}
path: logs
retention-days: 5