Skip to content

PO to GMP Migration Tool: Podmonitor Auth, TLS and Proxy Migration#1982

Open
karthunni wants to merge 14 commits into
mainfrom
karthunni/po-migrate-auth-secret-proxy
Open

PO to GMP Migration Tool: Podmonitor Auth, TLS and Proxy Migration#1982
karthunni wants to merge 14 commits into
mainfrom
karthunni/po-migrate-auth-secret-proxy

Conversation

@karthunni

Copy link
Copy Markdown
Collaborator

Adds migration logic to map Authentication, TLS, and Proxy configurations from Prometheus Operator PodMonitor endpoints into GMP PodMonitoring equivalents.

This change introduces the core extraction helpers required to consolidate nested Kubernetes corev1.SecretKeySelector and corev1.ConfigMapKeySelector references into GMP's monitoringv1.SecretKeySelector struct.

Key Changes:

  • Added translation mapping for BasicAuth, BearerTokenSecret, TLSConfig, and OAuth2 fields within endpoint configurations.
  • Added functions (extractSecretKey, extractConfigMapKey) that inject clear <MISSING_...> placeholders and emit warnings if a referenced resource is missing from the input files.
  • Added convertConfigMapToSecretSelector to automatically migrate TLS ConfigMap references into generated Secrets, adhering to GMP's strict Secret-only TLS requirements.
  • Added comprehensive, table-driven unit tests for all edge cases (cache hits vs misses, empty inputs) in helpers_test.go.
  • Added a test case to podmonitor_test.go.

@karthunni karthunni self-assigned this Jul 7, 2026

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

Copy link
Copy Markdown

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 introduces helper functions and a conversion context in pkg/migrate/helpers.go to support translating Prometheus Operator configurations (such as TLS, BasicAuth, OAuth2, and Relabelings) to Google Managed Prometheus (GMP) equivalents, updating PodMonitor conversion to utilize these helpers, and adding corresponding unit tests. The review feedback recommends tracking whether target resources are cluster-scoped via an isClusterScoped field in the conversion context to correctly set namespaces on generated secret selectors. Additionally, the feedback suggests returning explicit errors instead of hardcoded placeholders for invalid or empty selectors, and safely returning nil when selectors are unspecified.

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 Outdated
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/podmonitor.go
Comment thread pkg/migrate/podmonitor.go
@karthunni karthunni force-pushed the karthunni/podmonitor-endpoint-migration branch from 01c870a to a230cd6 Compare July 7, 2026 18:44
@karthunni karthunni force-pushed the karthunni/po-migrate-auth-secret-proxy branch from 3c8d1a9 to d4eb356 Compare July 7, 2026 19:14
@karthunni

Copy link
Copy Markdown
Collaborator Author

/gemini review

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

Copy link
Copy Markdown

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 introduces helper functions in pkg/migrate/helpers.go to convert Prometheus Operator configurations (such as Secrets, ConfigMaps, BasicAuth, TLS, OAuth2, and Authorization) to Google Cloud Prometheus (GMP) equivalents, generating Secret manifests when translating ConfigMaps. These helpers are integrated into the PodMonitorConverter and covered by new unit tests. Feedback on the changes highlights a critical issue where duplicate Secret manifests can be generated if multiple endpoints or fields reference the same ConfigMap, which would cause collision errors during migration.

Comment thread pkg/migrate/helpers.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

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 introduces conversion helpers and context in pkg/migrate/helpers.go to translate Prometheus Operator configurations (such as BasicAuth, TLS, OAuth2, and Authorization) into Google Cloud Prometheus (GMP) equivalents, and updates PodMonitorConverter to support these mappings. The feedback focuses on handling empty ConfigMap and Secret selectors gracefully by returning nil when both name and key are empty, and ensuring deterministic output by sorting the generated secrets before returning them, which also requires importing the sort package.

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

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@karthunni

Copy link
Copy Markdown
Collaborator Author

/gemini review

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

Copy link
Copy Markdown

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 introduces conversion helper functions in pkg/migrate/helpers.go to translate Prometheus Operator configurations (such as Secrets, ConfigMaps, BasicAuth, TLS, OAuth2, and Authorization) into Google Cloud Managed Service for Prometheus (GMP) formats, and integrates them into the PodMonitor converter with accompanying tests. Feedback on the changes suggests robustly handling binaryData in ConfigMap extraction, mapping missing TLS version constraints and OAuth2 parameters, and avoiding loop variable pointer capture when handling deprecated bearer token secrets.

Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/podmonitor.go
@karthunni karthunni force-pushed the karthunni/po-migrate-auth-secret-proxy branch from 16dfba1 to 5491eb9 Compare July 8, 2026 15:33
@karthunni

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@karthunni

Copy link
Copy Markdown
Collaborator Author

/gemini review

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

Copy link
Copy Markdown

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 introduces helper functions and a conversion context in pkg/migrate/helpers.go to support translating Prometheus Operator configurations (such as BasicAuth, TLS, OAuth2, and Authorization) into Google Cloud Prometheus Engine (GMP) equivalents, including converting ConfigMaps to Secrets. Unit tests were added to verify these helpers, and PodMonitorConverter was updated to utilize them. A review comment identified a potential collision issue where multiple PodMonitor resources sharing the same TLS ConfigMap would attempt to generate duplicate Secrets with the same name, and suggested caching the generated Secrets to prevent this.

Comment thread pkg/migrate/helpers.go
@karthunni karthunni force-pushed the karthunni/po-migrate-auth-secret-proxy branch from 5369d22 to 7305317 Compare July 8, 2026 18:08
@karthunni karthunni changed the base branch from karthunni/podmonitor-endpoint-migration to main July 8, 2026 18:08
@karthunni

Copy link
Copy Markdown
Collaborator Author

/gemini review

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

Copy link
Copy Markdown

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 introduces conversion helper functions and context in pkg/migrate/helpers.go to translate Prometheus Operator configurations (such as BasicAuth, SafeTLSConfig, OAuth2, and Authorization) into Google Cloud Prometheus Engine (GMP) resources. It also updates the migration logic to accumulate and deduplicate generated resources, and integrates these helpers into pkg/migrate/podmonitor.go along with comprehensive unit tests. The review feedback suggests trimming trailing whitespace and newlines before decoding base64 data in Secrets and ConfigMaps to prevent unexpected decoding failures, and replacing hardcoded strings with defined constants (KindConfigMap and KindSecret) for consistency.

Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.go Outdated
Comment thread pkg/migrate/helpers.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

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 introduces helper functions and a conversion context to translate Prometheus Operator configurations (such as TLS, BasicAuth, OAuth2, and Relabeling rules) into Google Cloud Prometheus Engine (GMP) equivalents, while also adding deduplication logic for generated Secrets. The review feedback highlights a potential issue where strict base64 decoding of Secret data and ConfigMap binaryData fields might fail due to internal whitespaces or newlines, and suggests stripping all whitespace characters before decoding.

Comment thread pkg/migrate/helpers.go
Comment thread pkg/migrate/helpers.go
@karthunni karthunni marked this pull request as ready for review July 8, 2026 20:13
@karthunni karthunni requested a review from bernot-dev July 8, 2026 20:15
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.

1 participant