Skip to content

Commit e2c4fce

Browse files
aarontsharpclaude
andauthored
fix: lowercase CleanStringForDNS output for RFC 1123 compliance (#228)
## Summary `CleanStringForDNS` strips invalid characters but does not lowercase the result. When an image tag contains uppercase characters (e.g. `myimage:master--HEAD`), `ComputeVersionedDeploymentName` produces a deployment name that violates RFC 1123 DNS label rules, causing Kubernetes to reject the Deployment. This adds `strings.ToLower()` to `CleanStringForDNS` so deployment names are always valid DNS labels. ### Why `CleanStringForDNS` and not `cleanBuildID`? The build ID is also used as a Kubernetes label value and as the Temporal worker build ID. Labels allow uppercase (`[a-zA-Z0-9._-]`), and Temporal build IDs just need to be ASCII. Lowercasing only in `CleanStringForDNS` keeps the fix scoped to where DNS compliance is required (resource names) without affecting label values or Temporal version matching. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f394c51 commit e2c4fce

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

internal/k8s/deployments.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ func TruncateString(s string, n int) string {
187187
func CleanStringForDNS(s string) string {
188188
// Keep only letters, numbers, and dashes.
189189
re := regexp.MustCompile(`[^a-zA-Z0-9-]+`)
190-
return re.ReplaceAllString(s, ResourceNameSeparator)
190+
// Lowercase to ensure RFC 1123 DNS label compliance for Kubernetes resource names.
191+
return strings.ToLower(re.ReplaceAllString(s, ResourceNameSeparator))
191192
}
192193

193194
// Build ID is used as a label in k8s, and as the build ID for

internal/k8s/deployments_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,12 @@ func TestComputeVersionedDeploymentName(t *testing.T) {
479479
buildID: "image-v2.1.0-a1b2c3d4",
480480
expectedName: "worker-name-image-v2-1-0-a1b2c3d4",
481481
},
482+
{
483+
name: "uppercase characters in build ID are lowercased",
484+
baseName: "worker-name",
485+
buildID: "master--HEAD",
486+
expectedName: "worker-name-master--head",
487+
},
482488
{
483489
name: "exceed max length",
484490
baseName: "worker-name-0123456789-0123456789",

0 commit comments

Comments
 (0)