-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Install telemetry CRDs via crd-installer #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,8 @@ installed regardless. Add new groups here as new subchart-CRD dependencies land. | |
| {{- if (dig "altinity-clickhouse-operator" "enabled" false .Values.AsMap) -}} | ||
| {{- $groups = append $groups "clickhouse" -}} | ||
| {{- end -}} | ||
| {{- /* Telemetry CRDs install in every mode so an off→full upgrade never has to add CRDs. */ -}} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should only install this when they are needed, but the difference is that the crd-installer will install them during a helm upgrade if they are enabled, which the helm charts were not doing. |
||
| {{- $groups = concat $groups (list "victoriametrics" "grafana") -}} | ||
| {{- join "," $groups -}} | ||
| {{- end -}} | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -122,6 +122,52 @@ func TestStandaloneTelemetryChartFullModeRendersCoreStack(t *testing.T) { | |||||||||||||||||||||||||||
| mustContain(t, output, "datadog:") | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // The crd-installer Job installs VM + Grafana CRDs in every mode so an off→full | ||||||||||||||||||||||||||||
| // upgrade never has to add CRDs (which Helm won't do on upgrade). | ||||||||||||||||||||||||||||
| func TestCrdInstallerAlwaysRequestsTelemetryGroups(t *testing.T) { | ||||||||||||||||||||||||||||
| modes := []struct { | ||||||||||||||||||||||||||||
| name string | ||||||||||||||||||||||||||||
| extra []string | ||||||||||||||||||||||||||||
| }{ | ||||||||||||||||||||||||||||
| {"off", []string{"--set", "telemetry.mode=off"}}, | ||||||||||||||||||||||||||||
| {"forward", []string{ | ||||||||||||||||||||||||||||
| "--set", "telemetry.mode=forward", | ||||||||||||||||||||||||||||
| "--set", "telemetry.forwarding.otlp.endpoint=https://otel.example.com", | ||||||||||||||||||||||||||||
| "--set", "victoria-metrics-operator.enabled=true", | ||||||||||||||||||||||||||||
| }}, | ||||||||||||||||||||||||||||
| {"full", []string{ | ||||||||||||||||||||||||||||
| "--set", "telemetry.mode=full", | ||||||||||||||||||||||||||||
| "--set", "victoria-metrics-operator.enabled=true", | ||||||||||||||||||||||||||||
| "--set", "grafana-operator.enabled=true", | ||||||||||||||||||||||||||||
| }}, | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| for _, m := range modes { | ||||||||||||||||||||||||||||
| t.Run(m.name, func(t *testing.T) { | ||||||||||||||||||||||||||||
| args := append([]string{"--set", "helmHooks.enabled=true", "--set", "wandb.install=false"}, m.extra...) | ||||||||||||||||||||||||||||
| output := runHelmTemplate(t, args...) | ||||||||||||||||||||||||||||
| groups := crdInstallerGroups(t, output) | ||||||||||||||||||||||||||||
| for _, g := range []string{"victoriametrics", "grafana"} { | ||||||||||||||||||||||||||||
| if !strings.Contains(groups, g) { | ||||||||||||||||||||||||||||
| t.Errorf("crd-installer --groups=%q missing %q", groups, g) | ||||||||||||||||||||||||||||
|
Comment on lines
+149
to
+151
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Match complete group names instead of substrings.
Proposed assertion fix- groups := crdInstallerGroups(t, output)
+ groupValue := crdInstallerGroups(t, output)
+ groups := make(map[string]struct{})
+ for _, group := range strings.Split(groupValue, ",") {
+ groups[strings.TrimSpace(group)] = struct{}{}
+ }
for _, g := range []string{"victoriametrics", "grafana"} {
- if !strings.Contains(groups, g) {
- t.Errorf("crd-installer --groups=%q missing %q", groups, g)
+ if _, ok := groups[g]; !ok {
+ t.Errorf("crd-installer --groups=%q missing exact group %q", groupValue, g)
}
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // crdInstallerGroups returns the value of the crd-installer Job's --groups flag. | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Explain why the helper scans rendered output. The comment only restates Proposed comment update-// crdInstallerGroups returns the value of the crd-installer Job's --groups flag.
+// Scan rendered YAML so the test verifies the Helm hook's command arguments.As per coding guidelines, 📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||||||||||||||||||||
| func crdInstallerGroups(t *testing.T, output string) string { | ||||||||||||||||||||||||||||
| t.Helper() | ||||||||||||||||||||||||||||
| const marker = "--groups=" | ||||||||||||||||||||||||||||
| for _, line := range strings.Split(output, "\n") { | ||||||||||||||||||||||||||||
| if i := strings.Index(line, marker); i >= 0 { | ||||||||||||||||||||||||||||
| return strings.TrimSpace(line[i+len(marker):]) | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| t.Fatalf("crd-installer --groups= flag not found in rendered output") | ||||||||||||||||||||||||||||
| return "" | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| func runHelmTemplate(t *testing.T, extraArgs ...string) string { | ||||||||||||||||||||||||||||
| t.Helper() | ||||||||||||||||||||||||||||
| output, err := runHelmTemplateWithError(t, filepath.Join("..", "..", "..", "deploy", "operator"), extraArgs...) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Make CRD replacement all-or-nothing.
Both recipes remove or overwrite existing CRD artifacts before all reads and copies succeed. A failed
tarorcpcan leave generated inputs incomplete.internal/crdinstaller/crdsafter every copy succeeds.📍 Affects 1 file
Makefile#L65-L70(this comment)Makefile#L75-L81🤖 Prompt for AI Agents