Skip to content

Conversation

@EricWittmann
Copy link
Member

@EricWittmann EricWittmann commented Dec 1, 2025

Summary

This PR adds MySQL storage support to the Apicurio Registry operator, enabling users to deploy Registry instances with MySQL databases.

  • Added mysql as a first-class storage type alongside PostgreSQL and KafkaSQL
  • Renamed PostgresSql class to SqlStorage to support multiple SQL database types
  • Implemented JDBC URL validation to reject mismatched storage type and URL combinations
  • Uncommented and updated MySQL deployment documentation
  • Added integration test for MySQL datasource configuration

Related Issue

Fixes #6919

Test Plan

  • Verify operator builds successfully with Maven
  • Run MysqlDataSourceITTest integration test
  • Test deploying a registry instance with type: mysql storage
  • Verify validation rejects type: mysql with jdbc:postgresql:// URL
  • Verify validation rejects type: postgresql with jdbc:mysql:// URL
  • Confirm documentation renders correctly with MySQL examples
  • Test backward compatibility - ensure existing PostgreSQL deployments continue to work

This change adds MySQL as a first-class storage type alongside PostgreSQL,
enabling users to deploy Apicurio Registry with MySQL databases through the operator.

Key changes:
- Added MYSQL to StorageType enum
- Renamed PostgresSql to SqlStorage to support multiple SQL databases
- Implemented JDBC URL validation to reject type/URL mismatches
- Uncommented MySQL documentation and updated examples to use type: mysql
- Added integration test for MySQL datasource configuration

Fixes #6919
Copy link

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 MySQL as a first-class storage type to the Apicurio Registry operator, expanding the supported database backends beyond PostgreSQL and KafkaSQL. The implementation refactors the PostgreSQL-specific code into a more generic SQL storage handler that supports both PostgreSQL and MySQL databases, with proper validation to prevent misconfigurations.

Key Changes:

  • Added MYSQL enum value to StorageType alongside PostgreSQL and KafkaSQL
  • Refactored PostgresSql class to SqlStorage to handle both PostgreSQL and MySQL configurations
  • Implemented JDBC URL validation that ensures the URL scheme matches the declared storage type
  • Updated automatic CR migration logic to recognize both PostgreSQL and MySQL as SQL storage types

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
operator/model/src/main/java/io/apicurio/registry/operator/api/v1/spec/StorageType.java Added MYSQL enum value to support MySQL as a storage type
operator/model/src/main/java/io/apicurio/registry/operator/api/v1/spec/StorageSpec.java Updated JavaDoc and schema descriptions to document MySQL support
operator/install/install.yaml Updated CRD schema to include mysql enum value and updated version to 3.1.5-SNAPSHOT
operator/controller/src/test/resources/k8s/examples/mysql/example-mysql.apicurioregistry3.yaml Added example MySQL configuration with JDBC URL and credentials
operator/controller/src/test/resources/k8s/examples/mysql/example-mysql-database.yaml Added MySQL StatefulSet, Service, and Secret for testing purposes
operator/controller/src/test/java/io/apicurio/registry/operator/it/MysqlDataSourceITTest.java Added integration test verifying MySQL datasource configuration and deployment
operator/controller/src/main/java/io/apicurio/registry/operator/updater/SqlCRUpdater.java Updated CR migration logic to handle both PostgreSQL and MySQL as SQL storage types
operator/controller/src/main/java/io/apicurio/registry/operator/resource/app/AppDeploymentResource.java Updated deployment resource to use SqlStorage for both PostgreSQL and MySQL
operator/controller/src/main/java/io/apicurio/registry/operator/feat/SqlStorage.java New class replacing PostgresSql with support for both database types and JDBC URL validation
operator/controller/src/main/java/io/apicurio/registry/operator/feat/PostgresSql.java Deleted and replaced by SqlStorage
docs/modules/ROOT/pages/getting-started/assembly-operator-config-reference.adoc Uncommented MySQL example configuration in documentation
docs/modules/ROOT/pages/getting-started/assembly-deploying-registry-operator.adoc Uncommented and updated MySQL deployment guide section

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +79 to +89
private static String getSqlKind(StorageType storageType) {
if (storageType == null) {
throw new OperatorException("Storage type must be specified for SQL storage");
}
return switch (storageType) {
case POSTGRESQL -> "postgresql";
case MYSQL -> "mysql";
default -> throw new OperatorException(
"Unsupported SQL storage type: " + storageType.getValue());
};
}
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The getSqlKind method lacks test coverage. While the integration test verifies MySQL configuration works end-to-end, there are no unit tests for the getSqlKind method that verify:

  1. StorageType.POSTGRESQL returns "postgresql"
  2. StorageType.MYSQL returns "mysql"
  3. Null storage type throws OperatorException with appropriate message
  4. Other storage types (e.g., KAFKASQL) throw OperatorException

Consider adding unit tests for this method to ensure the correct SQL kind is returned for each storage type.

Copilot uses AI. Check for mistakes.
Comment on lines 179 to 181
private static boolean isSqlStorageType(StorageType storageType) {
return StorageType.POSTGRESQL.equals(storageType) || StorageType.MYSQL.equals(storageType);
}
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The isSqlStorageType helper method in SqlCRUpdater lacks test coverage. This method is critical for backward compatibility during automatic CR migrations. Consider adding unit tests to verify:

  1. Returns true for StorageType.POSTGRESQL
  2. Returns true for StorageType.MYSQL
  3. Returns false for StorageType.KAFKASQL
  4. Returns false for null

This ensures the automatic migration logic correctly identifies SQL storage types.

Copilot uses AI. Check for mistakes.
Comment on lines +98 to +115
private static void validateJdbcUrl(StorageType storageType, String jdbcUrl) {
if (storageType == null || jdbcUrl == null) {
return;
}

String expectedPrefix = switch (storageType) {
case POSTGRESQL -> "jdbc:postgresql://";
case MYSQL -> "jdbc:mysql://";
default -> null;
};

if (expectedPrefix != null && !jdbcUrl.startsWith(expectedPrefix)) {
throw new OperatorException(String.format(
"JDBC URL mismatch: storage type is '%s' but JDBC URL is '%s'. "
+ "Expected URL to start with '%s'",
storageType.getValue(), jdbcUrl, expectedPrefix));
}
}
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The JDBC URL validation logic lacks test coverage. The PR description mentions testing that validation rejects mismatched storage types and URLs, but there are no unit tests for the validateJdbcUrl method. Consider adding unit tests to verify:

  1. type: mysql with jdbc:postgresql:// URL throws OperatorException
  2. type: postgresql with jdbc:mysql:// URL throws OperatorException
  3. Valid combinations pass validation
  4. Null URL or storage type is handled correctly

This validation is critical for preventing misconfigurations in production deployments.

Copilot uses AI. Check for mistakes.
EricWittmann added a commit that referenced this pull request Dec 2, 2025
- Move isSqlStorageType() to StorageType enum for better reusability
- Remove PostgreSQL default in CR updater, use existing storage type instead
- Update warning message to mention both SQL storage types
- Rename SqlDataSourceITTest to PostgresqlDataSourceITTest for clarity

Changes based on review feedback in PR #6936:
1. SqlCRUpdater now uses storageType.orElse(POSTGRESQL) instead of hardcoding POSTGRESQL
2. Storage type validation now uses StorageType.isSqlStorageType() instance method
3. Test naming is clearer with separate PostgreSQL and MySQL test classes
- Copy storageType instead of defaulting to PostgreSQL in SqlCRUpdater
- Move isSqlStorageType logic to StorageType.isSql() method
- Rename SqlDataSourceITTest to PostgresqlDataSourceITTest for consistency
@EricWittmann EricWittmann merged commit 0399c04 into main Dec 3, 2025
23 checks passed
@EricWittmann EricWittmann deleted the issues/6919 branch December 3, 2025 13:33
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.

Operator support for MySQL storage

3 participants