fix(operator): cap k8s discovery RBAC label values to 63 chars#11709
fix(operator): cap k8s discovery RBAC label values to 63 chars#11709kulkarnisamr wants to merge 1 commit into
Conversation
|
👋 Hi kulkarnisamr! Thank you for contributing to ai-dynamo/dynamo. Just a reminder: The 🚀 |
WalkthroughChangesDiscovery label capping
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
deploy/operator/internal/discovery/resource_test.go (1)
32-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the deterministic label value, not only its shape.
These tests pass for an arbitrary shortened value containing
-, or even empty resource labels. Assert the expected SHA-256 suffix and that every resource label equals the capped service-account label.Proposed test strengthening
import ( + "crypto/sha256" + "encoding/hex" "strings" "testing" ) if tc.wantHashPart && !strings.Contains(got, "-") { t.Fatalf("getK8sDiscoveryLabelValue(%q) = %q, want hash separator", tc.input, got) } + if tc.wantHashPart { + sum := sha256.Sum256([]byte(tc.input)) + want := tc.input[:maxLabelValueLen-hashLen-1] + "-" + + hex.EncodeToString(sum[:])[:hashLen] + if got != want { + t.Fatalf("getK8sDiscoveryLabelValue(%q) = %q, want %q", tc.input, got, want) + } + } }) } } + wantLabel := getK8sDiscoveryLabelValue(GetK8sDiscoveryServiceAccountName(dgdName)) for _, label := range []string{ sa.Labels["app.kubernetes.io/name"], role.Labels["app.kubernetes.io/name"], rb.Labels["app.kubernetes.io/name"], } { + if label != wantLabel { + t.Fatalf("label = %q, want %q", label, wantLabel) + } if len(label) > maxLabelValueLen {Also applies to: 72-79
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@deploy/operator/internal/discovery/resource_test.go` around lines 32 - 36, Strengthen the truncation tests around the “over limit truncated with hash” cases to assert the exact deterministic SHA-256 suffix rather than only checking its shape. Verify that all generated resource labels equal the capped service-account label, including the corresponding cases near the referenced test entries, while preserving the existing length and equality assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@deploy/operator/internal/discovery/resource_test.go`:
- Around line 32-36: Strengthen the truncation tests around the “over limit
truncated with hash” cases to assert the exact deterministic SHA-256 suffix
rather than only checking its shape. Verify that all generated resource labels
equal the capped service-account label, including the corresponding cases near
the referenced test entries, while preserving the existing length and equality
assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 28b9236b-1117-42f5-aa91-ad860a1e9598
📒 Files selected for processing (2)
deploy/operator/internal/discovery/resource.godeploy/operator/internal/discovery/resource_test.go
3cd2ec6 to
c081185
Compare
Keep k8s discovery ServiceAccount, Role, and RoleBinding resource names unchanged while capping only app.kubernetes.io/name label values with a deterministic hash suffix when needed. Add boundary tests to cover unchanged <=63 values and capped values across all three resources. Signed-off-by: Sameer Kulkarni <skulkarni@coreweave.com> Signed-off-by: Sameer Kulkarni <kulkarnisameer7@gmail.com>
31ff0f6 to
2a87b1d
Compare
Summary
app.kubernetes.io/namelabel values to Kubernetes' 63-char limitTest plan
go test ./internal/discoverySummary by CodeRabbit
Bug Fixes
Tests