LuciferYang opened a new pull request, #14954: URL: https://github.com/apache/gravitino/pull/14954
### What changes were proposed in this pull request? Alters keep the write-through URN fixed and version the secret behind it, as suggested in #14926. - `SecretProvider` gets four version methods (write, promote, delete, current), which `InMemorySecretsProvider` implements. - Prepare applies the whole batch to a copy of the properties. Each key whose final value is a write-through URN of the entity with a new plaintext gets a new version, current only if the URN has none. For each write-through URN the final properties no longer hold, the current version is recorded. - After the entity update commits, each new version is made current and the version it replaced is deleted, as are the recorded versions. A rollback deletes only the new versions. - This covers the catalog, schema and fileset alter paths. For an external schema with a SchemaEntity, the commit runs after its update, and the recorded versions are kept if that update fails. ### Why are the changes needed? A failed alter could leave the entity referencing a deleted secret: remove, switching to a reference and cross-provider rebinds deleted the old secret during prepare, and rolling back a failed `setSecretBinding` rotation deleted the still-referenced URN. A failed `setProperty` rotation kept the new value. Comparing start and final properties also handles a batch that changes one key twice, and deleting by version id keeps a version a later alter wrote to the same URN. Fix: #13439 ### Does this PR introduce _any_ user-facing change? - A failed alter keeps the entity's write-through secret values. - Write-through `SecretProvider` implementations must implement the four version methods; otherwise altering their secrets fails with `UnsupportedOperationException`. The SPI is not in a release yet. - If promoting a new version fails after the commit, the alter still succeeds, the secret keeps the provider's current version, and an error is logged. - With a provider shared across servers, two concurrent rotations of one key can be promoted out of their entity commit order. ### How was this patch tested? - `TestCatalogManager.testFailedCatalogStoreUpdateKeepsSecretValue`, `TestFilesetCatalogOperations.testAlterFilesetSecretSwitchesOnlyAfterCommit`: a store update failing after prepare keeps the old value; rollback deletes a first binding. - `TestSchemaOperationDispatcher`: external schemas whose entity update fails or that have no SchemaEntity. - `FilesetSecretsIT.testAlterSchemaSecretBinding`: rotation and removal on a managed schema. - `TestSecretManagerAlter`: batches touching one key twice, missing material, failed promotes and version writes, and a provider without versions. - `TestInMemorySecretsProvider`: the version methods. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
