You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "lasdf1234 (via GitHub)" <gi...@apache.org> on 2026/08/11 10:28:25 UTC
[PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
lasdf1234 opened a new pull request, #12420:
URL: https://github.com/apache/gravitino/pull/12420
### What changes were proposed in this pull request?
Follow-up to #12366 (fileset create-time secrets). Adds create-time
`secretBindings` / `secretReferences` for **catalog** and **schema**:
- API / REST / Java & Python clients / OpenAPI
- Create path: `assembleSecretMaterials` → `writeSecrets`; failure rollback via `rollbackSecrets`; drop cleanup via `deleteSecretsFromProperties`
- `testConnection` rejects raw secret URNs via `checkSecretKeys`
- Hook owner-failure compensation; `listCatalogsInfo` authorize-before-resolve
### Why are the changes needed?
Fix: #12297
Create-time secret bindings/references were added for fileset in #12366;
catalog and schema need the same create-path support.
### Does this PR introduce _any_ user-facing change?
- Yes: catalog/schema create APIs accept optional `secretBindings` /
`secretReferences` (same model as fileset).
### How was this patch tested?
- Unit tests for catalog/schema create secret paths
- `:core:compileJava` after rebasing onto `main` post-#12366
Made with [Cursor](https://cursor.com)
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3766768205
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -103,82 +109,108 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
@Override
public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(ident, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ @Override
+ public Schema createSchema(
+ NameIdentifier ident,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties =
+ SecretPropertyUtils.copyEntityProperties(properties, secretBindings, secretReferences);
+ List<SecretMaterial> secretMaterials =
+ secretManager.assembleSecretMaterials(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.schemaPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.schemaPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(secretMaterials);
// Add StringIdentifier to the properties, the specific catalog will handle this
// StringIdentifier to make sure only when the operation is successful, the related
// SchemaEntity will be visible.
+ //
+ // Same split as CatalogManager: create/storage properties keep secret URNs. Connectors that
+ // need plaintext for runtime (e.g. Fileset FS) resolve at the conf boundary — see
+ // FilesetCatalogOperations.mergeUpLevelConfigurations / CatalogManager.createBaseCatalog.
StringIdentifier stringId = StringIdentifier.fromId(uid);
Map<String, String> updatedProperties =
- StringIdentifier.newPropertiesWithId(stringId, properties);
-
- return TreeLockUtils.doWithTreeLock(
- catalogIdent,
- LockType.WRITE,
- () -> {
- // we do not retrieve the schema again (to obtain some values generated by underlying
- // catalog)
- // since some catalogs' API is async and the schema may not be created immediately
- Schema schema =
- doWithCatalog(
- catalogIdent,
- c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
- NoSuchCatalogException.class,
- SchemaAlreadyExistsException.class);
+ StringIdentifier.newPropertiesWithId(stringId, entityProperties);
- // If the Schema is maintained by the Gravitino's store, we don't have to store again.
- boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
- if (isManagedSchema) {
- return EntityCombinedSchema.of(schema)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- }
+ try {
+ return TreeLockUtils.doWithTreeLock(
+ catalogIdent,
+ LockType.WRITE,
+ () -> {
+ // we do not retrieve the schema again (to obtain some values generated by underlying
+ // catalog)
+ // since some catalogs' API is async and the schema may not be created immediately
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
+ NoSuchCatalogException.class,
+ SchemaAlreadyExistsException.class);
+
+ // If the Schema is maintained by the Gravitino's store, we don't have to store again.
+ boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
+ if (isManagedSchema) {
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- SchemaEntity schemaEntity =
- SchemaEntity.builder()
- .withId(uid)
- .withName(ident.name())
- .withNamespace(ident.namespace())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
+ SchemaEntity schemaEntity =
+ SchemaEntity.builder()
+ .withId(uid)
+ .withName(ident.name())
+ .withNamespace(ident.namespace())
+ .withAuditInfo(
+ AuditInfo.builder()
+ .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
+ .withCreateTime(Instant.now())
+ .build())
+ .build();
Review Comment:
Schema properties are not stored in Gravitino's entity store at all; their only source is the underlying catalog. Will they be lost for catalogs that don't support them?
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -975,9 +1008,12 @@ public boolean dropCatalog(NameIdentifier ident, boolean force)
// Finally, delete the catalog entity as well as all its sub-entities from the store.
// Invalidate after store.delete() to prevent a background thread from repopulating
// the cache with stale data between invalidate and delete.
+ Map<String, String> catalogProperties =
+ catalogWrapper.catalog().entity().getProperties();
boolean deleted = store.delete(ident, EntityType.CATALOG, true);
Review Comment:
Cascade deletion does not clean up the secrets of child entities at all.
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -331,6 +363,21 @@ public boolean dropSchema(NameIdentifier ident, boolean cascade) throws NonEmpty
catalogIdent,
LockType.WRITE,
() -> {
+ // Capture persisted properties (including write-through secret URNs) before drop so we
+ // can clean provider material after a successful delete. External-ref URNs are skipped by
+ // deleteSecretsFromProperties.
+ Map<String, String> schemaProperties = null;
+ try {
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.loadSchema(ident)),
+ NoSuchSchemaException.class);
+ schemaProperties = schema.properties();
Review Comment:
If load throws any other exception, the drop operation will fail.
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -103,82 +109,108 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
@Override
public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(ident, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ @Override
+ public Schema createSchema(
+ NameIdentifier ident,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties =
+ SecretPropertyUtils.copyEntityProperties(properties, secretBindings, secretReferences);
+ List<SecretMaterial> secretMaterials =
+ secretManager.assembleSecretMaterials(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.schemaPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.schemaPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(secretMaterials);
// Add StringIdentifier to the properties, the specific catalog will handle this
// StringIdentifier to make sure only when the operation is successful, the related
// SchemaEntity will be visible.
+ //
+ // Same split as CatalogManager: create/storage properties keep secret URNs. Connectors that
+ // need plaintext for runtime (e.g. Fileset FS) resolve at the conf boundary — see
+ // FilesetCatalogOperations.mergeUpLevelConfigurations / CatalogManager.createBaseCatalog.
StringIdentifier stringId = StringIdentifier.fromId(uid);
Map<String, String> updatedProperties =
- StringIdentifier.newPropertiesWithId(stringId, properties);
-
- return TreeLockUtils.doWithTreeLock(
- catalogIdent,
- LockType.WRITE,
- () -> {
- // we do not retrieve the schema again (to obtain some values generated by underlying
- // catalog)
- // since some catalogs' API is async and the schema may not be created immediately
- Schema schema =
- doWithCatalog(
- catalogIdent,
- c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
- NoSuchCatalogException.class,
- SchemaAlreadyExistsException.class);
+ StringIdentifier.newPropertiesWithId(stringId, entityProperties);
- // If the Schema is maintained by the Gravitino's store, we don't have to store again.
- boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
- if (isManagedSchema) {
- return EntityCombinedSchema.of(schema)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- }
+ try {
+ return TreeLockUtils.doWithTreeLock(
+ catalogIdent,
+ LockType.WRITE,
+ () -> {
+ // we do not retrieve the schema again (to obtain some values generated by underlying
+ // catalog)
+ // since some catalogs' API is async and the schema may not be created immediately
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
+ NoSuchCatalogException.class,
+ SchemaAlreadyExistsException.class);
+
+ // If the Schema is maintained by the Gravitino's store, we don't have to store again.
+ boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
+ if (isManagedSchema) {
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- SchemaEntity schemaEntity =
- SchemaEntity.builder()
- .withId(uid)
- .withName(ident.name())
- .withNamespace(ident.namespace())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
+ SchemaEntity schemaEntity =
+ SchemaEntity.builder()
+ .withId(uid)
+ .withName(ident.name())
+ .withNamespace(ident.namespace())
+ .withAuditInfo(
+ AuditInfo.builder()
+ .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
+ .withCreateTime(Instant.now())
+ .build())
+ .build();
+
+ try {
+ store.put(schemaEntity, true /* overwrite */);
+ } catch (Exception e) {
+ LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "put", ident, e);
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- try {
- store.put(schemaEntity, true /* overwrite */);
- } catch (Exception e) {
- LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "put", ident, e);
- return EntityCombinedSchema.of(schema)
+ // Merge both the metadata from catalog operation and the metadata from entity store.
+ return EntityCombinedSchema.of(schema, schemaEntity)
.withHiddenProperties(
getHiddenPropertyNames(
catalogIdent,
HasPropertyMetadata::schemaPropertiesMetadata,
schema.properties()));
- }
-
- // Merge both the metadata from catalog operation and the metadata from entity store.
- return EntityCombinedSchema.of(schema, schemaEntity)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- });
+ });
+ } catch (RuntimeException e) {
+ secretManager.rollbackSecrets(secretMaterials);
Review Comment:
Will this delete a secret that is currently referenced by an existing schema?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3794663113
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaDispatcher.java:
##########
@@ -19,12 +19,68 @@
package org.apache.gravitino.catalog;
+import java.util.Collections;
+import java.util.Map;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Schema;
import org.apache.gravitino.connector.SupportsSchemas;
+import org.apache.gravitino.exceptions.NoSuchCatalogException;
+import org.apache.gravitino.exceptions.SchemaAlreadyExistsException;
+import org.apache.gravitino.secret.SecretBinding;
+import org.apache.gravitino.secret.SecretReference;
/**
* {@code SchemaDispatcher} interface acts as a specialization of the {@link SupportsSchemas}
* interface. This interface is designed to potentially add custom behaviors or operations related
* to dispatching or handling schema-related events or actions that are not covered by the standard
* {@code SupportsSchemas} operations.
*/
-public interface SchemaDispatcher extends SupportsSchemas {}
+public interface SchemaDispatcher extends SupportsSchemas {
Review Comment:
The added methods seems unused. Could u remove them?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3782046518
##########
api/src/main/java/org/apache/gravitino/SupportsCatalogs.java:
##########
@@ -84,22 +87,66 @@ default boolean catalogExists(String catalogName) {
* the created catalog is the managed catalog, like model, fileset catalog. For the details of the
* provider definition, see {@link CatalogProvider}.
*
- * @param catalogName the name of the catalog.
- * @param type the type of the catalog.
- * @param provider the provider of the catalog, or null if the catalog is a managed catalog.
- * @param comment the comment of the catalog.
- * @param properties the properties of the catalog.
- * @return The created catalog.
- * @throws NoSuchMetalakeException If the metalake does not exist.
- * @throws CatalogAlreadyExistsException If the catalog already exists.
+ * <p>Delegates to {@link #createCatalog(String, Catalog.Type, String, String, Map, Map, Map)}
+ * with empty secret maps.
+ *
+ * @param catalogName the name of the catalog
+ * @param type the type of the catalog
+ * @param provider the provider of the catalog, or null if the catalog is a managed catalog
+ * @param comment the comment of the catalog
+ * @param properties the properties of the catalog
+ * @return the created catalog
+ * @throws NoSuchMetalakeException if the metalake does not exist
+ * @throws CatalogAlreadyExistsException if the catalog already exists
*/
- Catalog createCatalog(
+ default Catalog createCatalog(
String catalogName,
Catalog.Type type,
String provider,
String comment,
Map<String, String> properties)
- throws NoSuchMetalakeException, CatalogAlreadyExistsException;
+ throws NoSuchMetalakeException, CatalogAlreadyExistsException {
+ return createCatalog(
+ catalogName,
+ type,
+ provider,
+ comment,
+ properties,
+ Collections.emptyMap(),
+ Collections.emptyMap());
+ }
+
+ /**
+ * Create a catalog with optional secret maps.
+ *
+ * <p>The default implementation rejects create-time secrets. Implementations that support secrets
+ * must override this method.
+ *
+ * @param catalogName the name of the catalog
+ * @param type the type of the catalog
+ * @param provider the provider of the catalog, or null if managed
+ * @param comment the comment of the catalog
+ * @param properties the properties of the catalog
+ * @param secretBindings optional property key → binding ({@code provider} + {@code plaintext})
+ * for write-through
+ * @param secretReferences optional property key → secret locator ({@code provider} plus
+ * provider-specific attributes)
+ * @return the created catalog
+ * @throws NoSuchMetalakeException if the metalake does not exist
+ * @throws CatalogAlreadyExistsException if the catalog already exists
+ * @throws UnsupportedOperationException if create-time secrets are not supported
+ */
+ default Catalog createCatalog(
+ String catalogName,
+ Catalog.Type type,
+ String provider,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchMetalakeException, CatalogAlreadyExistsException {
+ throw new UnsupportedOperationException("Not implemented");
Review Comment:
Got. Use 'Creating xxx with secrets is not supported' instead.(Consistent with the original code of the project)
##########
api/src/main/java/org/apache/gravitino/SupportsSchemas.java:
##########
@@ -93,15 +96,48 @@ default boolean schemaExists(String schemaName) {
* need the schema with default values applied, use the {@link #loadSchema(String)} method after
* creation.
*
+ * <p>Delegates to {@link #createSchema(String, String, Map, Map, Map)} with empty secret maps.
+ *
+ * @param schemaName The name of the schema.
+ * @param comment The comment of the schema.
+ * @param properties The properties of the schema.
+ * @return The schema as defined by the caller, without all default values.
+ * @throws NoSuchCatalogException If the catalog does not exist.
+ * @throws SchemaAlreadyExistsException If the schema already exists.
+ */
+ default Schema createSchema(String schemaName, String comment, Map<String, String> properties)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(
+ schemaName, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ /**
+ * Creates a schema with optional secret maps.
+ *
+ * <p>The default implementation rejects create-time secrets. Implementations that support secrets
+ * must override this method.
+ *
* @param schemaName The name of the schema.
* @param comment The comment of the schema.
* @param properties The properties of the schema.
+ * @param secretBindings optional property key → binding ({@code provider} + {@code plaintext})
+ * for write-through
+ * @param secretReferences optional property key → secret locator ({@code provider} plus
+ * provider-specific attributes)
* @return The schema as defined by the caller, without all default values.
* @throws NoSuchCatalogException If the catalog does not exist.
* @throws SchemaAlreadyExistsException If the schema already exists.
+ * @throws UnsupportedOperationException if create-time secrets are not supported
*/
- Schema createSchema(String schemaName, String comment, Map<String, String> properties)
- throws NoSuchCatalogException, SchemaAlreadyExistsException;
+ default Schema createSchema(
Review Comment:
Got. Use 'Creating xxx with secrets is not supported' instead.(Consistent with the original code of the project)
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#issuecomment-5267467605
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|68.59% **`+0.41%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|82.78%|:green_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|49.23% **`-0.2%`**|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|aws|42.04%|:green_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|9.92%|:red_circle:|
|catalog-fileset|79.77%|:green_circle:|
|catalog-glue|68.95%|:green_circle:|
|catalog-hive|79.4%|:green_circle:|
|catalog-jdbc-common|45.7%|:green_circle:|
|catalog-jdbc-doris|81.8%|:green_circle:|
|catalog-jdbc-mysql|79.33%|:green_circle:|
|catalog-jdbc-postgresql|83.39%|:green_circle:|
|catalog-jdbc-starrocks|79.16%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|59.18%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.86%|:green_circle:|
|catalog-lakehouse-paimon|84.23%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.48%|:green_circle:|
|client-java|78.49% **`+3.5%`**|:green_circle:|
|common|52.75% **`-0.05%`**|:green_circle:|
|core|83.44% **`-0.28%`**|:green_circle:|
|filesystem-hadoop3|77.28%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|48.68%|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-auth|68.0%|:green_circle:|
|hadoop-common|12.7%|:red_circle:|
|hive-metastore-common|53.4%|:green_circle:|
|iceberg-aliyun-bundle|0.0%|:red_circle:|
|iceberg-common|64.75%|:green_circle:|
|iceberg-rest-server|75.03%|:green_circle:|
|idp-basic|86.02%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|62.92%|:green_circle:|
|lance-common|31.75%|:red_circle:|
|lance-rest-server|63.47%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|83.24%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|87.31% **`+0.77%`**|:green_circle:|
|server-common|79.34%|:green_circle:|
|spark|28.57%|:red_circle:|
|spark-common|45.89%|:green_circle:|
|tencent|69.84%|:green_circle:|
|trino-connector|40.29%|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|api|[SupportsCatalogs.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/api/src/main/java/org/apache/gravitino/SupportsCatalogs.java)|0.0%|:red_circle:|
||[SupportsSchemas.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/api/src/main/java/org/apache/gravitino/SupportsSchemas.java)|0.0%|:red_circle:|
|client-java|[BaseSchemaCatalog.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/clients/client-java/src/main/java/org/apache/gravitino/client/BaseSchemaCatalog.java)|100.0%|:green_circle:|
||[GravitinoMetalake.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java)|92.39%|:green_circle:|
||[GravitinoClient.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java)|72.29%|:green_circle:|
|common|[CatalogCreateRequest.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/common/src/main/java/org/apache/gravitino/dto/requests/CatalogCreateRequest.java)|76.47%|:green_circle:|
||[SchemaCreateRequest.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/common/src/main/java/org/apache/gravitino/dto/requests/SchemaCreateRequest.java)|0.0%|:red_circle:|
|core|[SchemaNormalizeDispatcher.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/catalog/SchemaNormalizeDispatcher.java)|100.0%|:green_circle:|
||[SecretPropertyUtils.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/secret/SecretPropertyUtils.java)|100.0%|:green_circle:|
||[SchemaEventDispatcher.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/listener/SchemaEventDispatcher.java)|98.21%|:green_circle:|
||[CatalogEventDispatcher.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/listener/CatalogEventDispatcher.java)|97.75%|:green_circle:|
||[FilesetOperationDispatcher.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/catalog/FilesetOperationDispatcher.java)|94.94%|:green_circle:|
||[SchemaHookDispatcher.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/hook/SchemaHookDispatcher.java)|92.31%|:green_circle:|
||[SecretManager.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/secret/SecretManager.java)|88.05%|:green_circle:|
||[SchemaOperationDispatcher.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java)|83.1%|:green_circle:|
||[CatalogManager.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java)|71.71%|:green_circle:|
||[CatalogNormalizeDispatcher.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/catalog/CatalogNormalizeDispatcher.java)|42.42%|:red_circle:|
||[CatalogHookDispatcher.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java)|39.29%|:red_circle:|
||[SupportsCatalogs.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/catalog/SupportsCatalogs.java)|12.5%|:red_circle:|
||[SchemaDispatcher.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/core/src/main/java/org/apache/gravitino/catalog/SchemaDispatcher.java)|0.0%|:red_circle:|
|server|[CatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/server/src/main/java/org/apache/gravitino/server/web/rest/CatalogOperations.java)|100.0%|:green_circle:|
||[SchemaOperations.java](https://github.com/lasdf1234/gravitino/blob/c9da34a7e5036930ec7b945efe2d7cda2831c1c8/server/src/main/java/org/apache/gravitino/server/web/rest/SchemaOperations.java)|100.0%|:green_circle:|
</details>
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3773866013
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -103,82 +109,108 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
@Override
public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(ident, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ @Override
+ public Schema createSchema(
+ NameIdentifier ident,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties =
+ SecretPropertyUtils.copyEntityProperties(properties, secretBindings, secretReferences);
+ List<SecretMaterial> secretMaterials =
+ secretManager.assembleSecretMaterials(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.schemaPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.schemaPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(secretMaterials);
// Add StringIdentifier to the properties, the specific catalog will handle this
// StringIdentifier to make sure only when the operation is successful, the related
// SchemaEntity will be visible.
+ //
+ // Same split as CatalogManager: create/storage properties keep secret URNs. Connectors that
+ // need plaintext for runtime (e.g. Fileset FS) resolve at the conf boundary — see
+ // FilesetCatalogOperations.mergeUpLevelConfigurations / CatalogManager.createBaseCatalog.
StringIdentifier stringId = StringIdentifier.fromId(uid);
Map<String, String> updatedProperties =
- StringIdentifier.newPropertiesWithId(stringId, properties);
-
- return TreeLockUtils.doWithTreeLock(
- catalogIdent,
- LockType.WRITE,
- () -> {
- // we do not retrieve the schema again (to obtain some values generated by underlying
- // catalog)
- // since some catalogs' API is async and the schema may not be created immediately
- Schema schema =
- doWithCatalog(
- catalogIdent,
- c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
- NoSuchCatalogException.class,
- SchemaAlreadyExistsException.class);
+ StringIdentifier.newPropertiesWithId(stringId, entityProperties);
- // If the Schema is maintained by the Gravitino's store, we don't have to store again.
- boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
- if (isManagedSchema) {
- return EntityCombinedSchema.of(schema)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- }
+ try {
+ return TreeLockUtils.doWithTreeLock(
+ catalogIdent,
+ LockType.WRITE,
+ () -> {
+ // we do not retrieve the schema again (to obtain some values generated by underlying
+ // catalog)
+ // since some catalogs' API is async and the schema may not be created immediately
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
+ NoSuchCatalogException.class,
+ SchemaAlreadyExistsException.class);
+
+ // If the Schema is maintained by the Gravitino's store, we don't have to store again.
+ boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
+ if (isManagedSchema) {
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- SchemaEntity schemaEntity =
- SchemaEntity.builder()
- .withId(uid)
- .withName(ident.name())
- .withNamespace(ident.namespace())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
+ SchemaEntity schemaEntity =
+ SchemaEntity.builder()
+ .withId(uid)
+ .withName(ident.name())
+ .withNamespace(ident.namespace())
+ .withAuditInfo(
+ AuditInfo.builder()
+ .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
+ .withCreateTime(Instant.now())
+ .build())
+ .build();
Review Comment:
Got resolved.
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -975,9 +1008,12 @@ public boolean dropCatalog(NameIdentifier ident, boolean force)
// Finally, delete the catalog entity as well as all its sub-entities from the store.
// Invalidate after store.delete() to prevent a background thread from repopulating
// the cache with stale data between invalidate and delete.
+ Map<String, String> catalogProperties =
+ catalogWrapper.catalog().entity().getProperties();
boolean deleted = store.delete(ident, EntityType.CATALOG, true);
Review Comment:
Fixed: before cascading `store.delete` / managed `dropSchema`, we now call `deleteSecretsForSchemaSubtree` for each schema (schema properties + listed fileset entities under that schema). Catalog-level secrets are still cleaned after a successful catalog delete.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3767336081
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -103,82 +109,108 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
@Override
public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(ident, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ @Override
+ public Schema createSchema(
+ NameIdentifier ident,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties =
+ SecretPropertyUtils.copyEntityProperties(properties, secretBindings, secretReferences);
+ List<SecretMaterial> secretMaterials =
+ secretManager.assembleSecretMaterials(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.schemaPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.schemaPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(secretMaterials);
// Add StringIdentifier to the properties, the specific catalog will handle this
// StringIdentifier to make sure only when the operation is successful, the related
// SchemaEntity will be visible.
+ //
+ // Same split as CatalogManager: create/storage properties keep secret URNs. Connectors that
+ // need plaintext for runtime (e.g. Fileset FS) resolve at the conf boundary — see
+ // FilesetCatalogOperations.mergeUpLevelConfigurations / CatalogManager.createBaseCatalog.
StringIdentifier stringId = StringIdentifier.fromId(uid);
Map<String, String> updatedProperties =
- StringIdentifier.newPropertiesWithId(stringId, properties);
-
- return TreeLockUtils.doWithTreeLock(
- catalogIdent,
- LockType.WRITE,
- () -> {
- // we do not retrieve the schema again (to obtain some values generated by underlying
- // catalog)
- // since some catalogs' API is async and the schema may not be created immediately
- Schema schema =
- doWithCatalog(
- catalogIdent,
- c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
- NoSuchCatalogException.class,
- SchemaAlreadyExistsException.class);
+ StringIdentifier.newPropertiesWithId(stringId, entityProperties);
- // If the Schema is maintained by the Gravitino's store, we don't have to store again.
- boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
- if (isManagedSchema) {
- return EntityCombinedSchema.of(schema)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- }
+ try {
+ return TreeLockUtils.doWithTreeLock(
+ catalogIdent,
+ LockType.WRITE,
+ () -> {
+ // we do not retrieve the schema again (to obtain some values generated by underlying
+ // catalog)
+ // since some catalogs' API is async and the schema may not be created immediately
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
+ NoSuchCatalogException.class,
+ SchemaAlreadyExistsException.class);
+
+ // If the Schema is maintained by the Gravitino's store, we don't have to store again.
+ boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
+ if (isManagedSchema) {
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- SchemaEntity schemaEntity =
- SchemaEntity.builder()
- .withId(uid)
- .withName(ident.name())
- .withNamespace(ident.namespace())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
+ SchemaEntity schemaEntity =
+ SchemaEntity.builder()
+ .withId(uid)
+ .withName(ident.name())
+ .withNamespace(ident.namespace())
+ .withAuditInfo(
+ AuditInfo.builder()
+ .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
+ .withCreateTime(Instant.now())
+ .build())
+ .build();
+
+ try {
+ store.put(schemaEntity, true /* overwrite */);
+ } catch (Exception e) {
+ LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "put", ident, e);
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- try {
- store.put(schemaEntity, true /* overwrite */);
- } catch (Exception e) {
- LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "put", ident, e);
- return EntityCombinedSchema.of(schema)
+ // Merge both the metadata from catalog operation and the metadata from entity store.
+ return EntityCombinedSchema.of(schema, schemaEntity)
.withHiddenProperties(
getHiddenPropertyNames(
catalogIdent,
HasPropertyMetadata::schemaPropertiesMetadata,
schema.properties()));
- }
-
- // Merge both the metadata from catalog operation and the metadata from entity store.
- return EntityCombinedSchema.of(schema, schemaEntity)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- });
+ });
+ } catch (RuntimeException e) {
+ secretManager.rollbackSecrets(secretMaterials);
Review Comment:
Fixed: rollback now runs only when catalog `createSchema` did not succeed (`AtomicBoolean`). Write-through URNs are entityId-scoped, so a failed recreate no longer risks deleting secrets still referenced by an existing schema. Added a regression assertion in `testCreateWithSecrets`.
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -975,9 +1008,12 @@ public boolean dropCatalog(NameIdentifier ident, boolean force)
// Finally, delete the catalog entity as well as all its sub-entities from the store.
// Invalidate after store.delete() to prevent a background thread from repopulating
// the cache with stale data between invalidate and delete.
+ Map<String, String> catalogProperties =
+ catalogWrapper.catalog().entity().getProperties();
boolean deleted = store.delete(ident, EntityType.CATALOG, true);
Review Comment:
Fixed: before cascading `store.delete` / managed `dropSchema`, we now call `deleteSecretsForSchemaSubtree` for each schema (schema properties + listed fileset entities under that schema). Catalog-level secrets are still cleaned after a successful catalog delete.
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -103,82 +109,108 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
@Override
public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(ident, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ @Override
+ public Schema createSchema(
+ NameIdentifier ident,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties =
+ SecretPropertyUtils.copyEntityProperties(properties, secretBindings, secretReferences);
+ List<SecretMaterial> secretMaterials =
+ secretManager.assembleSecretMaterials(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.schemaPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.schemaPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(secretMaterials);
// Add StringIdentifier to the properties, the specific catalog will handle this
// StringIdentifier to make sure only when the operation is successful, the related
// SchemaEntity will be visible.
+ //
+ // Same split as CatalogManager: create/storage properties keep secret URNs. Connectors that
+ // need plaintext for runtime (e.g. Fileset FS) resolve at the conf boundary — see
+ // FilesetCatalogOperations.mergeUpLevelConfigurations / CatalogManager.createBaseCatalog.
StringIdentifier stringId = StringIdentifier.fromId(uid);
Map<String, String> updatedProperties =
- StringIdentifier.newPropertiesWithId(stringId, properties);
-
- return TreeLockUtils.doWithTreeLock(
- catalogIdent,
- LockType.WRITE,
- () -> {
- // we do not retrieve the schema again (to obtain some values generated by underlying
- // catalog)
- // since some catalogs' API is async and the schema may not be created immediately
- Schema schema =
- doWithCatalog(
- catalogIdent,
- c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
- NoSuchCatalogException.class,
- SchemaAlreadyExistsException.class);
+ StringIdentifier.newPropertiesWithId(stringId, entityProperties);
- // If the Schema is maintained by the Gravitino's store, we don't have to store again.
- boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
- if (isManagedSchema) {
- return EntityCombinedSchema.of(schema)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- }
+ try {
+ return TreeLockUtils.doWithTreeLock(
+ catalogIdent,
+ LockType.WRITE,
+ () -> {
+ // we do not retrieve the schema again (to obtain some values generated by underlying
+ // catalog)
+ // since some catalogs' API is async and the schema may not be created immediately
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
+ NoSuchCatalogException.class,
+ SchemaAlreadyExistsException.class);
+
+ // If the Schema is maintained by the Gravitino's store, we don't have to store again.
+ boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
+ if (isManagedSchema) {
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- SchemaEntity schemaEntity =
- SchemaEntity.builder()
- .withId(uid)
- .withName(ident.name())
- .withNamespace(ident.namespace())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
+ SchemaEntity schemaEntity =
+ SchemaEntity.builder()
+ .withId(uid)
+ .withName(ident.name())
+ .withNamespace(ident.namespace())
+ .withAuditInfo(
+ AuditInfo.builder()
+ .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
+ .withCreateTime(Instant.now())
+ .build())
+ .build();
Review Comment:
Fixed: unmanaged `SchemaEntity` now persists `updatedProperties` (including secret URNs) via `withProperties`, so URNs are not solely dependent on the underlying catalog retaining schema properties. Import path updated similarly.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3767338128
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -331,6 +363,21 @@ public boolean dropSchema(NameIdentifier ident, boolean cascade) throws NonEmpty
catalogIdent,
LockType.WRITE,
() -> {
+ // Capture persisted properties (including write-through secret URNs) before drop so we
+ // can clean provider material after a successful delete. External-ref URNs are skipped by
+ // deleteSecretsFromProperties.
+ Map<String, String> schemaProperties = null;
+ try {
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.loadSchema(ident)),
+ NoSuchSchemaException.class);
+ schemaProperties = schema.properties();
Review Comment:
Fixed: pre-drop catalog `loadSchema` now catches unexpected exceptions, logs a warning, and continues the drop. Secret cleanup prefers entity-store properties and falls back to catalog props when available.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3781810801
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -331,6 +363,21 @@ public boolean dropSchema(NameIdentifier ident, boolean cascade) throws NonEmpty
catalogIdent,
LockType.WRITE,
() -> {
+ // Capture persisted properties (including write-through secret URNs) before drop so we
+ // can clean provider material after a successful delete. External-ref URNs are skipped by
+ // deleteSecretsFromProperties.
+ Map<String, String> schemaProperties = null;
+ try {
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.loadSchema(ident)),
+ NoSuchSchemaException.class);
+ schemaProperties = schema.properties();
Review Comment:
schema.properties() is not read properties from entity store, some catalog‘s properties does not contain URN
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -103,82 +109,108 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
@Override
public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(ident, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ @Override
+ public Schema createSchema(
+ NameIdentifier ident,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties =
+ SecretPropertyUtils.copyEntityProperties(properties, secretBindings, secretReferences);
+ List<SecretMaterial> secretMaterials =
+ secretManager.assembleSecretMaterials(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.schemaPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.schemaPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(secretMaterials);
// Add StringIdentifier to the properties, the specific catalog will handle this
// StringIdentifier to make sure only when the operation is successful, the related
// SchemaEntity will be visible.
+ //
+ // Same split as CatalogManager: create/storage properties keep secret URNs. Connectors that
+ // need plaintext for runtime (e.g. Fileset FS) resolve at the conf boundary — see
+ // FilesetCatalogOperations.mergeUpLevelConfigurations / CatalogManager.createBaseCatalog.
StringIdentifier stringId = StringIdentifier.fromId(uid);
Map<String, String> updatedProperties =
- StringIdentifier.newPropertiesWithId(stringId, properties);
-
- return TreeLockUtils.doWithTreeLock(
- catalogIdent,
- LockType.WRITE,
- () -> {
- // we do not retrieve the schema again (to obtain some values generated by underlying
- // catalog)
- // since some catalogs' API is async and the schema may not be created immediately
- Schema schema =
- doWithCatalog(
- catalogIdent,
- c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
- NoSuchCatalogException.class,
- SchemaAlreadyExistsException.class);
+ StringIdentifier.newPropertiesWithId(stringId, entityProperties);
- // If the Schema is maintained by the Gravitino's store, we don't have to store again.
- boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
- if (isManagedSchema) {
- return EntityCombinedSchema.of(schema)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- }
+ try {
+ return TreeLockUtils.doWithTreeLock(
+ catalogIdent,
+ LockType.WRITE,
+ () -> {
+ // we do not retrieve the schema again (to obtain some values generated by underlying
+ // catalog)
+ // since some catalogs' API is async and the schema may not be created immediately
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
+ NoSuchCatalogException.class,
+ SchemaAlreadyExistsException.class);
+
+ // If the Schema is maintained by the Gravitino's store, we don't have to store again.
+ boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
+ if (isManagedSchema) {
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- SchemaEntity schemaEntity =
- SchemaEntity.builder()
- .withId(uid)
- .withName(ident.name())
- .withNamespace(ident.namespace())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
+ SchemaEntity schemaEntity =
+ SchemaEntity.builder()
+ .withId(uid)
+ .withName(ident.name())
+ .withNamespace(ident.namespace())
+ .withAuditInfo(
+ AuditInfo.builder()
+ .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
+ .withCreateTime(Instant.now())
+ .build())
+ .build();
+
+ try {
+ store.put(schemaEntity, true /* overwrite */);
+ } catch (Exception e) {
+ LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "put", ident, e);
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- try {
- store.put(schemaEntity, true /* overwrite */);
- } catch (Exception e) {
- LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "put", ident, e);
- return EntityCombinedSchema.of(schema)
+ // Merge both the metadata from catalog operation and the metadata from entity store.
+ return EntityCombinedSchema.of(schema, schemaEntity)
.withHiddenProperties(
getHiddenPropertyNames(
catalogIdent,
HasPropertyMetadata::schemaPropertiesMetadata,
schema.properties()));
- }
-
- // Merge both the metadata from catalog operation and the metadata from entity store.
- return EntityCombinedSchema.of(schema, schemaEntity)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- });
+ });
+ } catch (RuntimeException e) {
+ secretManager.rollbackSecrets(secretMaterials);
Review Comment:
The concern isn't sharing between schemas but liveness: the catch also covers the code after s.createSchema() has already succeeded (isManagedEntity, getHiddenPropertyNames), so a failure there deletes the secret while the schema still exists in the underlying catalog holding that URN — suggest rolling back only when the schema was not created.
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -992,6 +1049,51 @@ public boolean dropCatalog(NameIdentifier ident, boolean force)
});
}
+ /**
+ * Deletes write-through secrets for a schema and its fileset children using properties snapped
+ * before the entities were dropped. Entity drop must succeed before calling this.
+ */
+ private void deleteSecretsFromPropertySnapshots(
Review Comment:
The logic is duplicate with SchemaOperationDispatcher.java snapshotFilesetProperties and deleteSecretsAfterSchemaDrop
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
Review Comment:
alterSchema will remove the persisted properties.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3794673761
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -327,10 +380,41 @@ public Schema alterSchema(NameIdentifier ident, SchemaChange... changes)
@Override
public boolean dropSchema(NameIdentifier ident, boolean cascade) throws NonEmptySchemaException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+
+ // Cascade: drop filesets via FilesetDispatcher first so each fileset cleans its own
+ // write-through secrets. Do this before the catalog lock to avoid nested TreeLocks.
+ if (cascade) {
Review Comment:
Why do u add this weird logic? Why do we need handle fileset logic here?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3773877021
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -975,9 +1008,12 @@ public boolean dropCatalog(NameIdentifier ident, boolean force)
// Finally, delete the catalog entity as well as all its sub-entities from the store.
// Invalidate after store.delete() to prevent a background thread from repopulating
// the cache with stale data between invalidate and delete.
+ Map<String, String> catalogProperties =
+ catalogWrapper.catalog().entity().getProperties();
boolean deleted = store.delete(ident, EntityType.CATALOG, true);
Review Comment:
Before deleting the catalog/schema, first note down the properties (including URNs) of the sub-schemas and filesets. After successfully deleting the entity, call the function "deleteSecretsFromProperties" to remove their write-through secrets.
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -331,6 +363,21 @@ public boolean dropSchema(NameIdentifier ident, boolean cascade) throws NonEmpty
catalogIdent,
LockType.WRITE,
() -> {
+ // Capture persisted properties (including write-through secret URNs) before drop so we
+ // can clean provider material after a successful delete. External-ref URNs are skipped by
+ // deleteSecretsFromProperties.
+ Map<String, String> schemaProperties = null;
+ try {
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.loadSchema(ident)),
+ NoSuchSchemaException.class);
+ schemaProperties = schema.properties();
Review Comment:
Fixed: pre-drop catalog `loadSchema` now catches unexpected exceptions, logs a warning, and continues the drop. Secret cleanup prefers entity-store properties and falls back to catalog props when available.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3795272390
##########
core/src/main/java/org/apache/gravitino/catalog/SupportsCatalogs.java:
##########
@@ -97,13 +103,48 @@ default boolean catalogExists(NameIdentifier ident) {
* @throws NoSuchMetalakeException If the metalake does not exist.
* @throws CatalogAlreadyExistsException If the catalog already exists.
*/
- Catalog createCatalog(
+ default Catalog createCatalog(
Review Comment:
Got resolved.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 merged PR #12420:
URL: https://github.com/apache/gravitino/pull/12420
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3767406117
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -103,82 +109,108 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
@Override
public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(ident, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ @Override
+ public Schema createSchema(
+ NameIdentifier ident,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties =
+ SecretPropertyUtils.copyEntityProperties(properties, secretBindings, secretReferences);
+ List<SecretMaterial> secretMaterials =
+ secretManager.assembleSecretMaterials(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.schemaPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.schemaPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(secretMaterials);
// Add StringIdentifier to the properties, the specific catalog will handle this
// StringIdentifier to make sure only when the operation is successful, the related
// SchemaEntity will be visible.
+ //
+ // Same split as CatalogManager: create/storage properties keep secret URNs. Connectors that
+ // need plaintext for runtime (e.g. Fileset FS) resolve at the conf boundary — see
+ // FilesetCatalogOperations.mergeUpLevelConfigurations / CatalogManager.createBaseCatalog.
StringIdentifier stringId = StringIdentifier.fromId(uid);
Map<String, String> updatedProperties =
- StringIdentifier.newPropertiesWithId(stringId, properties);
-
- return TreeLockUtils.doWithTreeLock(
- catalogIdent,
- LockType.WRITE,
- () -> {
- // we do not retrieve the schema again (to obtain some values generated by underlying
- // catalog)
- // since some catalogs' API is async and the schema may not be created immediately
- Schema schema =
- doWithCatalog(
- catalogIdent,
- c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
- NoSuchCatalogException.class,
- SchemaAlreadyExistsException.class);
+ StringIdentifier.newPropertiesWithId(stringId, entityProperties);
- // If the Schema is maintained by the Gravitino's store, we don't have to store again.
- boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
- if (isManagedSchema) {
- return EntityCombinedSchema.of(schema)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- }
+ try {
+ return TreeLockUtils.doWithTreeLock(
+ catalogIdent,
+ LockType.WRITE,
+ () -> {
+ // we do not retrieve the schema again (to obtain some values generated by underlying
+ // catalog)
+ // since some catalogs' API is async and the schema may not be created immediately
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
+ NoSuchCatalogException.class,
+ SchemaAlreadyExistsException.class);
+
+ // If the Schema is maintained by the Gravitino's store, we don't have to store again.
+ boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
+ if (isManagedSchema) {
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- SchemaEntity schemaEntity =
- SchemaEntity.builder()
- .withId(uid)
- .withName(ident.name())
- .withNamespace(ident.namespace())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
+ SchemaEntity schemaEntity =
+ SchemaEntity.builder()
+ .withId(uid)
+ .withName(ident.name())
+ .withNamespace(ident.namespace())
+ .withAuditInfo(
+ AuditInfo.builder()
+ .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
+ .withCreateTime(Instant.now())
+ .build())
+ .build();
+
+ try {
+ store.put(schemaEntity, true /* overwrite */);
+ } catch (Exception e) {
+ LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "put", ident, e);
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- try {
- store.put(schemaEntity, true /* overwrite */);
- } catch (Exception e) {
- LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "put", ident, e);
- return EntityCombinedSchema.of(schema)
+ // Merge both the metadata from catalog operation and the metadata from entity store.
+ return EntityCombinedSchema.of(schema, schemaEntity)
.withHiddenProperties(
getHiddenPropertyNames(
catalogIdent,
HasPropertyMetadata::schemaPropertiesMetadata,
schema.properties()));
- }
-
- // Merge both the metadata from catalog operation and the metadata from entity store.
- return EntityCombinedSchema.of(schema, schemaEntity)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- });
+ });
+ } catch (RuntimeException e) {
+ secretManager.rollbackSecrets(secretMaterials);
Review Comment:
Each schema's secret is exclusively owned by that schema and there is no sharing involved, so this issue does not exist.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3794679502
##########
core/src/main/java/org/apache/gravitino/catalog/SupportsCatalogs.java:
##########
@@ -97,13 +103,48 @@ default boolean catalogExists(NameIdentifier ident) {
* @throws NoSuchMetalakeException If the metalake does not exist.
* @throws CatalogAlreadyExistsException If the catalog already exists.
*/
- Catalog createCatalog(
+ default Catalog createCatalog(
Review Comment:
Why do we make this default method?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3782519590
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
Review Comment:
Thank you very much for your review. I chage my code and now alter also has properties.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3782048769
##########
clients/client-java/src/main/java/org/apache/gravitino/client/BaseSchemaCatalog.java:
##########
@@ -167,20 +171,35 @@ public String[] listSchemas(String parentSchema)
}
/**
- * Create a new schema with specified identifier, comment and metadata.
+ * Create a new schema with specified identifier, comment, properties, and optional secret maps.
*
* @param schemaName The name identifier of the schema.
* @param comment The comment of the schema.
* @param properties The properties of the schema.
+ * @param secretBindings Optional property key → binding ({@code provider} + {@code plaintext})
+ * for write-through.
+ * @param secretReferences Optional property key → secret locator ({@code provider} plus
+ * provider-specific attributes).
* @return The created {@link Schema}.
* @throws NoSuchCatalogException if the catalog with specified namespace does not exist.
* @throws SchemaAlreadyExistsException if the schema with specified identifier already exists.
*/
@Override
- public Schema createSchema(String schemaName, String comment, Map<String, String> properties)
Review Comment:
Thank you for your review. This issue has been fixed.
##########
clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java:
##########
@@ -137,9 +139,13 @@ public Catalog createCatalog(
Catalog.Type type,
String provider,
String comment,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchMetalakeException, CatalogAlreadyExistsException {
- return getMetalake().createCatalog(catalogName, type, provider, comment, properties);
+ return getMetalake()
Review Comment:
Thank you for your review. This issue has been fixed.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3795274747
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaDispatcher.java:
##########
@@ -19,12 +19,68 @@
package org.apache.gravitino.catalog;
+import java.util.Collections;
+import java.util.Map;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Schema;
import org.apache.gravitino.connector.SupportsSchemas;
+import org.apache.gravitino.exceptions.NoSuchCatalogException;
+import org.apache.gravitino.exceptions.SchemaAlreadyExistsException;
+import org.apache.gravitino.secret.SecretBinding;
+import org.apache.gravitino.secret.SecretReference;
/**
* {@code SchemaDispatcher} interface acts as a specialization of the {@link SupportsSchemas}
* interface. This interface is designed to potentially add custom behaviors or operations related
* to dispatching or handling schema-related events or actions that are not covered by the standard
* {@code SupportsSchemas} operations.
*/
-public interface SchemaDispatcher extends SupportsSchemas {}
+public interface SchemaDispatcher extends SupportsSchemas {
Review Comment:
Yes. Modify these two 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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3795277059
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -327,10 +380,41 @@ public Schema alterSchema(NameIdentifier ident, SchemaChange... changes)
@Override
public boolean dropSchema(NameIdentifier ident, boolean cascade) throws NonEmptySchemaException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+
+ // Cascade: drop filesets via FilesetDispatcher first so each fileset cleans its own
+ // write-through secrets. Do this before the catalog lock to avoid nested TreeLocks.
+ if (cascade) {
Review Comment:
Fileset is concept under schema.So it's need to list and remove.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3767337554
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -103,82 +109,108 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
@Override
public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(ident, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ @Override
+ public Schema createSchema(
+ NameIdentifier ident,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties =
+ SecretPropertyUtils.copyEntityProperties(properties, secretBindings, secretReferences);
+ List<SecretMaterial> secretMaterials =
+ secretManager.assembleSecretMaterials(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.schemaPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.schemaPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(secretMaterials);
// Add StringIdentifier to the properties, the specific catalog will handle this
// StringIdentifier to make sure only when the operation is successful, the related
// SchemaEntity will be visible.
+ //
+ // Same split as CatalogManager: create/storage properties keep secret URNs. Connectors that
+ // need plaintext for runtime (e.g. Fileset FS) resolve at the conf boundary — see
+ // FilesetCatalogOperations.mergeUpLevelConfigurations / CatalogManager.createBaseCatalog.
StringIdentifier stringId = StringIdentifier.fromId(uid);
Map<String, String> updatedProperties =
- StringIdentifier.newPropertiesWithId(stringId, properties);
-
- return TreeLockUtils.doWithTreeLock(
- catalogIdent,
- LockType.WRITE,
- () -> {
- // we do not retrieve the schema again (to obtain some values generated by underlying
- // catalog)
- // since some catalogs' API is async and the schema may not be created immediately
- Schema schema =
- doWithCatalog(
- catalogIdent,
- c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
- NoSuchCatalogException.class,
- SchemaAlreadyExistsException.class);
+ StringIdentifier.newPropertiesWithId(stringId, entityProperties);
- // If the Schema is maintained by the Gravitino's store, we don't have to store again.
- boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
- if (isManagedSchema) {
- return EntityCombinedSchema.of(schema)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- }
+ try {
+ return TreeLockUtils.doWithTreeLock(
+ catalogIdent,
+ LockType.WRITE,
+ () -> {
+ // we do not retrieve the schema again (to obtain some values generated by underlying
+ // catalog)
+ // since some catalogs' API is async and the schema may not be created immediately
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
+ NoSuchCatalogException.class,
+ SchemaAlreadyExistsException.class);
+
+ // If the Schema is maintained by the Gravitino's store, we don't have to store again.
+ boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
+ if (isManagedSchema) {
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- SchemaEntity schemaEntity =
- SchemaEntity.builder()
- .withId(uid)
- .withName(ident.name())
- .withNamespace(ident.namespace())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
+ SchemaEntity schemaEntity =
+ SchemaEntity.builder()
+ .withId(uid)
+ .withName(ident.name())
+ .withNamespace(ident.namespace())
+ .withAuditInfo(
+ AuditInfo.builder()
+ .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
+ .withCreateTime(Instant.now())
+ .build())
+ .build();
Review Comment:
Fixed: unmanaged `SchemaEntity` now persists `updatedProperties` (including secret URNs) via `withProperties`, so URNs are not solely dependent on the underlying catalog retaining schema properties. Import path updated similarly.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3774024392
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -331,6 +363,21 @@ public boolean dropSchema(NameIdentifier ident, boolean cascade) throws NonEmpty
catalogIdent,
LockType.WRITE,
() -> {
+ // Capture persisted properties (including write-through secret URNs) before drop so we
+ // can clean provider material after a successful delete. External-ref URNs are skipped by
+ // deleteSecretsFromProperties.
+ Map<String, String> schemaProperties = null;
+ try {
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.loadSchema(ident)),
+ NoSuchSchemaException.class);
+ schemaProperties = schema.properties();
Review Comment:
Thank you very much for your review. I have added a "catch(Exception)" block to solve this problem.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3767336081
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -103,82 +109,108 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
@Override
public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(ident, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ @Override
+ public Schema createSchema(
+ NameIdentifier ident,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties =
+ SecretPropertyUtils.copyEntityProperties(properties, secretBindings, secretReferences);
+ List<SecretMaterial> secretMaterials =
+ secretManager.assembleSecretMaterials(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.schemaPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.schemaPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(secretMaterials);
// Add StringIdentifier to the properties, the specific catalog will handle this
// StringIdentifier to make sure only when the operation is successful, the related
// SchemaEntity will be visible.
+ //
+ // Same split as CatalogManager: create/storage properties keep secret URNs. Connectors that
+ // need plaintext for runtime (e.g. Fileset FS) resolve at the conf boundary — see
+ // FilesetCatalogOperations.mergeUpLevelConfigurations / CatalogManager.createBaseCatalog.
StringIdentifier stringId = StringIdentifier.fromId(uid);
Map<String, String> updatedProperties =
- StringIdentifier.newPropertiesWithId(stringId, properties);
-
- return TreeLockUtils.doWithTreeLock(
- catalogIdent,
- LockType.WRITE,
- () -> {
- // we do not retrieve the schema again (to obtain some values generated by underlying
- // catalog)
- // since some catalogs' API is async and the schema may not be created immediately
- Schema schema =
- doWithCatalog(
- catalogIdent,
- c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
- NoSuchCatalogException.class,
- SchemaAlreadyExistsException.class);
+ StringIdentifier.newPropertiesWithId(stringId, entityProperties);
- // If the Schema is maintained by the Gravitino's store, we don't have to store again.
- boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
- if (isManagedSchema) {
- return EntityCombinedSchema.of(schema)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- }
+ try {
+ return TreeLockUtils.doWithTreeLock(
+ catalogIdent,
+ LockType.WRITE,
+ () -> {
+ // we do not retrieve the schema again (to obtain some values generated by underlying
+ // catalog)
+ // since some catalogs' API is async and the schema may not be created immediately
+ Schema schema =
+ doWithCatalog(
+ catalogIdent,
+ c -> c.doWithSchemaOps(s -> s.createSchema(ident, comment, updatedProperties)),
+ NoSuchCatalogException.class,
+ SchemaAlreadyExistsException.class);
+
+ // If the Schema is maintained by the Gravitino's store, we don't have to store again.
+ boolean isManagedSchema = isManagedEntity(catalogIdent, Capability.Scope.SCHEMA);
+ if (isManagedSchema) {
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- SchemaEntity schemaEntity =
- SchemaEntity.builder()
- .withId(uid)
- .withName(ident.name())
- .withNamespace(ident.namespace())
- .withAuditInfo(
- AuditInfo.builder()
- .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
- .withCreateTime(Instant.now())
- .build())
- .build();
+ SchemaEntity schemaEntity =
+ SchemaEntity.builder()
+ .withId(uid)
+ .withName(ident.name())
+ .withNamespace(ident.namespace())
+ .withAuditInfo(
+ AuditInfo.builder()
+ .withCreator(PrincipalUtils.getCurrentPrincipal().getName())
+ .withCreateTime(Instant.now())
+ .build())
+ .build();
+
+ try {
+ store.put(schemaEntity, true /* overwrite */);
+ } catch (Exception e) {
+ LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "put", ident, e);
+ return EntityCombinedSchema.of(schema)
+ .withHiddenProperties(
+ getHiddenPropertyNames(
+ catalogIdent,
+ HasPropertyMetadata::schemaPropertiesMetadata,
+ schema.properties()));
+ }
- try {
- store.put(schemaEntity, true /* overwrite */);
- } catch (Exception e) {
- LOG.error(FormattedErrorMessages.STORE_OP_FAILURE, "put", ident, e);
- return EntityCombinedSchema.of(schema)
+ // Merge both the metadata from catalog operation and the metadata from entity store.
+ return EntityCombinedSchema.of(schema, schemaEntity)
.withHiddenProperties(
getHiddenPropertyNames(
catalogIdent,
HasPropertyMetadata::schemaPropertiesMetadata,
schema.properties()));
- }
-
- // Merge both the metadata from catalog operation and the metadata from entity store.
- return EntityCombinedSchema.of(schema, schemaEntity)
- .withHiddenProperties(
- getHiddenPropertyNames(
- catalogIdent,
- HasPropertyMetadata::schemaPropertiesMetadata,
- schema.properties()));
- });
+ });
+ } catch (RuntimeException e) {
+ secretManager.rollbackSecrets(secretMaterials);
Review Comment:
Fixed: rollback now runs only when catalog `createSchema` did not succeed (`AtomicBoolean`). Write-through URNs are entityId-scoped, so a failed recreate no longer risks deleting secrets still referenced by an existing schema. Added a regression assertion in `testCreateWithSecrets`.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3794685263
##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -782,15 +794,6 @@ private void initGravitinoServerComponents() {
new PartitionNormalizeDispatcher(partitionOperationDispatcher, catalogManager);
this.partitionDispatcher = new PartitionEventDispatcher(eventBus, partitionNormalizeDispatcher);
- FilesetOperationDispatcher filesetOperationDispatcher =
Review Comment:
Why do we remove this code?
##########
core/src/main/java/org/apache/gravitino/GravitinoEnv.java:
##########
@@ -782,15 +794,6 @@ private void initGravitinoServerComponents() {
new PartitionNormalizeDispatcher(partitionOperationDispatcher, catalogManager);
this.partitionDispatcher = new PartitionEventDispatcher(eventBus, partitionNormalizeDispatcher);
- FilesetOperationDispatcher filesetOperationDispatcher =
Review Comment:
Why do we remove this code?
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3781558017
##########
api/src/main/java/org/apache/gravitino/SupportsCatalogs.java:
##########
@@ -84,22 +87,66 @@ default boolean catalogExists(String catalogName) {
* the created catalog is the managed catalog, like model, fileset catalog. For the details of the
* provider definition, see {@link CatalogProvider}.
*
- * @param catalogName the name of the catalog.
- * @param type the type of the catalog.
- * @param provider the provider of the catalog, or null if the catalog is a managed catalog.
- * @param comment the comment of the catalog.
- * @param properties the properties of the catalog.
- * @return The created catalog.
- * @throws NoSuchMetalakeException If the metalake does not exist.
- * @throws CatalogAlreadyExistsException If the catalog already exists.
+ * <p>Delegates to {@link #createCatalog(String, Catalog.Type, String, String, Map, Map, Map)}
+ * with empty secret maps.
+ *
+ * @param catalogName the name of the catalog
+ * @param type the type of the catalog
+ * @param provider the provider of the catalog, or null if the catalog is a managed catalog
+ * @param comment the comment of the catalog
+ * @param properties the properties of the catalog
+ * @return the created catalog
+ * @throws NoSuchMetalakeException if the metalake does not exist
+ * @throws CatalogAlreadyExistsException if the catalog already exists
*/
- Catalog createCatalog(
+ default Catalog createCatalog(
String catalogName,
Catalog.Type type,
String provider,
String comment,
Map<String, String> properties)
- throws NoSuchMetalakeException, CatalogAlreadyExistsException;
+ throws NoSuchMetalakeException, CatalogAlreadyExistsException {
+ return createCatalog(
+ catalogName,
+ type,
+ provider,
+ comment,
+ properties,
+ Collections.emptyMap(),
+ Collections.emptyMap());
+ }
+
+ /**
+ * Create a catalog with optional secret maps.
+ *
+ * <p>The default implementation rejects create-time secrets. Implementations that support secrets
+ * must override this method.
+ *
+ * @param catalogName the name of the catalog
+ * @param type the type of the catalog
+ * @param provider the provider of the catalog, or null if managed
+ * @param comment the comment of the catalog
+ * @param properties the properties of the catalog
+ * @param secretBindings optional property key → binding ({@code provider} + {@code plaintext})
+ * for write-through
+ * @param secretReferences optional property key → secret locator ({@code provider} plus
+ * provider-specific attributes)
+ * @return the created catalog
+ * @throws NoSuchMetalakeException if the metalake does not exist
+ * @throws CatalogAlreadyExistsException if the catalog already exists
+ * @throws UnsupportedOperationException if create-time secrets are not supported
+ */
+ default Catalog createCatalog(
+ String catalogName,
+ Catalog.Type type,
+ String provider,
+ String comment,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
+ throws NoSuchMetalakeException, CatalogAlreadyExistsException {
+ throw new UnsupportedOperationException("Not implemented");
Review Comment:
Could u use complete error message here? For example. `xxxx is not implemented`.
##########
clients/client-java/src/main/java/org/apache/gravitino/client/BaseSchemaCatalog.java:
##########
@@ -167,20 +171,35 @@ public String[] listSchemas(String parentSchema)
}
/**
- * Create a new schema with specified identifier, comment and metadata.
+ * Create a new schema with specified identifier, comment, properties, and optional secret maps.
*
* @param schemaName The name identifier of the schema.
* @param comment The comment of the schema.
* @param properties The properties of the schema.
+ * @param secretBindings Optional property key → binding ({@code provider} + {@code plaintext})
+ * for write-through.
+ * @param secretReferences Optional property key → secret locator ({@code provider} plus
+ * provider-specific attributes).
* @return The created {@link Schema}.
* @throws NoSuchCatalogException if the catalog with specified namespace does not exist.
* @throws SchemaAlreadyExistsException if the schema with specified identifier already exists.
*/
@Override
- public Schema createSchema(String schemaName, String comment, Map<String, String> properties)
Review Comment:
Do u modify the method signature? We should keep backwards compatibility.
##########
clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java:
##########
@@ -137,9 +139,13 @@ public Catalog createCatalog(
Catalog.Type type,
String provider,
String comment,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchMetalakeException, CatalogAlreadyExistsException {
- return getMetalake().createCatalog(catalogName, type, provider, comment, properties);
+ return getMetalake()
Review Comment:
ditto.
##########
api/src/main/java/org/apache/gravitino/SupportsSchemas.java:
##########
@@ -93,15 +96,48 @@ default boolean schemaExists(String schemaName) {
* need the schema with default values applied, use the {@link #loadSchema(String)} method after
* creation.
*
+ * <p>Delegates to {@link #createSchema(String, String, Map, Map, Map)} with empty secret maps.
+ *
+ * @param schemaName The name of the schema.
+ * @param comment The comment of the schema.
+ * @param properties The properties of the schema.
+ * @return The schema as defined by the caller, without all default values.
+ * @throws NoSuchCatalogException If the catalog does not exist.
+ * @throws SchemaAlreadyExistsException If the schema already exists.
+ */
+ default Schema createSchema(String schemaName, String comment, Map<String, String> properties)
+ throws NoSuchCatalogException, SchemaAlreadyExistsException {
+ return createSchema(
+ schemaName, comment, properties, Collections.emptyMap(), Collections.emptyMap());
+ }
+
+ /**
+ * Creates a schema with optional secret maps.
+ *
+ * <p>The default implementation rejects create-time secrets. Implementations that support secrets
+ * must override this method.
+ *
* @param schemaName The name of the schema.
* @param comment The comment of the schema.
* @param properties The properties of the schema.
+ * @param secretBindings optional property key → binding ({@code provider} + {@code plaintext})
+ * for write-through
+ * @param secretReferences optional property key → secret locator ({@code provider} plus
+ * provider-specific attributes)
* @return The schema as defined by the caller, without all default values.
* @throws NoSuchCatalogException If the catalog does not exist.
* @throws SchemaAlreadyExistsException If the schema already exists.
+ * @throws UnsupportedOperationException if create-time secrets are not supported
*/
- Schema createSchema(String schemaName, String comment, Map<String, String> properties)
- throws NoSuchCatalogException, SchemaAlreadyExistsException;
+ default Schema createSchema(
Review Comment:
ditto.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3782519590
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
Review Comment:
Thank you very much for your review. Alter also has properties.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#12297] feat(secret): Add catalog and schema create-time secrets [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12420:
URL: https://github.com/apache/gravitino/pull/12420#discussion_r3783555992
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -992,6 +1049,51 @@ public boolean dropCatalog(NameIdentifier ident, boolean force)
});
}
+ /**
+ * Deletes write-through secrets for a schema and its fileset children using properties snapped
+ * before the entities were dropped. Entity drop must succeed before calling this.
+ */
+ private void deleteSecretsFromPropertySnapshots(
Review Comment:
1. The concern isn't sharing between schemas but liveness: the catch also covers the code after s.createSchema() has already succeeded (isManagedEntity, getHiddenPropertyNames), so a failure there deletes the secret while the schema still exists in the underlying catalog holding that URN — suggest rolling back only when the schema was not created.
It has been resolved. The solution is similar to that for the catalog.
2. schema.properties() is not read properties from entity store, some catalog‘s properties does not contain URN
Read properties from SchemaEntity (entity store) before dropping
3. The logic is duplicate with SchemaOperationDispatcher.java snapshotFilesetProperties and deleteSecretsAfterSchemaDrop
This method has been removed.
--
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: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org