Skip to content

PO to GMP Migration Tool: Podmonitor Limits, ScrapeClass, Metadata. FilterRunning Migration - #1989

Open
karthunni wants to merge 9 commits into
karthunni/po-migrate-relabelingfrom
karthunni/po-migrate-podmonitor-limits-scrapeclass
Open

PO to GMP Migration Tool: Podmonitor Limits, ScrapeClass, Metadata. FilterRunning Migration#1989
karthunni wants to merge 9 commits into
karthunni/po-migrate-relabelingfrom
karthunni/po-migrate-podmonitor-limits-scrapeclass

Conversation

@karthunni

Copy link
Copy Markdown
Collaborator

This change completes the missing configuration fields in the PodMonitor migration path to GKE Managed Prometheus (PodMonitoring and ClusterPodMonitoring).

Key changes:

  • Node Metadata Mapping: Maps attachMetadata.node to targetLabels.metadata: ["node"].
  • Limits Mapping: Maps sampleLimit, labelLimit, labelNameLengthLimit, and labelValueLengthLimit to GMP's ScrapeLimits.
  • FilterRunning aggregation: Aggregates endpoint-level filterRunning configurations to the resource level.
  • ScrapeClass TODO & Warnings: Emits warning logs when a scrapeClassName is configured, noting that inherited settings will be lost. Added a TODO code comments to resolve and merge ScrapeClass settings from the Prometheus CR once that migration pipeline is implemented.

@karthunni karthunni self-assigned this Jul 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for converting limits, node metadata attachment, and filter-running configurations from Prometheus PodMonitor resources to GMP PodMonitoring and ClusterPodMonitoring resources, alongside adding relevant unit tests and warnings for unsupported fields. The review feedback points out a concurrency/mutation risk where the metadata slice is modified in-place via pointer dereference. To prevent unexpected side effects on shared or cached configurations, it is recommended to copy the slice before appending new elements.

Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor.go Outdated
@karthunni

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements conversion logic for limits, node metadata attachment, and filter-running configurations from Prometheus PodMonitors to GMP PodMonitoring and ClusterPodMonitoring resources, along with corresponding test coverage and warnings for unsupported fields. The review feedback suggests improving the warning messages for endpoint-level filterRunning settings to clarify that the tool automatically applies the configuration globally and to ensure the correct resource type is referenced in the ClusterPodMonitoring converter.

Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor.go Outdated
@karthunni

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for mapping PodMonitor limit settings to GMP ScrapeLimits and handles several unsupported fields (such as followRedirects, enableHttp2, scrapeClassName, and scrapeProtocols) by logging warnings. It also adds conversion logic for AttachMetadata.Node and resource-level FilterRunning settings. The review feedback suggests avoiding taking the address of block-local variables when updating metadata, and refining the FilterRunning warning logic to only trigger when there is an actual conflict between endpoints.

Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor.go Outdated
@karthunni

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for converting PodMonitor limit settings, node metadata attachment, and filter-running configurations to GMP ScrapeLimits and PodMonitoring/ClusterPodMonitoring specs, along with warnings for unsupported fields. The reviewer recommends extracting the duplicated spec-level field processing logic from both convertToPodMonitoring and convertToClusterPodMonitoring into a single shared helper function in helpers.go to reduce code duplication and improve maintainability.

Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/podmonitor.go
Comment thread pkg/migrate/podmonitor.go
@karthunni
karthunni force-pushed the karthunni/po-migrate-podmonitor-limits-scrapeclass branch from 43c6120 to cbeae05 Compare July 21, 2026 14:15
@karthunni
karthunni requested a review from bernot-dev July 22, 2026 20:59
@karthunni
karthunni marked this pull request as ready for review July 22, 2026 20:59
@karthunni
karthunni force-pushed the karthunni/po-migrate-podmonitor-limits-scrapeclass branch from cbeae05 to 99b9190 Compare July 23, 2026 15:08
@karthunni
karthunni force-pushed the karthunni/po-migrate-podmonitor-limits-scrapeclass branch 3 times, most recently from feba832 to 034c91a Compare July 28, 2026 14:56
@dashpole dashpole self-assigned this Jul 29, 2026
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor_test.go
Comment thread pkg/migrate/podmonitor_test.go
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/podmonitor.go
Comment thread pkg/migrate/podmonitor.go
Comment thread pkg/migrate/podmonitor.go
@karthunni
karthunni force-pushed the karthunni/po-migrate-podmonitor-limits-scrapeclass branch from ee7f76d to 3273c74 Compare July 30, 2026 16:10
Comment thread pkg/migrate/podmonitor.go
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor.go
warnUnsupportedSpecFields(logger, pm.Spec)
// TODO(M2): Resolve and merge ScrapeClass configurations from Prometheus CR if scrapeClassName is specified.
if pm.Spec.ScrapeClassName != nil && *pm.Spec.ScrapeClassName != "" {
logger.Warn(fmt.Sprintf("ScrapeClass %q was not found in the inputs. The 'scrapeClassName' field has been dropped and inherited settings will be lost.", *pm.Spec.ScrapeClassName))

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.

The warning claims was not found in the inputs, implying a lookup was attempted. Saying is not yet supported or could not be resolved would be clearer.

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.

Plan is to add support in M2, but I could temporarily change the logs to `is not yet supported``

Comment thread pkg/migrate/helpers.go

// Constants representing the supported ScrapeProtocol enum values defined in upstream Prometheus Operator.
const (
scrapeProtocolOpenMetricsText001 = pomonitoringv1.ScrapeProtocol("OpenMetricsText0.0.1")

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.

Unused constant scrapeProtocolOpenMetricsText001 (along with scrapeProtocolPrometheusText004 on line 49). Consider removing them if they aren't needed.

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.

Defined them in case they are needed for the future and/or for test cases -- but can remove them

Comment thread pkg/migrate/helpers.go Outdated
@@ -1435,6 +1884,16 @@ func TestPodMonitorConversion(t *testing.T) {
t.Fatalf("Convert failed: %v", err)

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.

wantWarnings only asserts positive matches. Adding a dontWantWarnings []string field to the test table would allow pinning negative cases (e.g. verifying no conflict warning is emitted when all endpoints set filterRunning: false).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants