jerryshao commented on code in PR #14954:
URL: https://github.com/apache/gravitino/pull/14954#discussion_r4560246455
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -323,6 +324,209 @@ public void rollbackSecrets(List<SecretMaterial>
secretMaterials) {
deleteSecrets(urns);
}
+ /**
+ * Makes the versions an alter wrote current and deletes the versions it
replaced.
+ *
+ * <p>Call only after the entity alter committed. Failures are logged and do
not fail the
+ * committed alter. If making a written version current fails and the
provider then reports it as
+ * current, the previous version is deleted; otherwise the written version
is deleted. If the
+ * current version cannot be looked up, both versions are kept. Running the
same change again
+ * writes and promotes a new version.
+ *
+ * @param prepared secrets prepared by a {@code
SecretAlterChanges.prepare*Changes} method
+ */
+ public void commitSecrets(PreparedSecrets prepared) {
+ Preconditions.checkArgument(prepared != null, "prepared must not be null");
+ for (PreparedSecrets.WrittenVersion written : prepared.written()) {
+ // Without a previous version the write already made the new version
current.
+ if (written.previousId() == null) {
+ continue;
+ }
+ SecretUrn urn = written.version().urn();
+ SecretProvider provider = null;
+ try {
+ provider = registry.getProvider(urn.providerName());
+ provider.promoteSecretVersion(urn, written.version().id());
Review Comment:
If promote fails after the entity alter committed, the failure is only
logged and the new version is deleted, so the entity silently keeps the old
value while the caller sees success. Is that intended, or should it surface a
warning or error to the caller?
--
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]