Skip to content

refactor(monitoring): migrate MonitoringDashboard controller to Google REST client - #13574

Merged
ldanielmadariaga merged 2 commits into
GoogleCloudPlatform:masterfrom
ldanielmadariaga:refactor-monitoringdashboard-rest-client
Oct 6, 2026
Merged

ldanielmadariaga merged 2 commits into
GoogleCloudPlatform:masterfrom
ldanielmadariaga:refactor-monitoringdashboard-rest-client

Conversation

@ldanielmadariaga

@ldanielmadariaga ldanielmadariaga commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

Prerequisite for #12458.

Migrates the MonitoringDashboard direct controller from cloud.google.com/go/monitoring/dashboard/apiv1 (gRPC client) to google.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 all MonitoringDashboard test fixtures without requiring enum mappings or normalizations in golden_alignment_test.go.

Additionally:

  • Updates protobuf references to mockgcp/generated/mockgcp/monitoring/dashboard/v1 (from feat(mockgcp): add google.monitoring.dashboard.v1 proto definitions #13471).
  • Normalizes dashboardFilters.valueType in tests/e2e/normalize.go.
  • Removes unnecessary minAlignmentPeriod: "0s" defaulter in MockGCP to match real GCP behavior.
  • Re-records golden HTTP logs with the REST client across fixtures.

Which issue(s) this PR fixes:

Prerequisite for #7090 / #12458

Does this PR introduce a user-facing change?

NONE

@gemmahou gemmahou left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Two nit comments...

Comment thread mockgcp/mockmonitoring/dashboard.go Outdated
@@ -235,11 +234,6 @@ func (d *dashboardDefaulter) visitPieChart(obj *pb.PieChart) {
}

func (d *dashboardDefaulter) visitTimeSeriesTable(obj *pb.TimeSeriesTable) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two details explain why this block is there:

  1. In Go, dashboard is a typed pointer to the clone message (clone := proto.Clone(obj)), so setting dashboard.Name = "" and dashboard.Etag = "" mutates clone in place before proto.Marshal(clone) is called.
  2. We zero out Etag and Name on the clone so the hash is deterministically computed from the dashboard specification alone:
    • On updates, incoming objects already have an existing etag set, which would otherwise pollute the computed hash.
    • MockGCP generates random UUIDs in Name, so clearing Name ensures the Etag does not change across runs or mock recreations.

I have added an explanatory doc comment to computeEtag and removed the empty visitTimeSeriesTable helper function as well!

@google-oss-prow google-oss-prow Bot added lgtm and removed lgtm labels Oct 2, 2026
@ldanielmadariaga
ldanielmadariaga force-pushed the refactor-monitoringdashboard-rest-client branch from 95dd25d to 5e28724 Compare October 3, 2026 06:49
…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.
@ldanielmadariaga
ldanielmadariaga force-pushed the refactor-monitoringdashboard-rest-client branch from 5e28724 to c07f0c2 Compare October 3, 2026 22:23
@google-oss-prow google-oss-prow Bot added the lgtm label Oct 5, 2026
@google-oss-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gemmahou
Once this PR has been reviewed and has the lgtm label, please ask for approval from ldanielmadariaga. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ldanielmadariaga
ldanielmadariaga added this pull request to the merge queue Oct 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 5, 2026
@ldanielmadariaga
ldanielmadariaga added this pull request to the merge queue Oct 5, 2026
Merged via the queue into GoogleCloudPlatform:master with commit 0db24d6 Oct 6, 2026
493 of 495 checks passed
daedalus-agent-bot pushed a commit to daedalus-agent-bot/k8s-config-connector that referenced this pull request Oct 7, 2026
…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`
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址