Repository navigation
refactor(monitoring): migrate MonitoringDashboard controller to Google REST client - #13574
Conversation
gemmahou
left a comment
There was a problem hiding this comment.
/lgtm
Two nit comments...
| @@ -235,11 +234,6 @@ func (d *dashboardDefaulter) visitPieChart(obj *pb.PieChart) { | |||
| } | |||
|
|
|||
| func (d *dashboardDefaulter) visitTimeSeriesTable(obj *pb.TimeSeriesTable) { | |||
There was a problem hiding this comment.
nit: remove this empty function
| func computeEtag(obj proto.Message) string { | ||
| b, err := proto.Marshal(obj) | ||
| clone := proto.Clone(obj) | ||
| if dashboard, ok := clone.(*pb.Dashboard); ok { |
There was a problem hiding this comment.
nit: I feel this function is to generate unique Etag for objects, I'm curious why do we need this if logic? The dashboard doesn't seem to be used here.
There was a problem hiding this comment.
IIRC the controller is using etag for reconciliation, we should revise that but it's out of scope for the change. I'll let the agent take a look though and reply as well.
There was a problem hiding this comment.
Two details explain why this block is there:
- In Go,
dashboardis a typed pointer to the clone message (clone := proto.Clone(obj)), so settingdashboard.Name = ""anddashboard.Etag = ""mutatesclonein place beforeproto.Marshal(clone)is called. - We zero out
EtagandNameon the clone so the hash is deterministically computed from the dashboard specification alone:- On updates, incoming objects already have an existing
etagset, which would otherwise pollute the computed hash. - MockGCP generates random UUIDs in
Name, so clearingNameensures the Etag does not change across runs or mock recreations.
- On updates, incoming objects already have an existing
I have added an explanatory doc comment to computeEtag and removed the empty visitTimeSeriesTable helper function as well!
95dd25d to
5e28724
Compare
…e REST client Migrate MonitoringDashboard direct controller from the Cloud Monitoring v1 gRPC client to google.golang.org/api/monitoring/v1 (REST client). Using the Google REST client aligns request/response payloads with MockGCP, natively using string enums instead of integer enum encodings. This enables 100% golden log alignment across all MonitoringDashboard fixtures without requiring custom enum mappers or normalizations in golden_alignment_test.go.
5e28724 to
c07f0c2
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gemmahou The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
0db24d6
…riesQuery (GoogleCloudPlatform#12458) #### What this PR does / why we need it: Fixes GoogleCloudPlatform#7090 Stacked on prerequisite PR GoogleCloudPlatform#13574 (migrate MonitoringDashboard controller to Google REST client). Adds support for `opsAnalyticsQuery` (SQL-based queries for Log Analytics) to `MonitoringDashboard.spec.gridLayout.widgets[].xyChart.dataSets[].timeSeriesQuery` and all layout widgets using `TimeSeriesQuery`. Key changes: - Adds `OpsAnalyticsQuery` struct and field to `TimeSeriesQuery` in `apis/monitoring/v1beta1/monitoringdashboard_types.go`. - Adds E2E test fixture `monitoringdashboard-opsanalyticsquery` with golden REST HTTP traffic recorded from real GCP and aligned with MockGCP. - Regenerates CRD, deepcopy, and mapper code. #### Which issue(s) this PR fixes: Fixes GoogleCloudPlatform#7090 #### Special notes for your reviewer: - Stacked on prerequisite PR GoogleCloudPlatform#13574. - All presubmits (`make fmt`, `go vet ./...`, `TestGoldenLogAlignment`, `TestFocusedMappers`) passed cleanly. #### Does this PR introduce a user-facing change? ```release-note MonitoringDashboard: add `opsAnalyticsQuery` field to `TimeSeriesQuery` ```
What this PR does / why we need it:
Prerequisite for #12458.
Migrates the
MonitoringDashboarddirect controller fromcloud.google.com/go/monitoring/dashboard/apiv1(gRPC client) togoogle.golang.org/api/monitoring/v1(Google REST client).Using the Google REST client aligns request/response payloads with MockGCP, natively using string enums instead of integer enum encodings (
%24alt=json%3Benum-encoding%3Dint). This achieves 100% golden log alignment across allMonitoringDashboardtest fixtures without requiring enum mappings or normalizations ingolden_alignment_test.go.Additionally:
mockgcp/generated/mockgcp/monitoring/dashboard/v1(from feat(mockgcp): add google.monitoring.dashboard.v1 proto definitions #13471).dashboardFilters.valueTypeintests/e2e/normalize.go.minAlignmentPeriod: "0s"defaulter in MockGCP to match real GCP behavior.Which issue(s) this PR fixes:
Prerequisite for #7090 / #12458
Does this PR introduce a user-facing change?