mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 14:10:49 -05:00
7981e23dcd604209ea07194f45b2e05ab4823886
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
569f9f55e4 |
perf(build): replace quarkus-jdbc extensions with plain JDBC drivers (#3465)
* perf(build): replace quarkus-jdbc extensions with plain JDBC drivers The RDS Data API and Redshift Data API open connections with DriverManager. They never used Agroal, Narayana or the datasource layer that quarkus-jdbc-mysql and quarkus-jdbc-postgresql pull in. Depend on mysql-connector-j and postgresql directly and hand-supply the native image config the extensions provided. * perf(build): cut unused JDBC driver paths from the native image Substitute driver code that cannot be reached against the databases Floci provisions, mirroring what quarkus-jdbc-mysql did for JMX and going a step further for authentication and multi-host URLs. * perf(build): keep the MySQL cleanup thread disabled in JVM mode quarkus-jdbc-mysql set com.mysql.cj.disableAbandonedConnectionCleanup at startup in JVM mode as well as at native build time. The first commit carried only the native build argument and a surefire copy, so quarkus:dev and the JVM Docker image started Connector/J's abandoned connection cleanup thread on the first MySQL Data API call. In dev mode that thread is recreated with every restart and pins the old classloader. * fix(rdsdata): reject PostgreSQL result types the Data API does not support Aurora PostgreSQL answers a result set that holds a point, interval, money, box, circle, line, lseg, path or polygon column with UnsupportedResultException and the message "The result contains the unsupported data type POINT." Floci returned the driver's toString of the value instead. Check the column type names before reading the rows and raise the same error. json and jsonb stay supported, and a column cast to text still reads as a string, which is the workaround AWS documents. * perf(build): drop the PGobject reflection entries pgjdbc builds point, interval, money and the geometric types through reflection only when a result set holds such a column. The Data API now rejects those columns before reading a row, and json and jsonb values are plain PGobject instances the driver creates directly, so none of the ten entries can be reached. * chore(rdsdata): name the tolerated ClassNotFoundException in OpenTelemetryUnavailable * perf(build): keep PGInterval registered for the Redshift Data API Redshift tables can hold INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND columns and the Redshift Data API returns them as strings. Floci serves that path from a PostgreSQL container through pgjdbc, which builds an interval value by reflection, so the entry stays. The Redshift Data compat test now reads two interval columns on the native image. * perf(build): keep the geometric reflection entries for the Redshift Data API Redshift refuses point, box, circle, lseg, path and polygon as column types but evaluates them in a select, and its Data API returns the values as strings, checked on a real ra3.large cluster. Floci serves that path through pgjdbc, which builds those values by reflection, so the six entries stay. line stays out because Redshift rejects it, and money never reaches PGmoney because pgjdbc reads it as a double. The Redshift Data compat test selects those expressions and expects the strings Redshift returned. JdbcDriverNativeSupportTest resolves every registered class name. * fix(redshiftdata): fail statements that produce line, json or jsonb like Redshift Redshift has none of these types. A select that names one fails with "ERROR: type "line" not yet implemented" or "ERROR: type "json" does not exist", checked on a real cluster. The PostgreSQL container behind Floci's Redshift evaluates them, so the Data API now checks the result column types and fails the statement with the same text. |
||
|
|
6b17ef2b1c |
feat(redshift): emulate GetClusterCredentials and GetClusterCredentialsWithIAM (#3273)
* feat(redshift): add RedshiftCredentialBroker for short-lived Db credentials * refactor(rds-proxy): widen PasswordValidator to a three-value AuthResult The wire-level password check the PostgreSQL/MySQL proxy handlers take now returns REJECT / PASSTHROUGH / MASTER_EQUIVALENT instead of a boolean, so a caller can tell the proxy to open the backend leg as the cluster master for a client it has vouched for. RdsAuthProxy keeps its own boolean master-password callback, renamed MasterPasswordCheck to free the PasswordValidator name, and adapts it at the handler boundary (non-master stays PASSTHROUGH). * feat(redshift): auth proxy accepts live GetClusterCredentials credentials passwordValidatorFor now returns AuthResult and consults RedshiftCredentialBroker: the master pair and any live minted credential resolve to MASTER_EQUIVALENT, a known broker user with a stale password is REJECTed, everyone else PASSTHROUGH. * feat(redshift): add default-credential-duration-seconds config * feat(redshift): implement GetClusterCredentials action Mints a short-lived DbUser/DbPassword pair via RedshiftCredentialBroker and returns it as Query-protocol XML. AutoCreate prefixes IAM: on the DbUser, DbGroups are echoed, DurationSeconds is validated to 900-3600 (default from the new config key), and an unknown ClusterIdentifier propagates ClusterNotFound. The two credential actions are registered in AwsQueryController.REDSHIFT_ACTIONS and the Query dispatch now forwards the Authorization header to the handler. * feat(redshift): implement GetClusterCredentialsWithIAM action Derives the DbUser from the caller's IAM identity resolved via the Authorization header: an IAM user maps to IAM:<name>, an assumed role to IAMR:<role>, and an unresolvable caller to the IAMR:floci fallback with a WARN so local and CI flows are not blocked. Any DbUser request parameter is ignored. * feat(redshift-data): resolve non-master DbUser via GetClusterCredentials resolveViaDbUser now accepts a DbUser that has a live credential in RedshiftCredentialBroker, connecting to the container as the cluster master (the minted DbUser is nominal). An unknown non-master DbUser still fails with ValidationException. * test(redshift): end-to-end GetClusterCredentials + Data API non-master DbUser Docker-gated: mints a credential for a non-master DbUser via GetClusterCredentials then runs SELECT 1 through the Data API as that DbUser, asserting the result. * test(compat): SDK coverage for Redshift GetClusterCredentials Adds getClusterCredentials and getClusterCredentialsWithIAM assertions to the AWS SDK Redshift compatibility test. * docs(redshift): document GetClusterCredentials and GetClusterCredentialsWithIAM Regenerates the redshift.md action table (excluding the DbGroups member-name switch label), fills the two new descriptions, updates the wire-auth and redshift-data.md DbUser notes, and bumps the Service Matrix count to 23. * fix(redshift): reject a wrong master password instead of passing it through passwordValidatorFor only treated the master pair as MASTER_EQUIVALENT and let everything else fall to the broker. A request with the master username but a wrong password is unknown to the broker, so it classified as PASSTHROUGH; the wire proxy then opened the backend leg as master (isMaster is username-only) and the client authenticated with the wrong password. Now the master username is decided on its own password: match to MASTER_EQUIVALENT, mismatch to REJECT. * fix(redshift): reject proxy logins when the cluster row is gone; strip IAM user path passwordValidatorFor fell through to the broker when the cluster was absent from the account partition, classifying an unknown user as PASSTHROUGH; the wire proxy reads isMaster from its own start-time config, so that still opened the backend as master for the master username with any password. Return REJECT when there is no cluster row to validate against. RedshiftIamDbUserResolver now strips an IAM path prefix from a user ARN (user/team/alice -> alice), matching how AWS names the DbUser. * fix(redshift): keep concurrent credentials, revoke on delete, bound the config default Addresses PR review (greptile): - RedshiftCredentialBroker now holds every unexpired credential per DbUser instead of one slot, so a reissue no longer invalidates a still-live password (matches AWS, which keeps each issued credential valid to its own expiry). - Add revokeCluster(); RedshiftService calls it on deleteCluster and at the start of createCluster, so a cluster recreated with the same identifier does not inherit master-equivalent access from a stale credential. - resolveDurationSeconds now holds the YAML default to the same 900-3600 bounds as a request value, falling back to 900 with a WARN instead of minting a credential that is already expired or over-range. * fix(redshift): revoke temp credentials on createCluster rollback too The greptile review asked for revocation on 'relevant rollback paths'. Both createCluster failure branches that delete the cluster row now also call credentialBroker.revokeCluster, so a credential issued by a concurrent GetClusterCredentials while the row briefly existed cannot outlive it. * fix(redshift): correct GetClusterCredentials AutoCreate prefix AWS prefixes the returned DbUser with IAM: when AutoCreate is false and IAMA: when it is true. The handler returned IAM: when true and no prefix when false, so a client using the returned name could not authenticate and the value diverged from GetClusterCredentialsWithIAM, which already issues prefixed identities. The broker keys on the returned name, so the proxy and Data API now expect the prefixed DbUser. Tests and the redshift docs are updated to match. * test(redshift): give compat GetClusterCredentials tests distinct @Order Three methods shared @Order(2), leaving their relative order undefined. Number the two credential tests 3 and 4 and move testDeleteCluster to 5. |
||
|
|
b9039fef1d |
feat(redshift-data): emulate the Amazon Redshift Data API (#3186)
* feat(redshift-data): resource resolver, connection factory, statement store, service registration * feat(redshift-data): field mapper, column metadata, SQL parameter binding * feat(redshift-data): execute, describe, and paged result retrieval * feat(redshift-data): batch execution, list statements, cancel * feat(redshift-data): schema introspection operations * test(redshift-data): end-to-end Data API over a real cluster plus SDK compatibility test * docs(redshift-data): document the Redshift Data API surface * fix(redshift-data): address code review findings - rejectMultiStatement now reuses the SQL tokenizer so a semicolon inside a comment, string literal, or dollar-quoted block no longer rejects a valid single statement - GetStatementResultV2 gains unit coverage for the typed and CSV envelopes - CSV output is RFC 4180 quoted (embedded comma, quote, CR, LF) - batch rollback is asserted transactionally in the integration test - RedshiftDataFieldMapper logs a swallowed blob-read SQLException - RedshiftPid/RedshiftQueryId use a non-negative hash - NextToken that decodes to a negative offset is rejected - CancelStatement leaves a FAILED statement FAILED - DescribeTable paginates ColumnList and emits NextToken - DbUser is echoed on the SecretArn path - the statement store no longer builds its sweeper executor in the test constructor * fix(redshift-data): address PR #3186 review findings - SQL scanner handles PostgreSQL escape strings (E'...'): a backslash-escaped quote no longer ends the literal and mis-detects a following :name as a bind marker; plain '...' literals still treat backslash as an ordinary character - ListStatements clamps MaxResults to 1..100 so MaxResults=0 no longer emits the same NextToken forever - DescribeTable matches Table / Schema exactly (=) instead of LIKE, so a name containing _ or % cannot merge other tables' columns into ColumnList - register the service in the README category table - drop a stray em dash from the neighbouring services.yaml comment * fix(redshift-data): bind string parameters untyped so real PostgreSQL infers the column type CI ran the integration test against a real Redshift (PostgreSQL 15) cluster and parameterisedStatement failed: a string bound to an int column via setString raised "operator does not exist: integer = character varying". H2 in PostgreSQL mode coerces it, so the unit test missed it. - RedshiftDataConnectionFactory adds stringtype=unspecified to the JDBC URL, so setString sends the value untyped and the server infers the target type, matching how AWS binds Redshift Data API parameters - ListStatements now rejects MaxResults above 100 with ValidationException instead of silently clamping (PR #3186 re-review) - RedshiftDataOperationsTest uses JBoss Logging, not java.util.logging (PR #3186 re-review) * fix(redshift-data): back the statement store with StorageFactory The store held a bare ConcurrentHashMap outside the configured storage and lifecycle model. It now obtains an account-aware backend through StorageFactory ("redshift-data", statements.json), the same as Athena's query store, resolved to the global storage mode via the catalog descriptor. Default mode stays memory, so statements are still lost on restart as documented; the 24h TTL sweep now walks every account partition and deletes per account since the sweep thread has no request context. StoredStatement is annotated for reflection and field-visible serialization so persistent modes round-trip it. * test(redshift-data): cover StoredStatement serialization round-trip and values() The StorageFactory-backed store serializes StoredStatement in persistent modes. Adds a round-trip test through the exact mapper PersistentStorage builds, covering the ArrayNode, enum, Instant, and nested sub-statement fields plus the field-visibility annotation, and a values() test. * fix(redshift-data): register the nested Status enum for reflection PersistedModelReflectionTest walks every type reachable from a StorageFactory persistence root; StoredStatement.status pointed at an unregistered enum, so native-image deserialization of a persisted statement would fail on restart. |