Skip to content

PO to GMP Migration Tool: Refactor Common Conversion Functions - #1990

Merged
karthunni merged 16 commits into
karthunni/po-migrate-podmonitor-limits-scrapeclassfrom
karthunni/po-migrate-refactor
Aug 6, 2026
Merged

PO to GMP Migration Tool: Refactor Common Conversion Functions#1990
karthunni merged 16 commits into
karthunni/po-migrate-podmonitor-limits-scrapeclassfrom
karthunni/po-migrate-refactor

Conversation

@karthunni

Copy link
Copy Markdown
Collaborator

Refactoring conversion functions to reduce code duplication and simplify implementation for impending ServiceMonitor migration logic.

@karthunni karthunni self-assigned this Jul 21, 2026
@karthunni karthunni changed the title PO to GMP Migration Tool: Refactor Conversion Functions PO to GMP Migration Tool: Refactor Common Conversion Functions Jul 21, 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 refactors the migration helpers and PodMonitor converter by extracting common logic into shared helper functions and introducing a commonMonitorSpec struct. Feedback is provided to address a bug in resolveFilterRunning where explicit filterRunning: true configurations are silently dropped, and to add defensive nil checks for the spec parameter in buildPodMonitoring and buildClusterPodMonitoring to prevent potential nil pointer dereferences.

Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/helpers.go
@karthunni
karthunni force-pushed the karthunni/po-migrate-refactor branch 2 times, most recently from 3b27e3b to 973c9b2 Compare July 21, 2026 18:35
@karthunni
karthunni force-pushed the karthunni/po-migrate-refactor branch from 973c9b2 to e8cd8d0 Compare July 23, 2026 15:14
@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 refactors the migration helpers and PodMonitor converter to reduce code duplication and improve maintainability. It introduces a shared commonMonitorSpec struct and extracts several helper functions for resolving scrape intervals, timeouts, proxy URLs, authentication, TLS settings, and unsupported fields. These helpers are then utilized to consolidate the conversion logic for both PodMonitoring and ClusterPodMonitoring resources. I have no feedback to provide as the changes are clean and well-structured.

@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 refactors the migration logic for PodMonitor resources by extracting common conversion logic, validation, and warning routines into helper functions within pkg/migrate/helpers.go. It also introduces a commonMonitorSpec struct to share configurations between namespaced and cluster-scoped resources, significantly reducing code duplication. The reviewer feedback suggests adding a nil check for the gmpEp parameter in the new applyAuthAndTLS helper function to prevent potential nil pointer dereferences.

Comment thread pkg/migrate/helpers.go
@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 refactors the PodMonitor migration logic by modularizing helper functions into helpers.go and introducing a shared commonMonitorSpec struct to streamline the conversion of both PodMonitoring and ClusterPodMonitoring resources. The review feedback focuses on improving resilience during migration; specifically, it suggests refactoring determineNamespaceScoping, resolveScrapeIntervalAndTimeout, and convertProxyURL to log warnings and fall back to safe defaults or placeholders instead of returning fatal errors when encountering non-fatal configuration issues.

Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/podmonitor.go
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/podmonitor.go
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/podmonitor.go
@karthunni
karthunni force-pushed the karthunni/po-migrate-refactor branch from dd4645d to e7f1688 Compare July 27, 2026 19:05
@karthunni
karthunni force-pushed the karthunni/po-migrate-refactor branch from e7f1688 to 578df0a Compare July 28, 2026 15:16
@dashpole dashpole self-assigned this Jul 29, 2026
@karthunni
karthunni marked this pull request as ready for review July 29, 2026 20:45
@karthunni
karthunni force-pushed the karthunni/po-migrate-refactor branch from f690691 to 643c79c Compare July 29, 2026 20:55
@karthunni
karthunni requested a review from bernot-dev July 29, 2026 21:54
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.go
@karthunni
karthunni force-pushed the karthunni/po-migrate-refactor branch 3 times, most recently from e26af0b to af7a1b2 Compare July 31, 2026 15:13
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/podmonitor.go Outdated
@karthunni
karthunni force-pushed the karthunni/po-migrate-refactor branch from af7a1b2 to f1d5cfa Compare July 31, 2026 19:54
@karthunni
karthunni force-pushed the karthunni/po-migrate-refactor branch from 052385d to a257779 Compare August 3, 2026 14:58
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/podmonitor.go Outdated
Comment thread pkg/migrate/types.go Outdated
@karthunni
karthunni force-pushed the karthunni/po-migrate-refactor branch from 191f0c4 to 5a792f8 Compare August 5, 2026 14:26
Comment thread pkg/migrate/podmonitor.go
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers_test.go Outdated
@karthunni
karthunni force-pushed the karthunni/po-migrate-refactor branch from c255bfb to 21cbeb7 Compare August 6, 2026 01:28
@karthunni
karthunni merged commit 1f91eca into main Aug 6, 2026
43 checks passed
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