Skip to content

Commit 18ce850

Browse files
committed
fixup: Store gh_workflow as an annotation
1 parent 33ec1e0 commit 18ce850

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
- uses: ./.github/actions/install-nix
9494
- name: Run e2e tests
9595
shell: bash
96-
run: nix develop --command bash -x ./scripts/tests.e2e.kube.sh
96+
run: nix develop --impure --command bash -x ./scripts/tests.e2e.kube.sh
9797
env:
9898
TMPNET_START_COLLECTORS: ${{ secrets.PROMETHEUS_ID != '' }}
9999
TMPNET_CHECK_MONITORING: ${{ secrets.PROMETHEUS_ID != '' }}

tests/fixture/tmpnet/kube.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,21 @@ func NewNodeStatefulSet(
7474
podLabels := map[string]string{
7575
"app": name,
7676
}
77-
ghRepo := ""
77+
var (
78+
ghRepo string
79+
ghWorkflow string
80+
)
7881
for label, value := range labels {
7982
// gh_repo contains a slash so it is not a valid label. Set it as an annotation instead.
8083
if label == "gh_repo" {
8184
ghRepo = value
8285
continue
8386
}
87+
// gh_workflow can contain spaces which is not valid in labels. Set it as an annotation instead.
88+
if label == "gh_workflow" {
89+
ghWorkflow = value
90+
continue
91+
}
8492
podLabels[label] = value
8593
}
8694
podAnnotations := map[string]string{
@@ -89,6 +97,7 @@ func NewNodeStatefulSet(
8997
"prometheus.io/path": "/ext/metrics",
9098
"promtail/collect": "true",
9199
"gh_repo": ghRepo,
100+
"gh_workflow": ghWorkflow,
92101
}
93102

94103
return &appsv1.StatefulSet{

tests/fixture/tmpnet/yaml/prometheus-agent.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ data:
9090
target_label: network_uuid
9191
- source_labels: [__meta_kubernetes_pod_label_node_id]
9292
target_label: node_id
93-
# gh_repo is an annotation because labels can't contain `/`
93+
# gh_repo is an annotation because labels can't contain `/` and a repo is typically `[org]/[repo]`
9494
- source_labels: [__meta_kubernetes_pod_annotation_gh_repo]
9595
target_label: gh_repo
96-
- source_labels: [__meta_kubernetes_pod_label_gh_workflow]
96+
# gh_workflow is an annotation because workflows can contain spaces
97+
- source_labels: [__meta_kubernetes_pod_annotation_gh_workflow]
9798
target_label: gh_workflow
9899
- source_labels: [__meta_kubernetes_pod_label_gh_run_id]
99100
target_label: gh_run_id

tests/fixture/tmpnet/yaml/promtail-daemonset.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ data:
111111
target_label: network_uuid
112112
- source_labels: [__meta_kubernetes_pod_label_node_id]
113113
target_label: node_id
114-
# gh_repo is an annotation because labels can't contain `/`
114+
# gh_repo is an annotation because labels can't contain `/` and a repo is typically `[org]/[repo]`
115115
- source_labels: [__meta_kubernetes_pod_annotation_gh_repo]
116116
target_label: gh_repo
117-
- source_labels: [__meta_kubernetes_pod_label_gh_workflow]
117+
# gh_workflow is an annotation because workflows can contain spaces
118+
- source_labels: [__meta_kubernetes_pod_annotation_gh_workflow]
118119
target_label: gh_workflow
119120
- source_labels: [__meta_kubernetes_pod_label_gh_run_id]
120121
target_label: gh_run_id

0 commit comments

Comments
 (0)