|
44 | 44 | podLabels: |
45 | 45 | tags.datadoghq.com/env: production |
46 | 46 | tags.datadoghq.com/service: buzz-storage-accounting |
| 47 | + # Stale operator pin: the chart owns this key and overrides it. |
47 | 48 | tags.datadoghq.com/version: test-sha |
48 | 49 | asserts: |
49 | 50 | - hasDocuments: |
@@ -89,9 +90,11 @@ tests: |
89 | 90 | path: spec.jobTemplate.spec.template.metadata.labels["tags.datadoghq.com/env"] |
90 | 91 | value: production |
91 | 92 | template: templates/storage-accounting-cronjob.yaml |
| 93 | + # Image identity wins over the operator-supplied pin; default image.tag |
| 94 | + # falls back to Chart.AppVersion, the same value as the env var below. |
92 | 95 | - equal: |
93 | 96 | path: spec.jobTemplate.spec.template.metadata.labels["tags.datadoghq.com/version"] |
94 | | - value: test-sha |
| 97 | + value: 0.1.0 |
95 | 98 | template: templates/storage-accounting-cronjob.yaml |
96 | 99 | - equal: |
97 | 100 | path: spec.jobTemplate.spec.template.spec.containers[0].args |
@@ -143,3 +146,102 @@ tests: |
143 | 146 | content: |
144 | 147 | name: BUZZ_GIT_HOOK_HMAC_SECRET |
145 | 148 | template: templates/storage-accounting-cronjob.yaml |
| 149 | + # ── Datadog version tag is chart-owned, derived from image identity ──────── |
| 150 | + # Regression: a wrapper chart pinned tags.datadoghq.com/version independently |
| 151 | + # of image.tag/image.digest, so the storage-accounting Pod reported one |
| 152 | + # version to Datadog while BUZZ_STORAGE_SNAPSHOT_CODE_SHA recorded another. |
| 153 | + - it: overrides a stale operator-pinned Datadog version label with the image tag |
| 154 | + set: |
| 155 | + relayUrl: wss://buzz.example.com |
| 156 | + ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000" |
| 157 | + externalPostgresql.url: postgres://u:p@h:5432/d |
| 158 | + externalRedis.url: redis://h:6379 |
| 159 | + s3.endpoint: https://s3.example.com |
| 160 | + s3.accessKey: test |
| 161 | + s3.secretKey: test |
| 162 | + image.tag: 1.2.3-rc.4 |
| 163 | + storageAccounting: |
| 164 | + enabled: true |
| 165 | + podLabels: |
| 166 | + tags.datadoghq.com/env: staging |
| 167 | + tags.datadoghq.com/service: buzz-storage-accounting |
| 168 | + tags.datadoghq.com/version: stale-operator-sha |
| 169 | + team: platform |
| 170 | + asserts: |
| 171 | + - equal: |
| 172 | + path: spec.jobTemplate.spec.template.metadata.labels["tags.datadoghq.com/version"] |
| 173 | + value: 1.2.3-rc.4 |
| 174 | + template: templates/storage-accounting-cronjob.yaml |
| 175 | + # The telemetry tag and the recorded snapshot identity cannot disagree. |
| 176 | + - contains: |
| 177 | + path: spec.jobTemplate.spec.template.spec.containers[0].env |
| 178 | + content: |
| 179 | + name: BUZZ_STORAGE_SNAPSHOT_CODE_SHA |
| 180 | + value: 1.2.3-rc.4 |
| 181 | + template: templates/storage-accounting-cronjob.yaml |
| 182 | + # Every other operator label still passes through. |
| 183 | + - equal: |
| 184 | + path: spec.jobTemplate.spec.template.metadata.labels["tags.datadoghq.com/env"] |
| 185 | + value: staging |
| 186 | + template: templates/storage-accounting-cronjob.yaml |
| 187 | + - equal: |
| 188 | + path: spec.jobTemplate.spec.template.metadata.labels["tags.datadoghq.com/service"] |
| 189 | + value: buzz-storage-accounting |
| 190 | + template: templates/storage-accounting-cronjob.yaml |
| 191 | + - equal: |
| 192 | + path: spec.jobTemplate.spec.template.metadata.labels["team"] |
| 193 | + value: platform |
| 194 | + template: templates/storage-accounting-cronjob.yaml |
| 195 | + - equal: |
| 196 | + path: spec.jobTemplate.spec.template.metadata.labels["app.kubernetes.io/component"] |
| 197 | + value: storage-accounting |
| 198 | + template: templates/storage-accounting-cronjob.yaml |
| 199 | + - it: stamps the version label with no operator podLabels at all |
| 200 | + set: |
| 201 | + relayUrl: wss://buzz.example.com |
| 202 | + ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000" |
| 203 | + externalPostgresql.url: postgres://u:p@h:5432/d |
| 204 | + externalRedis.url: redis://h:6379 |
| 205 | + s3.endpoint: https://s3.example.com |
| 206 | + s3.accessKey: test |
| 207 | + s3.secretKey: test |
| 208 | + image.tag: 2.0.0 |
| 209 | + storageAccounting: |
| 210 | + enabled: true |
| 211 | + asserts: |
| 212 | + - equal: |
| 213 | + path: spec.jobTemplate.spec.template.metadata.labels["tags.datadoghq.com/version"] |
| 214 | + value: 2.0.0 |
| 215 | + template: templates/storage-accounting-cronjob.yaml |
| 216 | + - it: renders a label-safe version from a pinned image digest |
| 217 | + set: |
| 218 | + relayUrl: wss://buzz.example.com |
| 219 | + ownerPubkey: "0000000000000000000000000000000000000000000000000000000000000000" |
| 220 | + externalPostgresql.url: postgres://u:p@h:5432/d |
| 221 | + externalRedis.url: redis://h:6379 |
| 222 | + s3.endpoint: https://s3.example.com |
| 223 | + s3.accessKey: test |
| 224 | + s3.secretKey: test |
| 225 | + image.tag: ignored-when-digest-set |
| 226 | + image.digest: sha256:1111111111111111111111111111111111111111111111111111111111111111 |
| 227 | + storageAccounting: |
| 228 | + enabled: true |
| 229 | + podLabels: |
| 230 | + tags.datadoghq.com/version: stale-operator-sha |
| 231 | + asserts: |
| 232 | + # 63 chars, no "sha256:" prefix — a label value the API server accepts, |
| 233 | + # still a unique prefix of the digest recorded in the env var below. |
| 234 | + - equal: |
| 235 | + path: spec.jobTemplate.spec.template.metadata.labels["tags.datadoghq.com/version"] |
| 236 | + value: "111111111111111111111111111111111111111111111111111111111111111" |
| 237 | + template: templates/storage-accounting-cronjob.yaml |
| 238 | + - matchRegex: |
| 239 | + path: spec.jobTemplate.spec.template.metadata.labels["tags.datadoghq.com/version"] |
| 240 | + pattern: ^[a-z0-9A-Z]([-_.a-zA-Z0-9]{0,61}[a-zA-Z0-9])?$ |
| 241 | + template: templates/storage-accounting-cronjob.yaml |
| 242 | + - contains: |
| 243 | + path: spec.jobTemplate.spec.template.spec.containers[0].env |
| 244 | + content: |
| 245 | + name: BUZZ_STORAGE_SNAPSHOT_CODE_SHA |
| 246 | + value: sha256:1111111111111111111111111111111111111111111111111111111111111111 |
| 247 | + template: templates/storage-accounting-cronjob.yaml |
0 commit comments