-
Notifications
You must be signed in to change notification settings - Fork 23
[SECURESIGN-3170] Support PostgreSQL as an optional backend database for Trillian #1483
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
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
153996a to
5a541ac
Compare
| SecretUser = "mysql-user" | ||
| SecretPort = "mysql-port" | ||
| SecretHost = "mysql-host" | ||
| SecretPassword = "db-password" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You unable to simple rename these values, it broke existing instances on upgrade. You have to keep both options for backward compatibility.
api/v1alpha1/trillian_types.go
Outdated
| // If false (default), MySQL/MariaDB is expected. | ||
| //+kubebuilder:default:=false | ||
| //+optional | ||
| UsePostgreSQL bool `json:"usePostgreSQL"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trillian support multiple storage systems so it is not right way to specify which to use. It should be enum type which has these options allowed mysql and postgresql. Please name the field provider so it is aligned with other CRDs standard.
| // mysql-password: The password to connect to the MySQL server | ||
| // mysql-database: The database to connect to | ||
| //+optional | ||
| // For PostgreSQL, only connection is supported, the secret must contain: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned about the new set of variables. Could we consider using the data source URL, similar to how we handle the search index? https://github.com/securesign/secure-sign-operator/blob/main/api/v1alpha1/rekor_types.go#L154
Envs are mounted by https://github.com/securesign/secure-sign-operator/blob/main/api/v1alpha1/rekor_types.go#L55
Any changes must be implemented carefully to maintain backward compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we consider using the data source URL:
Do you mean for both providers (mysql and postgresql) ?
If it's only for postgresql, I have added env variables for postgresql to have a similar config as mysql to be able to re-use the existing code in server-deployment.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, for both. I would like to have unified API for all components. The searchIndex uses the following format (see the data source spec https://jdbc.postgresql.org/documentation/use/#connecting-to-the-database):
"$(MYSQL_USER):$(MYSQL_PASSWORD)@tcp(my-mysql.$(NAMESPACE).svc:3300)/$(MYSQL_DB)"
https://github.com/securesign/secure-sign-operator/blob/main/test/e2e/byodb_test.go#L43
I know, that this could mean an API change that we can't afford in a minor version release. I just want to bring this to the table and explore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about changing searchIndex config to be as trillian DB's ? I find it easier to be handled by the customers.
I think providing the full database URL puts too much responsibility on the customer and increases the chance of mistakes. Supplying only the essential variables allows the operator to assemble the URL correctly and consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utilizing a URL to pass the datasource is a widely accepted convention. This method provides the flexibility to embed numerous configuration parameters, such as those relating to TLS (Transport Layer Security). Conversely, the discovery of proprietary parameter names may present challenges and is susceptible to error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if we apply it on the trillian mysql db, won't this break upgrade scenario and backward compatibility ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about providing a default URL that will read content from the secret. The secret needs to be mounted as Auth (https://github.com/securesign/secure-sign-operator/blob/main/internal/controller/rekor/actions/server/deployment.go#L82). Do you think it is doable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this would break the upgrade scenario anyway, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so.
- The URL will have default value -> no braking change
- the credentials file will be just mapped diferently to the deployment but it will be still working
PR Type
Enhancement
Description
Add PostgreSQL support as optional backend database for Trillian
Introduce
usePostgreSQLflag to switch between MySQL and PostgreSQLRename MySQL-specific environment variables to generic database names
Update deployment logic to generate appropriate connection strings
Conditionally apply TLS configuration based on database type
Diagram Walkthrough
File Walkthrough
trillian_types.go
Add PostgreSQL flag and update secret documentationapi/v1alpha1/trillian_types.go
UsePostgreSQLboolean field toTrillianDBstruct with defaultvalue false
naming (db-host, db-port, db-user, db-password, database)
constants.go
Rename constants to database-agnostic naminginternal/controller/trillian/actions/constants.go
DbPvcNamefrom "trillian-mysql" to "trillian-db"mysql-port, mysql-user, mysql-password, mysql-database) to generic
database names (db-host, db-port, db-user, db-password, db-name)
SecretRootPasswordis MySQL-onlyhandle_secret.go
Update secret generation for generic databaseinternal/controller/trillian/actions/db/handle_secret.go
mysqlPasstodbPassfor generic database supportserver-deployment.go
Implement database-agnostic deployment configurationinternal/controller/trillian/utils/server-deployment.go
(MYSQL_HOSTNAME→DB_HOSTNAME, MYSQL_PORT→DB_PORT, MYSQL_USER→DB_USER,
MYSQL_PASSWORD→DB_PASSWORD, MYSQL_DATABASE→DB_NAME)
ensureDeploymentto generate PostgreSQL orMySQL connection strings based on
UsePostgreSQLflagWithTlsDBfunction to conditionally apply PostgreSQL or MySQLTLS configuration
rhtas.redhat.com_securesigns.yaml
Update SecureSign CRD with PostgreSQL supportconfig/crd/bases/rhtas.redhat.com_securesigns.yaml
usePostgreSQLfield to CRD schema with default value falsedatabase naming
rhtas.redhat.com_trillians.yaml
Update Trillian CRD with PostgreSQL supportconfig/crd/bases/rhtas.redhat.com_trillians.yaml
usePostgreSQLfield to CRD schema with default value falsedatabase naming
images.env
Update Trillian component image versionsconfig/default/images.env