Skip to content

Allow kubegres manager to manage SQL connections to the primary instance #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sergicastro
Copy link
Collaborator

@sergicastro sergicastro commented Aug 6, 2025

I need to finish testing of the TLS PR #51 before making this connection management compatible with TLS-secured connections.

The func (r *ServicesCountSpecEnforcer) canConnectToPrimaryDb() bool method is the current one checking all of this works.
It will need to be removed once the target PR starts using these changes.

@sergicastro sergicastro requested review from piotrkpc and Copilot August 6, 2025 14:28
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds SQL connection management functionality to the kubegres manager, allowing it to establish and manage connections to primary PostgreSQL instances. The implementation includes a new connection store system, DSN management for dynamic connection configuration, and reconciliation logic to handle Kubegres resources and their associated secrets.

  • Introduces connection management infrastructure with thread-safe stores and dynamic DSN handling
  • Adds new reconcilers for Kubegres resources and secrets to manage database connections
  • Implements TLS configuration support in the API for secure database connections

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/sql/store.go Implements thread-safe connection store for managing database connections by ConnectionID
internal/sql/connection.go Provides connection abstractions with DSN management and dynamic reconnection capabilities
controllers/connection/reconciler.go Implements reconciliation logic for database connections based on Kubegres and secret changes
controllers/connection/sync_map.go Generic thread-safe map implementation for connection management
controllers/kubegres_controller.go Updates main controller to include connection store dependency
api/v1/kubegres_types.go Adds TLS configuration struct to Kubegres API
test/util/DbConnectionTestUtil.go Enhances test utilities to export connection details via environment variables
test/util/MockLogger.go Improves mock logger name handling and formatting

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Sergi Castro <[email protected]>
@piotrkpc piotrkpc merged commit b6b7f2f into tetrateio:manage-replication-slots Aug 7, 2025
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