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/05 00:51:29 UTC
[PR] [#12297] feat(secret): Support secretBindings/secretReferences on create [gravitino]
lasdf1234 opened a new pull request, #12366:
URL: https://github.com/apache/gravitino/pull/12366
### What changes were proposed in this pull request?
- Add create-time `secretBindings` / `secretReferences` for catalog, schema, and fileset (API, DTOs, OpenAPI, Java/Python clients, REST, dispatchers).
- Introduce `SecretManager` for write-through / external-ref lifecycle (`getSecretBindingUrns`, `getSecretReferenceUrns`, `writeSecrets`, `rollbackWritten`).
- Introduce `SecretPropertyUtils` for request checks, URN recognition, and applying URNs into properties.
- Nest `secretBindings` as `Map<String, Map<String, String>>` with `provider` + `value`, so plaintext is not carried in `properties`.
- On create failure, roll back write-through secrets via `needSecretClean`.
### Why are the changes needed?
Entity create needs a typed way to bind secrets (write-through or external reference) without leaving plaintext in persisted properties. This is part of epic #12297.
Fix: #12297
### Does this PR introduce _any_ user-facing change?
- Yes. Create APIs / REST requests gain optional `secretBindings` and `secretReferences`.
- `secretBindings` shape: property key → `{ "provider": "...", "value": "..." }`.
- Persisted property values for those keys become secret URNs; GET paths continue to hide secret URN properties.
### How was this patch tested?
- Unit tests: `TestSecretManager` and related create/DTO/REST test updates.
- `./gradlew :core:test --tests org.apache.gravitino.secret.TestSecretManager -PskipITs`
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3726900255
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -101,84 +108,119 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
* @throws SchemaAlreadyExistsException If a schema with the same identifier already exists.
*/
@Override
- public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
+ 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();
Review Comment:
Could u extract a common method to let FilesetDispatcher and SchemaOperationDispatcher to reuse?
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3749292100
##########
core/src/main/java/org/apache/gravitino/hook/FilesetHookDispatcher.java:
##########
@@ -75,27 +80,42 @@ public Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
Fileset fileset =
dispatcher.createMultipleLocationFileset(
- ident, comment, type, storageLocations, properties);
+ ident, comment, type, storageLocations, properties, secretBindings, secretReferences);
- // Set the creator as the owner of the fileset.
- OwnerDispatcher ownerManager = GravitinoEnv.getInstance().ownerDispatcher();
- if (ownerManager != null) {
- // The inner NormalizeDispatcher case-folds the fileset name (and its schema namespace)
- // based on catalog capabilities, so the entity is stored under the normalized identifier.
- // Apply the same normalization here so the owner is attached to the same identifier the
- // manager sees.
- NameIdentifier normalizedIdent =
- CapabilityHelpers.applyCapabilities(
- ident, Capability.Scope.FILESET, GravitinoEnv.getInstance().catalogManager());
- ownerManager.setOwner(
- normalizedIdent.namespace().level(0),
- NameIdentifierUtil.toMetadataObject(normalizedIdent, Entity.EntityType.FILESET),
- PrincipalUtils.getCurrentUserName(),
- Owner.Type.USER);
+ try {
+ // Set the creator as the owner of the fileset.
+ OwnerDispatcher ownerManager = GravitinoEnv.getInstance().ownerDispatcher();
+ if (ownerManager != null) {
+ // The inner NormalizeDispatcher case-folds the fileset name (and its schema namespace)
+ // based on catalog capabilities, so the entity is stored under the normalized identifier.
+ // Apply the same normalization here so the owner is attached to the same identifier the
+ // manager sees.
+ NameIdentifier normalizedIdent =
+ CapabilityHelpers.applyCapabilities(
+ ident, Capability.Scope.FILESET, GravitinoEnv.getInstance().catalogManager());
+ ownerManager.setOwner(
+ normalizedIdent.namespace().level(0),
+ NameIdentifierUtil.toMetadataObject(normalizedIdent, Entity.EntityType.FILESET),
+ PrincipalUtils.getCurrentUserName(),
+ Owner.Type.USER);
+ }
+ } catch (Exception postHookException) {
+ LOG.warn(
+ "Failed to execute post hook operations, rolling back fileset " + ident,
+ postHookException);
+ try {
+ dispatcher.dropFileset(ident);
Review Comment:
Because the Post hook failed, all the garbage data needs to be cleaned up as well, which is exactly what @mchades requested.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3754685366
##########
core/src/main/java/org/apache/gravitino/catalog/FilesetOperationDispatcher.java:
##########
@@ -143,45 +148,67 @@ public Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
+ // System entrance: normalize null secret maps to empty so SecretManager.writeSecrets can
+ // require non-null arguments.
+ Map<String, SecretBinding> bindings = secretBindings == null ? Map.of() : secretBindings;
+ Map<String, SecretReference> references =
+ secretReferences == null ? Map.of() : secretReferences;
+
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties = SecretPropertyUtils.copyEntityProperties(properties);
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ properties, entityProperties, "fileset", uid, bindings, references);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.filesetPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.filesetPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(bindings, secretUrns);
Review Comment:
Could do the secret bindings convert to secret urns? It maybe better to use secret uris. The interface will be clearer.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3733024878
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -63,20 +65,86 @@ public SecretProviderRegistry getRegistry() {
return registry;
}
+ /**
+ * Ensures each property key appears at most once across {@code properties}, {@code
+ * secretBindings}, and {@code secretReferences}.
+ *
+ * <p>{@code null} maps are treated as empty.
+ *
+ * @param properties entity properties from the create request (may be null)
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ */
+ public void checkSecretKeys(
+ @Nullable Map<String, String> properties,
+ @Nullable Map<String, SecretBinding> secretBindings,
+ @Nullable Map<String, SecretReference> secretReferences) {
+ Set<String> keys = new HashSet<>();
+ int count = 0;
+ if (properties != null) {
+ keys.addAll(properties.keySet());
+ count += properties.size();
+ }
Review Comment:
Create-time `properties` are never checked for raw secret URNs. A caller can therefore submit another entity's URN as (for example) `jdbc-password`; `createBaseCatalog` later resolves it and gives the plaintext to the connector, bypassing the typed reference path and any ownership validation. Reject matching secret URN values in the request properties before assembling server-generated URNs.
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -699,6 +715,7 @@ public void testConnection(
}
Map<String, String> mergedConfig = buildCatalogConf(provider, properties);
+ Map<String, String> plaintextConfig = secretManager.toPlaintextProperties(mergedConfig);
Review Comment:
`testConnection` receives caller-controlled properties but now resolves any matching Gravitino secret URN. A caller who knows another entity's URN can combine it with an attacker-controlled connection endpoint and cause the connector to send that secret externally. Do not resolve raw URNs on this request path; only resolve URNs loaded from trusted persisted metadata or add an authorized typed-secret flow.
##########
core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java:
##########
@@ -77,9 +79,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 {
- Catalog catalog = dispatcher.createCatalog(ident, type, provider, comment, properties);
+ Catalog catalog =
+ dispatcher.createCatalog(
+ ident, type, provider, comment, properties, secretBindings, secretReferences);
Review Comment:
The delegated create writes the new secrets before returning. If owner or future-grant setup then fails, the catch block drops the catalog, but `dropCatalog` does not delete these write-through secrets, leaving orphaned secret material after a failed create. Include secret rollback in this post-hook rollback path (or make drop clean the catalog's secret URNs).
##########
clients/client-python/gravitino/api/secret.py:
##########
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from dataclasses import dataclass, field
+from typing import Dict
+
+
+@dataclass
+class SecretBinding:
+ """Write-through secret binding: provider instance name plus plaintext."""
+
+ provider: str
+ plaintext: str
+
+ def __repr__(self) -> str:
+ return f"SecretBinding(provider={self.provider!r}, plaintext=***)"
+
+
+@dataclass
+class SecretReference:
+ """External secret locator: provider instance name plus provider-specific attributes."""
+
+ provider: str
+ attributes: Dict[str, str] = field(default_factory=dict)
+
+ def __post_init__(self):
+ if not self.attributes:
+ raise ValueError("attributes must not be null or empty")
Review Comment:
This rejects the documented valid case where `attributes` is omitted or empty. It also conflicts with the field's `default_factory=dict`, so `SecretReference(provider="...")` always raises. Reject only `None` and allow an empty dictionary.
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretBindingDTO.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretBinding;
+
+/** Data transfer object for a write-through {@link SecretBinding}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString(exclude = "plaintext")
+public class SecretBindingDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @JsonProperty("plaintext")
+ private String plaintext;
+
+ /**
+ * Converts this DTO to a {@link SecretBinding}.
+ *
+ * @return the secret binding
+ */
+ public SecretBinding toSecretBinding() {
+ return new SecretBinding(provider, plaintext);
+ }
+
+ /**
+ * Creates a DTO from a {@link SecretBinding}.
+ *
+ * @param binding the secret binding
+ * @return the secret binding DTO
+ */
+ public static SecretBindingDTO fromSecretBinding(SecretBinding binding) {
+ return new SecretBindingDTO(binding.provider(), binding.plaintext());
+ }
+
+ /**
+ * Converts a property-key map of DTOs to {@link SecretBinding}s.
+ *
+ * @param dtos property key → binding DTO; {@code null} or empty returns an empty map
+ * @return property key → binding (never {@code null})
+ */
+ public static Map<String, SecretBinding> toSecretBindings(
+ @Nullable Map<String, SecretBindingDTO> dtos) {
+ if (dtos == null || dtos.isEmpty()) {
+ return ImmutableMap.of();
+ }
+ ImmutableMap.Builder<String, SecretBinding> bindings = ImmutableMap.builder();
+ for (Map.Entry<String, SecretBindingDTO> entry : dtos.entrySet()) {
+ bindings.put(entry.getKey(), entry.getValue().toSecretBinding());
+ }
Review Comment:
A JSON map entry such as `"secretBindings": {"password": null}` is dereferenced here and throws `NullPointerException`, which the REST handlers treat as an internal error rather than a bad request. Validate null DTO values and throw `IllegalArgumentException` with the offending key.
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretReferenceDTO.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretReference;
+
+/** Data transfer object for an external {@link SecretReference}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString
+public class SecretReferenceDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @Builder.Default
+ @JsonProperty("attributes")
+ private Map<String, String> attributes = ImmutableMap.of();
+
+ /**
+ * Converts this DTO to a {@link SecretReference}.
+ *
+ * @return the secret reference
+ */
+ public SecretReference toSecretReference() {
+ Map<String, String> attrs = attributes == null ? ImmutableMap.of() : attributes;
+ return new SecretReference(provider, attrs);
Review Comment:
Omitted or empty `attributes` are normalized to an empty map here, but `SecretReference` currently rejects empty maps. Consequently the REST shape advertised by this PR fails during conversion whenever `attributes` is omitted or `{}`. Update the API model to accept a non-null empty map and adjust its tests/Javadoc accordingly.
##########
docs/open-api/filesets.yaml:
##########
@@ -346,6 +346,22 @@ components:
default: {}
additionalProperties:
type: string
+ secretBindings:
+ type: object
+ description: >
+ Optional map of property key to write-through binding. Persisted value
+ becomes a URN.
+ nullable: true
+ additionalProperties:
+ $ref: "./secrets.yaml#/components/schemas/SecretBinding"
Review Comment:
The fileset REST contract is documented here, but the Python `FilesetCreateRequest`, `create_fileset`, and `create_multiple_location_fileset` paths were not extended with these fields, unlike the catalog and schema paths. Thus the PR's stated Python-client support is incomplete: Python users cannot create filesets with either secret map.
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -101,84 +106,99 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
* @throws SchemaAlreadyExistsException If a schema with the same identifier already exists.
*/
@Override
- public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
+ 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);
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
Review Comment:
There is no schema-operation test for the new secret-aware create path; current schema tests only update mock arity. Add tests that verify URN persistence/hidden output and that a connector create failure invokes rollback, because this rollback boundary differs from the catalog path.
##########
core/src/main/java/org/apache/gravitino/catalog/FilesetOperationDispatcher.java:
##########
@@ -143,45 +148,58 @@ public Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties = SecretPropertyUtils.copyEntityProperties(properties);
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ properties, entityProperties, "fileset", uid, secretBindings, secretReferences);
Review Comment:
The fileset create implementation and rollback path are untested; existing fileset tests only update Mockito argument counts. Add a create test with bindings/references plus a failing connector test to verify URN persistence, hidden output, and rollback.
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -593,12 +596,20 @@ 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 {
NameIdentifier metalakeIdent = NameIdentifier.of(ident.namespace().levels());
- Map<String, String> mergedConfig = buildCatalogConf(provider, properties);
+ final Map<String, String> mergedConfig = new HashMap<>(buildCatalogConf(provider, properties));
long uid = idGenerator.nextId();
+
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ properties, mergedConfig, "catalog", uid, secretBindings, secretReferences);
+ secretManager.writeSecrets(secretBindings, secretUrns);
Review Comment:
No catalog-operation test exercises this new create path: the added secret tests cover `SecretManager` helpers, while existing catalog tests never call `createCatalog` with secret maps. Add coverage that verifies only the URN is persisted, the connector receives plaintext, the response hides the key, and a downstream create failure rolls back the write.
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretReferenceDTO.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretReference;
+
+/** Data transfer object for an external {@link SecretReference}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString
+public class SecretReferenceDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @Builder.Default
+ @JsonProperty("attributes")
+ private Map<String, String> attributes = ImmutableMap.of();
+
+ /**
+ * Converts this DTO to a {@link SecretReference}.
+ *
+ * @return the secret reference
+ */
+ public SecretReference toSecretReference() {
+ Map<String, String> attrs = attributes == null ? ImmutableMap.of() : attributes;
+ return new SecretReference(provider, attrs);
+ }
+
+ /**
+ * Creates a DTO from a {@link SecretReference}.
+ *
+ * @param reference the secret reference
+ * @return the secret reference DTO
+ */
+ public static SecretReferenceDTO fromSecretReference(SecretReference reference) {
+ return new SecretReferenceDTO(reference.provider(), reference.attributes());
+ }
+
+ /**
+ * Converts a property-key map of DTOs to {@link SecretReference}s.
+ *
+ * @param dtos property key → reference DTO; {@code null} or empty returns an empty map
+ * @return property key → reference (never {@code null})
+ */
+ public static Map<String, SecretReference> toSecretReferences(
+ @Nullable Map<String, SecretReferenceDTO> dtos) {
+ if (dtos == null || dtos.isEmpty()) {
+ return ImmutableMap.of();
+ }
+ ImmutableMap.Builder<String, SecretReference> references = ImmutableMap.builder();
+ for (Map.Entry<String, SecretReferenceDTO> entry : dtos.entrySet()) {
+ references.put(entry.getKey(), entry.getValue().toSecretReference());
+ }
Review Comment:
A JSON map entry such as `"secretReferences": {"password": null}` is dereferenced here and throws `NullPointerException`, producing a 500 response for malformed client input. Validate null DTO values and raise `IllegalArgumentException` with the offending key.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734472942
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -63,20 +65,86 @@ public SecretProviderRegistry getRegistry() {
return registry;
}
+ /**
+ * Ensures each property key appears at most once across {@code properties}, {@code
+ * secretBindings}, and {@code secretReferences}.
+ *
+ * <p>{@code null} maps are treated as empty.
+ *
+ * @param properties entity properties from the create request (may be null)
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ */
+ public void checkSecretKeys(
+ @Nullable Map<String, String> properties,
+ @Nullable Map<String, SecretBinding> secretBindings,
+ @Nullable Map<String, SecretReference> secretReferences) {
+ Set<String> keys = new HashSet<>();
+ int count = 0;
+ if (properties != null) {
+ keys.addAll(properties.keySet());
+ count += properties.size();
+ }
Review Comment:
Got this issued 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#issuecomment-5215005205
Split plan: this PR is now **fileset-only** (+ shared SecretManager create helpers). Catalog/schema create-time secrets are on a follow-up branch `feat/entity-secrets-create-catalog-schema` stacked on this one (fork PR: https://github.com/lasdf1234/gravitino/pulls?q=is%3Apr+catalog+schema+secrets — will link once created). External-ref authorization/scoping remains out of scope for both.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3725736344
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretReferenceDTO.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretReference;
+
+/** Data transfer object for an external {@link SecretReference}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString
+public class SecretReferenceDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @Nullable
+ @JsonProperty("attributes")
+ private Map<String, String> attributes;
+
+ /**
+ * Converts this DTO to a {@link SecretReference}.
+ *
+ * @return the secret reference
+ */
+ public SecretReference toSecretReference() {
+ return new SecretReference(provider, attributes == null ? ImmutableMap.of() : attributes);
+ }
+
+ /**
+ * Creates a DTO from a {@link SecretReference}.
+ *
+ * @param reference the secret reference
+ * @return the secret reference DTO
+ */
+ public static SecretReferenceDTO fromSecretReference(SecretReference reference) {
+ return new SecretReferenceDTO(reference.provider(), reference.attributes());
+ }
+
+ /**
+ * Converts a property-key map of DTOs to {@link SecretReference}s.
+ *
+ * @param dtos property key → reference DTO; {@code null} returns {@code null}
+ * @return property key → reference, or {@code null}
+ */
+ @Nullable
+ public static Map<String, SecretReference> toSecretReferences(
+ @Nullable Map<String, SecretReferenceDTO> dtos) {
+ if (dtos == null) {
+ return null;
+ }
+ Map<String, SecretReference> references = new LinkedHashMap<>(dtos.size());
+ for (Map.Entry<String, SecretReferenceDTO> entry : dtos.entrySet()) {
+ references.put(entry.getKey(), entry.getValue().toSecretReference());
+ }
+ return references;
+ }
+
+ /**
+ * Converts a property-key map of {@link SecretReference}s to DTOs.
+ *
+ * @param references property key → reference; {@code null} returns {@code null}
+ * @return property key → reference DTO, or {@code null}
+ */
+ @Nullable
+ public static Map<String, SecretReferenceDTO> fromSecretReferences(
+ @Nullable Map<String, SecretReference> references) {
Review Comment:
Could u avoid null value ?
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734441269
##########
api/src/main/java/org/apache/gravitino/file/FilesetCatalog.java:
##########
@@ -113,6 +116,10 @@ default Fileset createFileset(
* @param type The type of the fileset.
* @param storageLocations The location names and storage locations of the fileset.
* @param properties The properties of the fileset.
+ * @param secretBindings optional property key → binding ({@code provider} + {@code plaintext})
Review Comment:
Got. createFileset has new method sign with parameter 'secretReferences' and 'secretBindings'
##########
design-docs/gravitino-entity-secrets.md:
##########
@@ -650,12 +650,12 @@ sibling maps). Existing **`setProperty`** stays a **string** `value` (plaintext
| `@type` | Fields (flat; not nested under `value`) | Behavior |
| -------------------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `setProperty` | `value` (**string** plaintext) | Today’s plaintext set. If the **current** value matches the URN recognition rule, in-place `writeSecret` via provider in the current URN; persist new URN |
-| `setSecretBinding` | `provider` (instance name) + `value` (plaintext string) | Write-through bind/re-bind (`writeSecret`); persist returned URN |
+| `setSecretBinding` | `provider` (instance name) + `plaintext` (plaintext string) | Write-through bind/re-bind (`writeSecret`); persist returned URN |
Review Comment:
Got document has been 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3747736879
##########
clients/client-python/gravitino/client/fileset_catalog.py:
##########
@@ -138,6 +139,8 @@ def create_fileset(
fileset_type: Fileset.Type,
storage_location: str,
properties: Dict[str, str],
+ secret_bindings: Dict[str, SecretBinding] = None,
Review Comment:
Could u use empty collection here, too?
##########
clients/client-python/gravitino/client/fileset_catalog.py:
##########
@@ -176,6 +187,8 @@ def create_multiple_location_fileset(
fileset_type: Fileset.Type,
storage_locations: Dict[str, str],
properties: Dict[str, str],
+ secret_bindings: Dict[str, SecretBinding] = None,
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756177568
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -105,21 +204,23 @@ public List<SecretUrn> getSecretReferenceUrns(Map<String, SecretReference> secre
/**
* Builds write-through URNs from {@code secretBindings} without writing secret material.
*
- * <p>Callers should pass the returned URNs to {@link #writeSecrets} to persist plaintext from
- * each binding's value, then put URNs into properties (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>Callers typically pass the returned URNs to {@link #writeSecrets} via {@link
+ * #assembleSecretUrns}, or put URN strings into properties themselves (e.g. via {@link
+ * SecretPropertyUtils#putSecretUrns}).
*
* @param entityType {@code catalog}, {@code schema}, or {@code fileset}
* @param entityId stable numeric entity id
- * @param secretBindings property key → write-through binding
+ * @param secretBindings property key → write-through binding (empty returns an empty list; must
+ * not be null)
* @return write-through URNs (insertion order)
*/
public List<SecretUrn> getSecretBindingUrns(
Review Comment:
buildSecretMaterials
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756286234
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -63,20 +66,108 @@ public SecretProviderRegistry getRegistry() {
return registry;
}
+ /**
+ * Ensures each property key appears at most once across {@code properties}, {@code
+ * secretBindings}, and {@code secretReferences}, and that {@code properties} do not contain raw
+ * secret URN values.
+ *
+ * <p>{@code null} maps are treated as empty. Callers must bind/reference secrets via the typed
+ * maps rather than embedding {@code urn:gravitino-secret:} values in properties.
+ *
+ * @param properties entity properties from the create request (may be null)
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ */
+ public void checkSecretKeys(
+ @Nullable Map<String, String> properties,
+ @Nullable Map<String, SecretBinding> secretBindings,
+ @Nullable Map<String, SecretReference> secretReferences) {
+ // Reject raw URNs in request properties: they bypass typed secretBindings/secretReferences
+ // and can be used to resolve another entity's secret.
+ if (properties != null && !properties.isEmpty()) {
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+ if (SecretPropertyUtils.isSecretProperty(key, value)) {
+ throw new IllegalArgumentException(
+ "Property \""
+ + key
+ + "\" must not contain a raw gravitino secret URN; use secretBindings or"
+ + " secretReferences instead");
+ }
+ }
+ }
+ Set<String> keys = new HashSet<>();
+ int count = 0;
+ if (properties != null) {
+ keys.addAll(properties.keySet());
+ count += properties.size();
+ }
+ if (secretBindings != null) {
+ keys.addAll(secretBindings.keySet());
+ count += secretBindings.size();
+ }
+ if (secretReferences != null) {
+ keys.addAll(secretReferences.keySet());
+ count += secretReferences.size();
+ }
+ if (keys.size() != count) {
+ throw new IllegalArgumentException(
+ "Duplicate property key across properties, secretBindings and secretReferences");
+ }
+ }
+
+ /**
+ * Checks secret keys and puts reference / write-through URN strings into {@code
+ * targetProperties}.
+ *
+ * <p>Callers typically validate {@code targetProperties}, then call {@link #writeSecrets} with
+ * the returned secret materials, and {@link #rollbackSecrets} on failure. {@code properties} is
+ * used only for key uniqueness checks (e.g. the original request map); {@code targetProperties}
+ * is the mutable map that will be stored (may already contain merged catalog conf).
+ *
+ * @param properties properties used for key uniqueness checks (may be null)
+ * @param targetProperties mutable properties that receive URN values
+ * @param entityType {@code catalog}, {@code schema}, or {@code fileset}
+ * @param entityId stable numeric entity id
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ * @return write-through secret materials for {@link #writeSecrets} / {@link #rollbackSecrets}
+ * (empty when there are no bindings)
+ */
+ public List<SecretMaterial> assembleSecretMaterials(
Review Comment:
This name isn't good enough. We can't know you modify the properties from the name. Could u give a better name for it?
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734481576
##########
docs/open-api/filesets.yaml:
##########
@@ -346,6 +346,22 @@ components:
default: {}
additionalProperties:
type: string
+ secretBindings:
+ type: object
+ description: >
+ Optional map of property key to write-through binding. Persisted value
+ becomes a URN.
+ nullable: true
+ additionalProperties:
+ $ref: "./secrets.yaml#/components/schemas/SecretBinding"
Review Comment:
Got 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756074120
##########
core/src/main/java/org/apache/gravitino/secret/SecretMaterial.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.secret;
+
+import com.google.common.base.Preconditions;
+import java.util.Objects;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Write-through secret material: the target {@link SecretUrn} paired with the plaintext to store.
+ *
+ * <p>Produced by {@code SecretManager#assembleSecretUrns} and consumed by {@code
+ * SecretManager#writeSecrets} / {@code SecretManager#rollbackSecrets}.
+ */
+@Evolving
+public final class SecretMaterial {
+
+ private final SecretUrn urn;
+ private final String plaintext;
+
+ /**
+ * Creates secret material for a write-through secret.
+ *
+ * @param urn write-through URN (provider + entity locator)
+ * @param plaintext plaintext secret to write
+ */
+ public SecretMaterial(SecretUrn urn, String plaintext) {
Review Comment:
For the secret references, you don't have the plaintext, right?
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756046549
##########
api/src/main/java/org/apache/gravitino/secret/SecretMaterial.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.secret;
+
+import com.google.common.base.Preconditions;
+import java.util.Objects;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Write-through secret material: the target {@link SecretUrn} paired with the plaintext to store.
+ *
+ * <p>Produced by {@code SecretManager#assembleSecretUrns} and consumed by {@code
+ * SecretManager#writeSecrets} / {@code SecretManager#rollbackSecrets}.
+ */
+@Evolving
+public final class SecretMaterial {
Review Comment:
Could u put this class into core module? This is unnecessary to expose to users.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734486195
##########
core/src/main/java/org/apache/gravitino/catalog/FilesetOperationDispatcher.java:
##########
@@ -143,45 +148,58 @@ public Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties = SecretPropertyUtils.copyEntityProperties(properties);
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ properties, entityProperties, "fileset", uid, secretBindings, secretReferences);
Review Comment:
Got this issue has been fixed.
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretReferenceDTO.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretReference;
+
+/** Data transfer object for an external {@link SecretReference}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString
+public class SecretReferenceDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @Builder.Default
+ @JsonProperty("attributes")
+ private Map<String, String> attributes = ImmutableMap.of();
+
+ /**
+ * Converts this DTO to a {@link SecretReference}.
+ *
+ * @return the secret reference
+ */
+ public SecretReference toSecretReference() {
+ Map<String, String> attrs = attributes == null ? ImmutableMap.of() : attributes;
+ return new SecretReference(provider, attrs);
+ }
+
+ /**
+ * Creates a DTO from a {@link SecretReference}.
+ *
+ * @param reference the secret reference
+ * @return the secret reference DTO
+ */
+ public static SecretReferenceDTO fromSecretReference(SecretReference reference) {
+ return new SecretReferenceDTO(reference.provider(), reference.attributes());
+ }
+
+ /**
+ * Converts a property-key map of DTOs to {@link SecretReference}s.
+ *
+ * @param dtos property key → reference DTO; {@code null} or empty returns an empty map
+ * @return property key → reference (never {@code null})
+ */
+ public static Map<String, SecretReference> toSecretReferences(
+ @Nullable Map<String, SecretReferenceDTO> dtos) {
+ if (dtos == null || dtos.isEmpty()) {
+ return ImmutableMap.of();
+ }
+ ImmutableMap.Builder<String, SecretReference> references = ImmutableMap.builder();
+ for (Map.Entry<String, SecretReferenceDTO> entry : dtos.entrySet()) {
+ references.put(entry.getKey(), entry.getValue().toSecretReference());
+ }
Review Comment:
Got 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3749024883
##########
clients/client-python/gravitino/dto/requests/fileset_create_request.py:
##########
@@ -45,12 +52,16 @@ def __init__(
fileset_type: Fileset.Type = None,
storage_locations: Optional[Dict[str, str]] = None,
properties: Optional[Dict[str, str]] = None,
+ secret_bindings: Optional[Dict[str, SecretBinding]] = None,
Review Comment:
ditto.
##########
common/src/main/java/org/apache/gravitino/dto/requests/FilesetCreateRequest.java:
##########
@@ -64,6 +67,36 @@ public class FilesetCreateRequest implements RESTRequest {
@JsonProperty("properties")
private Map<String, String> properties;
+ @Nullable
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ @JsonProperty("secretBindings")
+ private Map<String, SecretBindingDTO> secretBindings;
+
+ @Nullable
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ @JsonProperty("secretReferences")
+ private Map<String, SecretReferenceDTO> secretReferences;
+
+ /**
+ * Constructor for FilesetCreateRequest without secret maps.
+ *
+ * @param name The name of the fileset.
+ * @param comment The comment of the fileset.
+ * @param type The type of the fileset.
+ * @param storageLocation The storage location of the fileset.
+ * @param storageLocations The storage locations of the fileset.
+ * @param properties The properties of the fileset.
+ */
+ public FilesetCreateRequest(
+ String name,
+ String comment,
+ Fileset.Type type,
+ String storageLocation,
+ Map<String, String> storageLocations,
+ Map<String, String> properties) {
+ this(name, comment, type, storageLocation, storageLocations, properties, null, null);
Review Comment:
Could u use empty collections?
##########
clients/client-python/gravitino/client/fileset_catalog.py:
##########
@@ -176,6 +189,8 @@ def create_multiple_location_fileset(
fileset_type: Fileset.Type,
storage_locations: Dict[str, str],
properties: Dict[str, str],
+ secret_bindings: Optional[Dict[str, SecretBinding]] = None,
Review Comment:
ditto.
##########
clients/client-python/gravitino/client/fileset_catalog.py:
##########
@@ -138,6 +139,8 @@ def create_fileset(
fileset_type: Fileset.Type,
storage_location: str,
properties: Dict[str, str],
+ secret_bindings: Optional[Dict[str, SecretBinding]] = None,
Review Comment:
Could u use empty collection?
##########
core/src/main/java/org/apache/gravitino/hook/FilesetHookDispatcher.java:
##########
@@ -75,27 +80,42 @@ public Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
Fileset fileset =
dispatcher.createMultipleLocationFileset(
- ident, comment, type, storageLocations, properties);
+ ident, comment, type, storageLocations, properties, secretBindings, secretReferences);
- // Set the creator as the owner of the fileset.
- OwnerDispatcher ownerManager = GravitinoEnv.getInstance().ownerDispatcher();
- if (ownerManager != null) {
- // The inner NormalizeDispatcher case-folds the fileset name (and its schema namespace)
- // based on catalog capabilities, so the entity is stored under the normalized identifier.
- // Apply the same normalization here so the owner is attached to the same identifier the
- // manager sees.
- NameIdentifier normalizedIdent =
- CapabilityHelpers.applyCapabilities(
- ident, Capability.Scope.FILESET, GravitinoEnv.getInstance().catalogManager());
- ownerManager.setOwner(
- normalizedIdent.namespace().level(0),
- NameIdentifierUtil.toMetadataObject(normalizedIdent, Entity.EntityType.FILESET),
- PrincipalUtils.getCurrentUserName(),
- Owner.Type.USER);
+ try {
+ // Set the creator as the owner of the fileset.
+ OwnerDispatcher ownerManager = GravitinoEnv.getInstance().ownerDispatcher();
+ if (ownerManager != null) {
+ // The inner NormalizeDispatcher case-folds the fileset name (and its schema namespace)
+ // based on catalog capabilities, so the entity is stored under the normalized identifier.
+ // Apply the same normalization here so the owner is attached to the same identifier the
+ // manager sees.
+ NameIdentifier normalizedIdent =
+ CapabilityHelpers.applyCapabilities(
+ ident, Capability.Scope.FILESET, GravitinoEnv.getInstance().catalogManager());
+ ownerManager.setOwner(
+ normalizedIdent.namespace().level(0),
+ NameIdentifierUtil.toMetadataObject(normalizedIdent, Entity.EntityType.FILESET),
+ PrincipalUtils.getCurrentUserName(),
+ Owner.Type.USER);
+ }
+ } catch (Exception postHookException) {
+ LOG.warn(
+ "Failed to execute post hook operations, rolling back fileset " + ident,
+ postHookException);
+ try {
+ dispatcher.dropFileset(ident);
Review Comment:
Why do we add extra operations about file set rollback?
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3749276144
##########
clients/client-python/gravitino/dto/requests/fileset_create_request.py:
##########
@@ -45,12 +52,16 @@ def __init__(
fileset_type: Fileset.Type = None,
storage_locations: Optional[Dict[str, str]] = None,
properties: Optional[Dict[str, str]] = None,
+ secret_bindings: Optional[Dict[str, SecretBinding]] = None,
Review Comment:
As mentioned above, it has also 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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3725412815
##########
docs/open-api/catalogs.yaml:
##########
@@ -390,6 +390,27 @@ components:
default: { }
additionalProperties:
type: string
+ secretBindings:
+ type: object
+ description: >
+ Optional map of property key to write-through binding. Each binding must
+ include provider and value (plaintext). Persisted value becomes a URN.
+ nullable: true
+ additionalProperties:
Review Comment:
Got. Resolved.
##########
clients/client-python/gravitino/dto/requests/catalog_create_request.py:
##########
@@ -41,6 +41,12 @@ class CatalogCreateRequest(RESTRequest):
_properties: Optional[Dict[str, str]] = field(
metadata=config(field_name="properties")
)
+ _secret_bindings: Optional[Dict[str, Dict[str, str]]] = field(
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734440087
##########
core/src/main/java/org/apache/gravitino/hook/SchemaHookDispatcher.java:
##########
@@ -91,7 +98,8 @@ public Schema createSchema(NameIdentifier ident, String comment, Map<String, Str
// ancestor's owner is never overwritten.
List<NameIdentifier> newAncestors = findMissingAncestors(normalizedIdent);
- Schema schema = dispatcher.createSchema(ident, comment, properties);
+ Schema schema =
+ dispatcher.createSchema(ident, comment, properties, secretBindings, secretReferences);
Review Comment:
I agree with your point of view. Currently, the creation of schema and fileset has failed, and the secret will also be rolled back.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734489459
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -101,84 +106,99 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
* @throws SchemaAlreadyExistsException If a schema with the same identifier already exists.
*/
@Override
- public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
+ 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);
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ properties, entityProperties, "schema", uid, secretBindings, secretReferences);
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3725411999
##########
common/src/main/java/org/apache/gravitino/dto/requests/CatalogCreateRequest.java:
##########
@@ -54,6 +54,14 @@ public class CatalogCreateRequest implements RESTRequest {
@JsonProperty("properties")
private final Map<String, String> properties;
+ @Nullable
+ @JsonProperty("secretBindings")
+ private final Map<String, Map<String, String>> secretBindings;
Review Comment:
Got. The problem was solved by creating the "secretBinding" class.
##########
common/src/main/java/org/apache/gravitino/dto/requests/CatalogCreateRequest.java:
##########
@@ -54,6 +54,14 @@ public class CatalogCreateRequest implements RESTRequest {
@JsonProperty("properties")
private final Map<String, String> properties;
+ @Nullable
+ @JsonProperty("secretBindings")
+ private final Map<String, Map<String, String>> secretBindings;
+
+ @Nullable
+ @JsonProperty("secretReferences")
+ private final Map<String, Map<String, String>> secretReferences;
Review Comment:
The problem was solved by creating the "secretReference" class.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734438836
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -87,7 +155,7 @@ public List<SecretUrn> getSecretReferenceUrns(Map<String, SecretReference> secre
SecretProvider provider = registry.getProvider(providerName);
try {
SecretUrn urn = provider.buildReferenceUrn(key, locator.attributes());
Review Comment:
Agreed this is important, but it’s outside the scope of this PR.It can be optimized later.
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -101,84 +106,99 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
* @throws SchemaAlreadyExistsException If a schema with the same identifier already exists.
*/
@Override
- public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
+ 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);
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ 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(secretBindings, secretUrns);
// 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.
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)),
Review Comment:
Thank you very much for your review. The text has been revised. persisted = URN, connector/runtime conf = plaintext
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -593,12 +596,20 @@ 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 {
NameIdentifier metalakeIdent = NameIdentifier.of(ident.namespace().levels());
- Map<String, String> mergedConfig = buildCatalogConf(provider, properties);
+ final Map<String, String> mergedConfig = new HashMap<>(buildCatalogConf(provider, properties));
long uid = idGenerator.nextId();
+
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ properties, mergedConfig, "catalog", uid, secretBindings, secretReferences);
+ secretManager.writeSecrets(secretBindings, secretUrns);
Review Comment:
Thank you for your review. The sequence has been adjusted. After checking Metalake, the writeSecrets operation will be executed.
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -101,84 +106,99 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
* @throws SchemaAlreadyExistsException If a schema with the same identifier already exists.
*/
@Override
- public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
+ 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);
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ 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(secretBindings, secretUrns);
Review Comment:
Agree with your review. The schema and fileset deletion scenarios have been added, and the secret has also been cleaned up.
##########
core/src/main/java/org/apache/gravitino/hook/SchemaHookDispatcher.java:
##########
@@ -91,7 +98,8 @@ public Schema createSchema(NameIdentifier ident, String comment, Map<String, Str
// ancestor's owner is never overwritten.
List<NameIdentifier> newAncestors = findMissingAncestors(normalizedIdent);
- Schema schema = dispatcher.createSchema(ident, comment, properties);
+ Schema schema =
+ dispatcher.createSchema(ident, comment, properties, secretBindings, secretReferences);
Review Comment:
I agree with your point of view. Currently, the creation of schema and fileset has failed, and the secret will also be rolled back.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3725611146
##########
api/src/main/java/org/apache/gravitino/file/FilesetCatalog.java:
##########
@@ -122,11 +128,36 @@ default Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
throw new UnsupportedOperationException("Not implemented");
}
+ /**
+ * Create a fileset metadata with multiple storage locations in the catalog.
+ *
+ * @param ident A fileset identifier.
+ * @param comment The comment of the fileset.
+ * @param type The type of the fileset.
+ * @param storageLocations The location names and storage locations of the fileset.
+ * @param properties The properties of the fileset.
+ * @return The created fileset metadata
+ * @throws NoSuchSchemaException If the schema does not exist.
+ * @throws FilesetAlreadyExistsException If the fileset already exists.
+ */
+ default Fileset createMultipleLocationFileset(
+ NameIdentifier ident,
+ String comment,
+ Fileset.Type type,
+ Map<String, String> storageLocations,
+ Map<String, String> properties)
+ throws NoSuchSchemaException, FilesetAlreadyExistsException {
+ return createMultipleLocationFileset(
Review Comment:
Thank you very much for your suggestions.This class and other similar classes have been used Collections.emptyMap() instead.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3749267239
##########
clients/client-python/gravitino/client/fileset_catalog.py:
##########
@@ -138,6 +139,8 @@ def create_fileset(
fileset_type: Fileset.Type,
storage_location: str,
properties: Dict[str, str],
+ secret_bindings: Optional[Dict[str, SecretBinding]] = None,
Review Comment:
Thank you very much for your suggestion. The problem 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3747553200
##########
api/src/main/java/org/apache/gravitino/file/FilesetCatalog.java:
##########
@@ -105,6 +108,43 @@ default Fileset createFileset(
properties);
}
+ /**
+ * Create a fileset metadata with a default location and optional create-time secrets.
+ *
+ * @param ident A fileset identifier.
+ * @param comment The comment of the fileset.
+ * @param type The type of the fileset.
+ * @param storageLocation The storage location of the fileset.
+ * @param properties The properties of the fileset.
+ * @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 fileset metadata
+ * @throws NoSuchSchemaException If the schema does not exist.
+ * @throws FilesetAlreadyExistsException If the fileset already exists.
+ */
+ default Fileset createFileset(
+ NameIdentifier ident,
+ String comment,
+ Fileset.Type type,
+ String storageLocation,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
Review Comment:
Think twice. This is acceptable.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3725432341
##########
api/src/main/java/org/apache/gravitino/file/FilesetCatalog.java:
##########
@@ -122,11 +128,36 @@ default Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
throw new UnsupportedOperationException("Not implemented");
}
+ /**
+ * Create a fileset metadata with multiple storage locations in the catalog.
+ *
+ * @param ident A fileset identifier.
+ * @param comment The comment of the fileset.
+ * @param type The type of the fileset.
+ * @param storageLocations The location names and storage locations of the fileset.
+ * @param properties The properties of the fileset.
+ * @return The created fileset metadata
+ * @throws NoSuchSchemaException If the schema does not exist.
+ * @throws FilesetAlreadyExistsException If the fileset already exists.
+ */
+ default Fileset createMultipleLocationFileset(
+ NameIdentifier ident,
+ String comment,
+ Fileset.Type type,
+ Map<String, String> storageLocations,
+ Map<String, String> properties)
+ throws NoSuchSchemaException, FilesetAlreadyExistsException {
+ return createMultipleLocationFileset(
Review Comment:
Could u use empty collection instead of null value?
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3748115920
##########
clients/client-python/gravitino/client/fileset_catalog.py:
##########
@@ -176,6 +187,8 @@ def create_multiple_location_fileset(
fileset_type: Fileset.Type,
storage_locations: Dict[str, str],
properties: Dict[str, str],
+ secret_bindings: Dict[str, SecretBinding] = None,
Review Comment:
Got resolved.
##########
clients/client-python/gravitino/client/fileset_catalog.py:
##########
@@ -138,6 +139,8 @@ def create_fileset(
fileset_type: Fileset.Type,
storage_location: str,
properties: Dict[str, str],
+ secret_bindings: Dict[str, SecretBinding] = None,
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#issuecomment-5215006710
Follow-up stacked PR (catalog + schema), base = this branch:
- Fork PR: https://github.com/lasdf1234/gravitino/pull/34
- Branch: `feat/entity-secrets-create-catalog-schema`
After this PR merges to `main`, that follow-up can be opened/retargeted against `apache/main`.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3718493031
##########
api/src/main/java/org/apache/gravitino/file/FilesetCatalog.java:
##########
@@ -122,11 +126,36 @@ default Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, Map<String, String>> secretBindings,
Review Comment:
We should define `SecretBindings` here instead of using a Map.
For example,
```
class SecretBinding {
string name;
String provider;
}
```
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756116719
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -141,78 +242,153 @@ public List<SecretUrn> getSecretBindingUrns(
}
/**
- * Writes plaintext secrets from {@code secretBindings} values into the write-through providers
- * for {@code secretUrns} (e.g. Vault).
+ * Writes plaintext secrets into the write-through providers for each {@link SecretMaterial} (e.g.
+ * Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretMaterials} must come from {@link #assembleSecretUrns}. On failure,
+ * already-written URNs are rolled back. When using {@link #assembleSecretUrns}, URN strings are
+ * already in properties; otherwise callers must put them themselves (e.g. via {@link
+ * SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * @param secretMaterials write-through secret materials (empty is a no-op; must not be null)
*/
- public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
- validateSecretBindings(secretBindings);
+ public void writeSecrets(List<SecretMaterial> secretMaterials) {
Review Comment:
Actually, we don't need to write the reference. We just need to secret bindings?
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756074120
##########
api/src/main/java/org/apache/gravitino/secret/SecretMaterial.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.secret;
+
+import com.google.common.base.Preconditions;
+import java.util.Objects;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Write-through secret material: the target {@link SecretUrn} paired with the plaintext to store.
+ *
+ * <p>Produced by {@code SecretManager#assembleSecretUrns} and consumed by {@code
+ * SecretManager#writeSecrets} / {@code SecretManager#rollbackSecrets}.
+ */
+@Evolving
+public final class SecretMaterial {
+
+ private final SecretUrn urn;
+ private final String plaintext;
+
+ /**
+ * Creates secret material for a write-through secret.
+ *
+ * @param urn write-through URN (provider + entity locator)
+ * @param plaintext plaintext secret to write
+ */
+ public SecretMaterial(SecretUrn urn, String plaintext) {
Review Comment:
For the secret references, you don't have the plaintext, right?
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756170713
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -63,20 +66,116 @@ public SecretProviderRegistry getRegistry() {
return registry;
}
+ /**
+ * Ensures each property key appears at most once across {@code properties}, {@code
+ * secretBindings}, and {@code secretReferences}, and that {@code properties} do not contain raw
+ * secret URN values.
+ *
+ * <p>{@code null} maps are treated as empty. Callers must bind/reference secrets via the typed
+ * maps rather than embedding {@code urn:gravitino-secret:} values in properties.
+ *
+ * @param properties entity properties from the create request (may be null)
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ */
+ public void checkSecretKeys(
+ @Nullable Map<String, String> properties,
+ @Nullable Map<String, SecretBinding> secretBindings,
+ @Nullable Map<String, SecretReference> secretReferences) {
+ // Reject raw URNs in request properties: they bypass typed secretBindings/secretReferences
+ // and can be used to resolve another entity's secret.
+ if (properties != null && !properties.isEmpty()) {
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+ if (SecretPropertyUtils.isSecretProperty(key, value)) {
+ throw new IllegalArgumentException(
+ "Property \""
+ + key
+ + "\" must not contain a raw gravitino secret URN; use secretBindings or"
+ + " secretReferences instead");
+ }
+ }
+ }
+ Set<String> keys = new HashSet<>();
+ int count = 0;
+ if (properties != null) {
+ keys.addAll(properties.keySet());
+ count += properties.size();
+ }
+ if (secretBindings != null) {
+ keys.addAll(secretBindings.keySet());
+ count += secretBindings.size();
+ }
+ if (secretReferences != null) {
+ keys.addAll(secretReferences.keySet());
+ count += secretReferences.size();
+ }
+ if (keys.size() != count) {
+ throw new IllegalArgumentException(
+ "Duplicate property key across properties, secretBindings and secretReferences");
+ }
+ }
+
+ /**
+ * Checks secret keys and puts reference / write-through URN strings into {@code
+ * targetProperties}.
+ *
+ * <p>Callers typically validate {@code targetProperties}, then call {@link #writeSecrets} with
+ * the returned secret materials, and {@link #rollbackSecrets} on failure. {@code properties} is
+ * used only for key uniqueness checks (e.g. the original request map); {@code targetProperties}
+ * is the mutable map that will be stored (may already contain merged catalog conf).
+ *
+ * @param properties properties used for key uniqueness checks (may be null)
+ * @param targetProperties mutable properties that receive URN values
+ * @param entityType {@code catalog}, {@code schema}, or {@code fileset}
+ * @param entityId stable numeric entity id
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ * @return write-through secret materials for {@link #writeSecrets} / {@link #rollbackSecrets}
+ * (empty when there are no bindings)
+ */
+ public List<SecretMaterial> assembleSecretUrns(
Review Comment:
We should refactor the method. This name isn't good. The method return SecretMaterial but has the name with SecreateUrns.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3733336388
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -101,84 +106,99 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
* @throws SchemaAlreadyExistsException If a schema with the same identifier already exists.
*/
@Override
- public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
+ 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);
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ 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(secretBindings, secretUrns);
// 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.
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)),
Review Comment:
`updatedProperties` contains the secret URNs assembled above, but it is passed unchanged to the schema connector. There is no schema/fileset equivalent of `CatalogManager.toPlaintextProperties`; the fileset catalog later merges schema/fileset properties into filesystem configuration, so a credential remains a `urn:...` string and authentication fails. Please provide a resolved copy at the connector/runtime consumption boundary while keeping persisted metadata as URNs, and apply the same fix to `FilesetOperationDispatcher`.
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -593,12 +596,20 @@ 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 {
NameIdentifier metalakeIdent = NameIdentifier.of(ident.namespace().levels());
- Map<String, String> mergedConfig = buildCatalogConf(provider, properties);
+ final Map<String, String> mergedConfig = new HashMap<>(buildCatalogConf(provider, properties));
long uid = idGenerator.nextId();
+
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ properties, mergedConfig, "catalog", uid, secretBindings, secretReferences);
+ secretManager.writeSecrets(secretBindings, secretUrns);
Review Comment:
`writeSecrets` executes before `checkMetalake` and before the cleanup `try/finally`. If the metalake is missing or concurrently deleted, this method exits at `checkMetalake` without rollback and leaves provider material orphaned. Move the write under the lock, after metalake validation, and keep it inside the cleanup scope.
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -101,84 +106,99 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
* @throws SchemaAlreadyExistsException If a schema with the same identifier already exists.
*/
@Override
- public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
+ 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);
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ 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(secretBindings, secretUrns);
Review Comment:
Once this write succeeds, a successful `dropSchema` has no corresponding path that reads the stored URNs and deletes the write-through secret. A create-then-drop sequence therefore permanently leaves provider material behind. Please add drop cleanup for write-through URNs owned by the schema; `FilesetOperationDispatcher` has the same gap. External-reference URNs must remain untouched.
##########
core/src/main/java/org/apache/gravitino/hook/SchemaHookDispatcher.java:
##########
@@ -91,7 +98,8 @@ public Schema createSchema(NameIdentifier ident, String comment, Map<String, Str
// ancestor's owner is never overwritten.
List<NameIdentifier> newAncestors = findMissingAncestors(normalizedIdent);
- Schema schema = dispatcher.createSchema(ident, comment, properties);
+ Schema schema =
+ dispatcher.createSchema(ident, comment, properties, secretBindings, secretReferences);
Review Comment:
`dispatcher.createSchema` has already persisted the entity and written its secrets when it returns. If the later `ownerManager.setOwners` call throws, the API reports a create failure but this hook has no compensating drop or secret cleanup, so the entity and secret remain and a retry sees already-exists. Please add hook-level compensation; `FilesetHookDispatcher` has the same sequence.
##########
design-docs/gravitino-entity-secrets.md:
##########
@@ -650,12 +650,12 @@ sibling maps). Existing **`setProperty`** stays a **string** `value` (plaintext
| `@type` | Fields (flat; not nested under `value`) | Behavior |
| -------------------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `setProperty` | `value` (**string** plaintext) | Today’s plaintext set. If the **current** value matches the URN recognition rule, in-place `writeSecret` via provider in the current URN; persist new URN |
-| `setSecretBinding` | `provider` (instance name) + `value` (plaintext string) | Write-through bind/re-bind (`writeSecret`); persist returned URN |
+| `setSecretBinding` | `provider` (instance name) + `plaintext` (plaintext string) | Write-through bind/re-bind (`writeSecret`); persist returned URN |
Review Comment:
This alter row now correctly uses typed `provider` plus `plaintext`, but the create contract in §5.9.2/TC-1 still says `secretBindings` is `map<string,string>` and places plaintext in `properties`. The current DTO/OpenAPI require `property -> {provider, plaintext}` and reject overlap with `properties`, so requests following the document fail. Please update the create rules and examples in the same change.
##########
api/src/main/java/org/apache/gravitino/file/FilesetCatalog.java:
##########
@@ -113,6 +116,10 @@ default Fileset createFileset(
* @param type The type of the fileset.
* @param storageLocations The location names and storage locations of the fileset.
* @param properties The properties of the fileset.
+ * @param secretBindings optional property key → binding ({@code provider} + {@code plaintext})
Review Comment:
The new secret-aware entry point exists only for `createMultipleLocationFileset`. The common single-location `createFileset` overload cannot accept either secret map, so Java callers must switch APIs and manufacture a singleton location map. Please add a symmetric secret-aware overload and delegate internally.
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -87,7 +155,7 @@ public List<SecretUrn> getSecretReferenceUrns(Map<String, SecretReference> secre
SecretProvider provider = registry.getProvider(providerName);
try {
SecretUrn urn = provider.buildReferenceUrn(key, locator.attributes());
Review Comment:
For an external-reference provider that reads a shared secret namespace with a service identity, this accepts caller-controlled `provider`/`attributes` without authorizing the referenced secret for the current principal or target entity. A catalog creator could therefore make Gravitino read or use a secret outside their scope; a caller-controlled connector target may then disclose or misuse it. Please add reference-level authorization/scoping when binding and again when reading or using the URN.
##########
api/src/main/java/org/apache/gravitino/SupportsCatalogs.java:
##########
@@ -84,23 +88,58 @@ 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.
+ * @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
+ * @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
*/
Catalog createCatalog(
String catalogName,
Catalog.Type type,
String provider,
String comment,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
Review Comment:
I realize this interface is `@Evolving`, but making the new secret-aware overload abstract while turning the old method into a default forces every existing third-party implementation to add the new method; invoking the new API on an old implementation can produce `AbstractMethodError`. Could we preserve the old abstract method and make the new overload a safe default that delegates only for empty secret maps, or explicitly rejects non-empty maps? `SupportsSchemas` has the same compatibility reversal.
##########
common/src/main/java/org/apache/gravitino/dto/requests/CatalogCreateRequest.java:
##########
@@ -62,18 +94,26 @@ public class CatalogCreateRequest implements RESTRequest {
* @param provider The provider of the catalog.
* @param comment The comment for the catalog.
* @param properties The properties for the catalog.
+ * @param secretBindings Optional property key → binding DTO ({@code provider} + {@code
+ * plaintext}) for write-through secrets.
+ * @param secretReferences Optional property key → secret locator DTO ({@code provider} plus
+ * provider-specific attributes).
*/
@JsonCreator
public CatalogCreateRequest(
@JsonProperty("name") String name,
@JsonProperty("type") Catalog.Type type,
@JsonProperty("provider") String provider,
@JsonProperty("comment") String comment,
- @JsonProperty("properties") Map<String, String> properties) {
+ @JsonProperty("properties") Map<String, String> properties,
+ @JsonProperty("secretBindings") Map<String, SecretBindingDTO> secretBindings,
+ @JsonProperty("secretReferences") Map<String, SecretReferenceDTO> secretReferences) {
this.name = name;
this.type = type;
this.comment = comment;
this.properties = properties;
+ this.secretBindings = secretBindings;
+ this.secretReferences = secretReferences;
Review Comment:
`NON_EMPTY` omits the empty maps created by the legacy constructor, but missing JSON fields arrive as `null` and are stored unchanged here. A JSON round trip therefore changes empty maps to `null`, currently failing `TestCatalogCreateRequest.testCatalogCreateRequestSerDe` and `TestRequestJsonSerDe.testCatalogCreateRequestSerDe` in `build (17)`. Normalize absent secret maps to empty here, or otherwise make the serialization/equality contract consistent.
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -1303,7 +1320,10 @@ private Map<String, String> getResolvedProperties(CatalogEntity entity) {
private BaseCatalog<?> createBaseCatalog(IsolatedClassLoader classLoader, CatalogEntity entity) {
// Load Catalog class instance
BaseCatalog<?> catalog = createCatalogInstance(classLoader, entity.getProvider());
- catalog.withCatalogConf(entity.getProperties()).withCatalogEntity(entity);
+ // Resolve secret URNs to plaintext for connector init only; entity storage keeps URNs.
+ catalog
+ .withCatalogConf(secretManager.toPlaintextProperties(entity.getProperties()))
Review Comment:
`GET .../catalogs?details=true` calls `listCatalogsInfo` for every catalog before the REST layer performs per-item authorization filtering. This eager resolution therefore performs provider reads and initializes cached catalog configuration with plaintext even for catalogs filtered from the response; one provider failure can also fail the entire listing. Filter authorized identifiers before loading/resolving wrappers, and avoid retaining plaintext longer than connector use.
##########
common/src/main/java/org/apache/gravitino/dto/requests/FilesetCreateRequest.java:
##########
@@ -64,6 +67,16 @@ public class FilesetCreateRequest implements RESTRequest {
@JsonProperty("properties")
private Map<String, String> properties;
+ @Nullable
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ @JsonProperty("secretBindings")
+ private Map<String, SecretBindingDTO> secretBindings;
Review Comment:
Because this class exposes Lombok's `@AllArgsConstructor`, adding these fields changes the public constructor from six parameters to eight. Existing source calls stop compiling and existing binaries can fail with `NoSuchMethodError`. Please preserve an explicit six-argument overload, as the catalog/schema request DTOs do, or avoid treating the generated all-args constructor as the compatibility contract.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734482829
##########
core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java:
##########
@@ -77,9 +79,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 {
- Catalog catalog = dispatcher.createCatalog(ident, type, provider, comment, properties);
+ Catalog catalog =
+ dispatcher.createCatalog(
+ ident, type, provider, comment, properties, secretBindings, secretReferences);
Review Comment:
Got 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): Support secretBindings/secretReferences on create [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3725740640
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretReferenceDTO.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretReference;
+
+/** Data transfer object for an external {@link SecretReference}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString
+public class SecretReferenceDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @Nullable
Review Comment:
We should use empty collection instead of null value 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): Support secretBindings/secretReferences on create [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3718493031
##########
api/src/main/java/org/apache/gravitino/file/FilesetCatalog.java:
##########
@@ -122,11 +126,36 @@ default Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, Map<String, String>> secretBindings,
Review Comment:
We should define `SecretBindings` here instead of using a Map.
For example,
```
class SecretBinding {
string name;
String provider;
}
```
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3749272499
##########
clients/client-python/gravitino/client/fileset_catalog.py:
##########
@@ -176,6 +189,8 @@ def create_multiple_location_fileset(
fileset_type: Fileset.Type,
storage_locations: Dict[str, str],
properties: Dict[str, str],
+ secret_bindings: Optional[Dict[str, SecretBinding]] = None,
Review Comment:
Thank you very much for your suggestion. The problem 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756027359
##########
core/src/main/java/org/apache/gravitino/catalog/FilesetOperationDispatcher.java:
##########
@@ -143,45 +148,67 @@ public Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
+ // System entrance: normalize null secret maps to empty so SecretManager.writeSecrets can
+ // require non-null arguments.
+ Map<String, SecretBinding> bindings = secretBindings == null ? Map.of() : secretBindings;
+ Map<String, SecretReference> references =
+ secretReferences == null ? Map.of() : secretReferences;
+
NameIdentifier catalogIdent = getCatalogIdentifier(ident);
+ long uid = idGenerator.nextId();
+ Map<String, String> entityProperties = SecretPropertyUtils.copyEntityProperties(properties);
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ properties, entityProperties, "fileset", uid, bindings, references);
doWithCatalog(
catalogIdent,
c ->
c.doWithPropertiesMeta(
p -> {
- validatePropertyForCreate(p.filesetPropertiesMetadata(), properties);
+ validatePropertyForCreate(p.filesetPropertiesMetadata(), entityProperties);
return null;
}),
IllegalArgumentException.class);
- long uid = idGenerator.nextId();
+ secretManager.writeSecrets(bindings, secretUrns);
Review Comment:
The secretUrns class lacks plaintext, so a new class called SecretMaterial was created. This class contains both plaintext and secretUrn.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756255145
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -63,20 +66,116 @@ public SecretProviderRegistry getRegistry() {
return registry;
}
+ /**
+ * Ensures each property key appears at most once across {@code properties}, {@code
+ * secretBindings}, and {@code secretReferences}, and that {@code properties} do not contain raw
+ * secret URN values.
+ *
+ * <p>{@code null} maps are treated as empty. Callers must bind/reference secrets via the typed
+ * maps rather than embedding {@code urn:gravitino-secret:} values in properties.
+ *
+ * @param properties entity properties from the create request (may be null)
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ */
+ public void checkSecretKeys(
+ @Nullable Map<String, String> properties,
+ @Nullable Map<String, SecretBinding> secretBindings,
+ @Nullable Map<String, SecretReference> secretReferences) {
+ // Reject raw URNs in request properties: they bypass typed secretBindings/secretReferences
+ // and can be used to resolve another entity's secret.
+ if (properties != null && !properties.isEmpty()) {
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+ if (SecretPropertyUtils.isSecretProperty(key, value)) {
+ throw new IllegalArgumentException(
+ "Property \""
+ + key
+ + "\" must not contain a raw gravitino secret URN; use secretBindings or"
+ + " secretReferences instead");
+ }
+ }
+ }
+ Set<String> keys = new HashSet<>();
+ int count = 0;
+ if (properties != null) {
+ keys.addAll(properties.keySet());
+ count += properties.size();
+ }
+ if (secretBindings != null) {
+ keys.addAll(secretBindings.keySet());
+ count += secretBindings.size();
+ }
+ if (secretReferences != null) {
+ keys.addAll(secretReferences.keySet());
+ count += secretReferences.size();
+ }
+ if (keys.size() != count) {
+ throw new IllegalArgumentException(
+ "Duplicate property key across properties, secretBindings and secretReferences");
+ }
+ }
+
+ /**
+ * Checks secret keys and puts reference / write-through URN strings into {@code
+ * targetProperties}.
+ *
+ * <p>Callers typically validate {@code targetProperties}, then call {@link #writeSecrets} with
+ * the returned secret materials, and {@link #rollbackSecrets} on failure. {@code properties} is
+ * used only for key uniqueness checks (e.g. the original request map); {@code targetProperties}
+ * is the mutable map that will be stored (may already contain merged catalog conf).
+ *
+ * @param properties properties used for key uniqueness checks (may be null)
+ * @param targetProperties mutable properties that receive URN values
+ * @param entityType {@code catalog}, {@code schema}, or {@code fileset}
+ * @param entityId stable numeric entity id
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ * @return write-through secret materials for {@link #writeSecrets} / {@link #rollbackSecrets}
+ * (empty when there are no bindings)
+ */
+ public List<SecretMaterial> assembleSecretUrns(
Review Comment:
Got rename to assembleSecretMaterials.
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -63,20 +66,116 @@ public SecretProviderRegistry getRegistry() {
return registry;
}
+ /**
+ * Ensures each property key appears at most once across {@code properties}, {@code
+ * secretBindings}, and {@code secretReferences}, and that {@code properties} do not contain raw
+ * secret URN values.
+ *
+ * <p>{@code null} maps are treated as empty. Callers must bind/reference secrets via the typed
+ * maps rather than embedding {@code urn:gravitino-secret:} values in properties.
+ *
+ * @param properties entity properties from the create request (may be null)
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ */
+ public void checkSecretKeys(
+ @Nullable Map<String, String> properties,
+ @Nullable Map<String, SecretBinding> secretBindings,
+ @Nullable Map<String, SecretReference> secretReferences) {
+ // Reject raw URNs in request properties: they bypass typed secretBindings/secretReferences
+ // and can be used to resolve another entity's secret.
+ if (properties != null && !properties.isEmpty()) {
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+ if (SecretPropertyUtils.isSecretProperty(key, value)) {
+ throw new IllegalArgumentException(
+ "Property \""
+ + key
+ + "\" must not contain a raw gravitino secret URN; use secretBindings or"
+ + " secretReferences instead");
+ }
+ }
+ }
+ Set<String> keys = new HashSet<>();
+ int count = 0;
+ if (properties != null) {
+ keys.addAll(properties.keySet());
+ count += properties.size();
+ }
+ if (secretBindings != null) {
+ keys.addAll(secretBindings.keySet());
+ count += secretBindings.size();
+ }
+ if (secretReferences != null) {
+ keys.addAll(secretReferences.keySet());
+ count += secretReferences.size();
+ }
+ if (keys.size() != count) {
+ throw new IllegalArgumentException(
+ "Duplicate property key across properties, secretBindings and secretReferences");
+ }
+ }
+
+ /**
+ * Checks secret keys and puts reference / write-through URN strings into {@code
+ * targetProperties}.
+ *
+ * <p>Callers typically validate {@code targetProperties}, then call {@link #writeSecrets} with
+ * the returned secret materials, and {@link #rollbackSecrets} on failure. {@code properties} is
+ * used only for key uniqueness checks (e.g. the original request map); {@code targetProperties}
+ * is the mutable map that will be stored (may already contain merged catalog conf).
+ *
+ * @param properties properties used for key uniqueness checks (may be null)
+ * @param targetProperties mutable properties that receive URN values
+ * @param entityType {@code catalog}, {@code schema}, or {@code fileset}
+ * @param entityId stable numeric entity id
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ * @return write-through secret materials for {@link #writeSecrets} / {@link #rollbackSecrets}
+ * (empty when there are no bindings)
+ */
+ public List<SecretMaterial> assembleSecretUrns(
+ @Nullable Map<String, String> properties,
+ Map<String, String> targetProperties,
+ String entityType,
+ long entityId,
+ @Nullable Map<String, SecretBinding> secretBindings,
+ @Nullable Map<String, SecretReference> secretReferences) {
+ checkSecretKeys(properties, secretBindings, secretReferences);
+ Map<String, SecretBinding> bindings = secretBindings == null ? Map.of() : secretBindings;
+ Map<String, SecretReference> references =
+ secretReferences == null ? Map.of() : secretReferences;
+ SecretPropertyUtils.putSecretUrns(targetProperties, getSecretReferenceUrns(references));
+ List<SecretUrn> bindingUrns = getSecretBindingUrns(entityType, entityId, bindings);
+ List<SecretMaterial> secretMaterials = new ArrayList<>(bindingUrns.size());
+ for (SecretUrn urn : bindingUrns) {
+ String propertyKey = urn.propertyKey();
+ SecretBinding binding = bindings.get(propertyKey);
+ Preconditions.checkArgument(
+ binding != null, "No secretBindings entry for property key \"%s\"", propertyKey);
+ secretMaterials.add(new SecretMaterial(urn, binding.plaintext()));
+ }
+ SecretPropertyUtils.putSecretUrns(targetProperties, bindingUrns);
+ return List.copyOf(secretMaterials);
+ }
+
/**
* Builds external-reference URNs from {@code secretReferences} without writing secret material.
*
* <p>Callers must put the returned URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}). External-ref URNs are owned outside Gravitino and must
- * not be passed to {@link #rollbackWritten}.
+ * SecretPropertyUtils#putSecretUrns}). External-ref URNs are owned outside Gravitino and must not
+ * be passed to {@link #rollbackSecrets}.
*
- * @param secretReferences property key → secret locator
+ * @param secretReferences property key → secret locator (empty returns an empty list; must not be
+ * null)
* @return external-reference URNs (insertion order)
*/
public List<SecretUrn> getSecretReferenceUrns(Map<String, SecretReference> secretReferences) {
Review Comment:
Got resolved.
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -105,21 +204,23 @@ public List<SecretUrn> getSecretReferenceUrns(Map<String, SecretReference> secre
/**
* Builds write-through URNs from {@code secretBindings} without writing secret material.
*
- * <p>Callers should pass the returned URNs to {@link #writeSecrets} to persist plaintext from
- * each binding's value, then put URNs into properties (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>Callers typically pass the returned URNs to {@link #writeSecrets} via {@link
+ * #assembleSecretUrns}, or put URN strings into properties themselves (e.g. via {@link
+ * SecretPropertyUtils#putSecretUrns}).
*
* @param entityType {@code catalog}, {@code schema}, or {@code fileset}
* @param entityId stable numeric entity id
- * @param secretBindings property key → write-through binding
+ * @param secretBindings property key → write-through binding (empty returns an empty list; must
+ * not be null)
* @return write-through URNs (insertion order)
*/
public List<SecretUrn> getSecretBindingUrns(
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756141064
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -141,78 +242,153 @@ public List<SecretUrn> getSecretBindingUrns(
}
/**
- * Writes plaintext secrets from {@code secretBindings} values into the write-through providers
- * for {@code secretUrns} (e.g. Vault).
+ * Writes plaintext secrets into the write-through providers for each {@link SecretMaterial} (e.g.
+ * Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretMaterials} must come from {@link #assembleSecretUrns}. On failure,
+ * already-written URNs are rolled back. When using {@link #assembleSecretUrns}, URN strings are
+ * already in properties; otherwise callers must put them themselves (e.g. via {@link
+ * SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * @param secretMaterials write-through secret materials (empty is a no-op; must not be null)
*/
- public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
- validateSecretBindings(secretBindings);
+ public void writeSecrets(List<SecretMaterial> secretMaterials) {
Review Comment:
The logic isn't clear enough.
You can use similar steps
```
urns = buildReferenceSecretUrns(references)
putUrnsToProps(urns)
buildSecretMaterials(bindings)
putUrnsToProps(bindings:urn::toList)
writeSecretMmaterials(materials)
```
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734440441
##########
common/src/main/java/org/apache/gravitino/dto/requests/CatalogCreateRequest.java:
##########
@@ -62,18 +94,26 @@ public class CatalogCreateRequest implements RESTRequest {
* @param provider The provider of the catalog.
* @param comment The comment for the catalog.
* @param properties The properties for the catalog.
+ * @param secretBindings Optional property key → binding DTO ({@code provider} + {@code
+ * plaintext}) for write-through secrets.
+ * @param secretReferences Optional property key → secret locator DTO ({@code provider} plus
+ * provider-specific attributes).
*/
@JsonCreator
public CatalogCreateRequest(
@JsonProperty("name") String name,
@JsonProperty("type") Catalog.Type type,
@JsonProperty("provider") String provider,
@JsonProperty("comment") String comment,
- @JsonProperty("properties") Map<String, String> properties) {
+ @JsonProperty("properties") Map<String, String> properties,
+ @JsonProperty("secretBindings") Map<String, SecretBindingDTO> secretBindings,
+ @JsonProperty("secretReferences") Map<String, SecretReferenceDTO> secretReferences) {
this.name = name;
this.type = type;
this.comment = comment;
this.properties = properties;
+ this.secretBindings = secretBindings;
+ this.secretReferences = secretReferences;
Review Comment:
Thank you very much for your review. This issue has been fixed.
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -1303,7 +1320,10 @@ private Map<String, String> getResolvedProperties(CatalogEntity entity) {
private BaseCatalog<?> createBaseCatalog(IsolatedClassLoader classLoader, CatalogEntity entity) {
// Load Catalog class instance
BaseCatalog<?> catalog = createCatalogInstance(classLoader, entity.getProvider());
- catalog.withCatalogConf(entity.getProperties()).withCatalogEntity(entity);
+ // Resolve secret URNs to plaintext for connector init only; entity storage keeps URNs.
+ catalog
+ .withCatalogConf(secretManager.toPlaintextProperties(entity.getProperties()))
Review Comment:
Thanks — agreed. details=true now authorizes on catalog identifiers first (listCatalogs + filterByExpression), then resolves catalog details only for the allowed names via listCatalogsInfo(namespace, catalogNames). Unauthorized catalogs are no longer loaded/resolved
##########
common/src/main/java/org/apache/gravitino/dto/requests/FilesetCreateRequest.java:
##########
@@ -64,6 +67,16 @@ public class FilesetCreateRequest implements RESTRequest {
@JsonProperty("properties")
private Map<String, String> properties;
+ @Nullable
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ @JsonProperty("secretBindings")
+ private Map<String, SecretBindingDTO> secretBindings;
Review Comment:
Thank you very much for your review. This issue has been fixed.
##########
api/src/main/java/org/apache/gravitino/SupportsCatalogs.java:
##########
@@ -84,23 +88,58 @@ 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.
+ * @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
+ * @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
*/
Catalog createCatalog(
String catalogName,
Catalog.Type type,
String provider,
String comment,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
Review Comment:
Thank you for your review. In the old method, the keyword used was "abstract", while in the new method, "default" was used. The changes have been made.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3747744339
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -144,75 +234,155 @@ public List<SecretUrn> getSecretBindingUrns(
* Writes plaintext secrets from {@code secretBindings} values into the write-through providers
* for {@code secretUrns} (e.g. Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretUrns} must come from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}. On failure, already-written URNs are rolled back. When using {@link
+ * #assembleSecretUrns}, URN strings are already in properties; otherwise callers must put them
+ * themselves (e.g. via {@link SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * @param secretBindings property key → write-through binding (null or empty is a no-op)
+ * @param secretUrns write-through URNs from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}
*/
- public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
+ public void writeSecrets(
+ @Nullable Map<String, SecretBinding> secretBindings, @Nullable List<SecretUrn> secretUrns) {
+ if (secretBindings == null || secretBindings.isEmpty()) {
Review Comment:
`Precondtitions.checkArgument` 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3748118428
##########
api/src/main/java/org/apache/gravitino/secret/SecretUrn.java:
##########
@@ -69,6 +69,22 @@ public List<String> identifierSegments() {
return identifierSegments;
}
+ /**
+ * Returns the property key encoded as the last identifier segment.
+ *
+ * <p>Gravitino secret URNs end with the entity property key that stores the URN (see {@link
+ * #buildWriteThrough}).
+ *
+ * @return the property key
+ * @throws IllegalArgumentException if this URN has no identifier segments
+ */
+ public String propertyKey() {
Review Comment:
Got. Remove throw exception logical. It's uncessary.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3755077889
##########
core/src/main/java/org/apache/gravitino/hook/FilesetHookDispatcher.java:
##########
@@ -75,27 +80,42 @@ public Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
Fileset fileset =
dispatcher.createMultipleLocationFileset(
- ident, comment, type, storageLocations, properties);
+ ident, comment, type, storageLocations, properties, secretBindings, secretReferences);
- // Set the creator as the owner of the fileset.
- OwnerDispatcher ownerManager = GravitinoEnv.getInstance().ownerDispatcher();
- if (ownerManager != null) {
- // The inner NormalizeDispatcher case-folds the fileset name (and its schema namespace)
- // based on catalog capabilities, so the entity is stored under the normalized identifier.
- // Apply the same normalization here so the owner is attached to the same identifier the
- // manager sees.
- NameIdentifier normalizedIdent =
- CapabilityHelpers.applyCapabilities(
- ident, Capability.Scope.FILESET, GravitinoEnv.getInstance().catalogManager());
- ownerManager.setOwner(
- normalizedIdent.namespace().level(0),
- NameIdentifierUtil.toMetadataObject(normalizedIdent, Entity.EntityType.FILESET),
- PrincipalUtils.getCurrentUserName(),
- Owner.Type.USER);
+ try {
+ // Set the creator as the owner of the fileset.
+ OwnerDispatcher ownerManager = GravitinoEnv.getInstance().ownerDispatcher();
+ if (ownerManager != null) {
+ // The inner NormalizeDispatcher case-folds the fileset name (and its schema namespace)
+ // based on catalog capabilities, so the entity is stored under the normalized identifier.
+ // Apply the same normalization here so the owner is attached to the same identifier the
+ // manager sees.
+ NameIdentifier normalizedIdent =
+ CapabilityHelpers.applyCapabilities(
+ ident, Capability.Scope.FILESET, GravitinoEnv.getInstance().catalogManager());
+ ownerManager.setOwner(
+ normalizedIdent.namespace().level(0),
+ NameIdentifierUtil.toMetadataObject(normalizedIdent, Entity.EntityType.FILESET),
+ PrincipalUtils.getCurrentUserName(),
+ Owner.Type.USER);
+ }
+ } catch (Exception postHookException) {
+ LOG.warn(
+ "Failed to execute post hook operations, rolling back fileset " + ident,
+ postHookException);
+ try {
+ dispatcher.dropFileset(ident);
Review Comment:
Understood your meaning. Back to normal now.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3754663251
##########
core/src/main/java/org/apache/gravitino/hook/FilesetHookDispatcher.java:
##########
@@ -75,27 +80,42 @@ public Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
Fileset fileset =
dispatcher.createMultipleLocationFileset(
- ident, comment, type, storageLocations, properties);
+ ident, comment, type, storageLocations, properties, secretBindings, secretReferences);
- // Set the creator as the owner of the fileset.
- OwnerDispatcher ownerManager = GravitinoEnv.getInstance().ownerDispatcher();
- if (ownerManager != null) {
- // The inner NormalizeDispatcher case-folds the fileset name (and its schema namespace)
- // based on catalog capabilities, so the entity is stored under the normalized identifier.
- // Apply the same normalization here so the owner is attached to the same identifier the
- // manager sees.
- NameIdentifier normalizedIdent =
- CapabilityHelpers.applyCapabilities(
- ident, Capability.Scope.FILESET, GravitinoEnv.getInstance().catalogManager());
- ownerManager.setOwner(
- normalizedIdent.namespace().level(0),
- NameIdentifierUtil.toMetadataObject(normalizedIdent, Entity.EntityType.FILESET),
- PrincipalUtils.getCurrentUserName(),
- Owner.Type.USER);
+ try {
+ // Set the creator as the owner of the fileset.
+ OwnerDispatcher ownerManager = GravitinoEnv.getInstance().ownerDispatcher();
+ if (ownerManager != null) {
+ // The inner NormalizeDispatcher case-folds the fileset name (and its schema namespace)
+ // based on catalog capabilities, so the entity is stored under the normalized identifier.
+ // Apply the same normalization here so the owner is attached to the same identifier the
+ // manager sees.
+ NameIdentifier normalizedIdent =
+ CapabilityHelpers.applyCapabilities(
+ ident, Capability.Scope.FILESET, GravitinoEnv.getInstance().catalogManager());
+ ownerManager.setOwner(
+ normalizedIdent.namespace().level(0),
+ NameIdentifierUtil.toMetadataObject(normalizedIdent, Entity.EntityType.FILESET),
+ PrincipalUtils.getCurrentUserName(),
+ Owner.Type.USER);
+ }
+ } catch (Exception postHookException) {
+ LOG.warn(
+ "Failed to execute post hook operations, rolling back fileset " + ident,
+ postHookException);
+ try {
+ dispatcher.dropFileset(ident);
Review Comment:
Should we adopt similar mechanism for other metadata objects if we rollback the fileset meta managed by Gravitino? I don't think this is a piece of cake. It brings inconsistence.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756260175
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -141,78 +242,153 @@ public List<SecretUrn> getSecretBindingUrns(
}
/**
- * Writes plaintext secrets from {@code secretBindings} values into the write-through providers
- * for {@code secretUrns} (e.g. Vault).
+ * Writes plaintext secrets into the write-through providers for each {@link SecretMaterial} (e.g.
+ * Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretMaterials} must come from {@link #assembleSecretUrns}. On failure,
+ * already-written URNs are rolled back. When using {@link #assembleSecretUrns}, URN strings are
+ * already in properties; otherwise callers must put them themselves (e.g. via {@link
+ * SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * @param secretMaterials write-through secret materials (empty is a no-op; must not be null)
*/
- public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
- validateSecretBindings(secretBindings);
+ public void writeSecrets(List<SecretMaterial> secretMaterials) {
Review Comment:
Got.Method assembleSecretUrns has been simplify.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756286234
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -63,20 +66,108 @@ public SecretProviderRegistry getRegistry() {
return registry;
}
+ /**
+ * Ensures each property key appears at most once across {@code properties}, {@code
+ * secretBindings}, and {@code secretReferences}, and that {@code properties} do not contain raw
+ * secret URN values.
+ *
+ * <p>{@code null} maps are treated as empty. Callers must bind/reference secrets via the typed
+ * maps rather than embedding {@code urn:gravitino-secret:} values in properties.
+ *
+ * @param properties entity properties from the create request (may be null)
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ */
+ public void checkSecretKeys(
+ @Nullable Map<String, String> properties,
+ @Nullable Map<String, SecretBinding> secretBindings,
+ @Nullable Map<String, SecretReference> secretReferences) {
+ // Reject raw URNs in request properties: they bypass typed secretBindings/secretReferences
+ // and can be used to resolve another entity's secret.
+ if (properties != null && !properties.isEmpty()) {
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+ if (SecretPropertyUtils.isSecretProperty(key, value)) {
+ throw new IllegalArgumentException(
+ "Property \""
+ + key
+ + "\" must not contain a raw gravitino secret URN; use secretBindings or"
+ + " secretReferences instead");
+ }
+ }
+ }
+ Set<String> keys = new HashSet<>();
+ int count = 0;
+ if (properties != null) {
+ keys.addAll(properties.keySet());
+ count += properties.size();
+ }
+ if (secretBindings != null) {
+ keys.addAll(secretBindings.keySet());
+ count += secretBindings.size();
+ }
+ if (secretReferences != null) {
+ keys.addAll(secretReferences.keySet());
+ count += secretReferences.size();
+ }
+ if (keys.size() != count) {
+ throw new IllegalArgumentException(
+ "Duplicate property key across properties, secretBindings and secretReferences");
+ }
+ }
+
+ /**
+ * Checks secret keys and puts reference / write-through URN strings into {@code
+ * targetProperties}.
+ *
+ * <p>Callers typically validate {@code targetProperties}, then call {@link #writeSecrets} with
+ * the returned secret materials, and {@link #rollbackSecrets} on failure. {@code properties} is
+ * used only for key uniqueness checks (e.g. the original request map); {@code targetProperties}
+ * is the mutable map that will be stored (may already contain merged catalog conf).
+ *
+ * @param properties properties used for key uniqueness checks (may be null)
+ * @param targetProperties mutable properties that receive URN values
+ * @param entityType {@code catalog}, {@code schema}, or {@code fileset}
+ * @param entityId stable numeric entity id
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ * @return write-through secret materials for {@link #writeSecrets} / {@link #rollbackSecrets}
+ * (empty when there are no bindings)
+ */
+ public List<SecretMaterial> assembleSecretMaterials(
Review Comment:
This name isn't good enough. We can't know you modify the properties. Could u give a better name for it?
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756117491
##########
core/src/main/java/org/apache/gravitino/secret/SecretMaterial.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.secret;
+
+import com.google.common.base.Preconditions;
+import java.util.Objects;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Write-through secret material: the target {@link SecretUrn} paired with the plaintext to store.
+ *
+ * <p>Produced by {@code SecretManager#assembleSecretUrns} and consumed by {@code
+ * SecretManager#writeSecrets} / {@code SecretManager#rollbackSecrets}.
+ */
+@Evolving
+public final class SecretMaterial {
Review Comment:
Got resovled.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3726603137
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretReferenceDTO.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretReference;
+
+/** Data transfer object for an external {@link SecretReference}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString
+public class SecretReferenceDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @Nullable
Review Comment:
Got resolved. The similar class has ben resolved too.
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretReferenceDTO.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretReference;
+
+/** Data transfer object for an external {@link SecretReference}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString
+public class SecretReferenceDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @Nullable
+ @JsonProperty("attributes")
+ private Map<String, String> attributes;
+
+ /**
+ * Converts this DTO to a {@link SecretReference}.
+ *
+ * @return the secret reference
+ */
+ public SecretReference toSecretReference() {
+ return new SecretReference(provider, attributes == null ? ImmutableMap.of() : attributes);
+ }
+
+ /**
+ * Creates a DTO from a {@link SecretReference}.
+ *
+ * @param reference the secret reference
+ * @return the secret reference DTO
+ */
+ public static SecretReferenceDTO fromSecretReference(SecretReference reference) {
+ return new SecretReferenceDTO(reference.provider(), reference.attributes());
+ }
+
+ /**
+ * Converts a property-key map of DTOs to {@link SecretReference}s.
+ *
+ * @param dtos property key → reference DTO; {@code null} returns {@code null}
+ * @return property key → reference, or {@code null}
+ */
+ @Nullable
+ public static Map<String, SecretReference> toSecretReferences(
+ @Nullable Map<String, SecretReferenceDTO> dtos) {
+ if (dtos == null) {
+ return null;
+ }
+ Map<String, SecretReference> references = new LinkedHashMap<>(dtos.size());
+ for (Map.Entry<String, SecretReferenceDTO> entry : dtos.entrySet()) {
+ references.put(entry.getKey(), entry.getValue().toSecretReference());
+ }
+ return references;
+ }
+
+ /**
+ * Converts a property-key map of {@link SecretReference}s to DTOs.
+ *
+ * @param references property key → reference; {@code null} returns {@code null}
+ * @return property key → reference DTO, or {@code null}
+ */
+ @Nullable
+ public static Map<String, SecretReferenceDTO> fromSecretReferences(
+ @Nullable Map<String, SecretReference> references) {
Review Comment:
Got resolved. The similar class has ben resolved too.
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretReferenceDTO.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretReference;
+
+/** Data transfer object for an external {@link SecretReference}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString
+public class SecretReferenceDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @Nullable
+ @JsonProperty("attributes")
+ private Map<String, String> attributes;
+
+ /**
+ * Converts this DTO to a {@link SecretReference}.
+ *
+ * @return the secret reference
+ */
+ public SecretReference toSecretReference() {
+ return new SecretReference(provider, attributes == null ? ImmutableMap.of() : attributes);
+ }
+
+ /**
+ * Creates a DTO from a {@link SecretReference}.
+ *
+ * @param reference the secret reference
+ * @return the secret reference DTO
+ */
+ public static SecretReferenceDTO fromSecretReference(SecretReference reference) {
+ return new SecretReferenceDTO(reference.provider(), reference.attributes());
+ }
+
+ /**
+ * Converts a property-key map of DTOs to {@link SecretReference}s.
+ *
+ * @param dtos property key → reference DTO; {@code null} returns {@code null}
+ * @return property key → reference, or {@code null}
+ */
+ @Nullable
+ public static Map<String, SecretReference> toSecretReferences(
+ @Nullable Map<String, SecretReferenceDTO> dtos) {
+ if (dtos == null) {
+ return null;
+ }
+ Map<String, SecretReference> references = new LinkedHashMap<>(dtos.size());
+ for (Map.Entry<String, SecretReferenceDTO> entry : dtos.entrySet()) {
+ references.put(entry.getKey(), entry.getValue().toSecretReference());
+ }
+ return references;
+ }
+
+ /**
+ * Converts a property-key map of {@link SecretReference}s to DTOs.
+ *
+ * @param references property key → reference; {@code null} returns {@code null}
+ * @return property key → reference DTO, or {@code null}
+ */
+ @Nullable
Review Comment:
Got resolved. The similar class has ben resolved too.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3718580676
##########
common/src/main/java/org/apache/gravitino/dto/requests/CatalogCreateRequest.java:
##########
@@ -54,6 +54,14 @@ public class CatalogCreateRequest implements RESTRequest {
@JsonProperty("properties")
private final Map<String, String> properties;
+ @Nullable
+ @JsonProperty("secretBindings")
+ private final Map<String, Map<String, String>> secretBindings;
Review Comment:
We should introduce a typed `SecretBinding` instead of representing the fixed `provider` + plaintext `value` structure as `Map<String, String>`. The request can then use `Map<String, SecretBinding>`, where the outer map key is the entity property name. Please also ensure that `SecretBinding.value` is redacted/excluded from `toString()`.
##########
common/src/main/java/org/apache/gravitino/dto/requests/CatalogCreateRequest.java:
##########
@@ -54,6 +54,14 @@ public class CatalogCreateRequest implements RESTRequest {
@JsonProperty("properties")
private final Map<String, String> properties;
+ @Nullable
+ @JsonProperty("secretBindings")
+ private final Map<String, Map<String, String>> secretBindings;
+
+ @Nullable
+ @JsonProperty("secretReferences")
+ private final Map<String, Map<String, String>> secretReferences;
Review Comment:
The same concern applies to `secretReferences`. Please model each entry as a typed `SecretReference` with an explicit `provider` and a `Map<String, String> attributes` field, instead of mixing the reserved provider key with provider-specific attributes in one string map.
##########
docs/open-api/catalogs.yaml:
##########
@@ -390,6 +390,27 @@ components:
default: { }
additionalProperties:
type: string
+ secretBindings:
+ type: object
+ description: >
+ Optional map of property key to write-through binding. Each binding must
+ include provider and value (plaintext). Persisted value becomes a URN.
+ nullable: true
+ additionalProperties:
Review Comment:
Please define reusable `SecretBinding` and `SecretReference` component schemas and reference them here and from the schema/fileset create requests. The current nested `additionalProperties` shape cannot express that `provider` and `value` are required, and generated clients will only expose untyped dictionaries.
##########
clients/client-python/gravitino/dto/requests/catalog_create_request.py:
##########
@@ -41,6 +41,12 @@ class CatalogCreateRequest(RESTRequest):
_properties: Optional[Dict[str, str]] = field(
metadata=config(field_name="properties")
)
+ _secret_bindings: Optional[Dict[str, Dict[str, str]]] = field(
Review Comment:
The Python API should expose the same typed models rather than `Dict[str, Dict[str, str]]`, for example `Dict[str, SecretBinding]` and `Dict[str, SecretReference]`. Since a binding contains plaintext, its `value` should also be excluded from/redacted in `repr`.
##########
api/src/main/java/org/apache/gravitino/secret/SecretConstants.java:
##########
@@ -37,5 +37,21 @@ public final class SecretConstants {
/** Write attribute: entity property key that holds the secret. */
public static final String ATTR_PROPERTY_KEY = "propertyKey";
+ /**
+ * Required key in each {@code secretBindings} / {@code secretReferences} map: registered provider
+ * instance name.
+ */
+ public static final String PROVIDER_KEY = "provider";
Review Comment:
If the request structures are modeled with `SecretBinding` and `SecretReference`, these request-shape magic keys should no longer be needed. In particular, `REFERENCE_PROVIDER_KEY` is only an alias and is currently unused. Provider-specific attribute maps can remain dynamic; only the fixed REST/API structure needs typed fields.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#issuecomment-5186830741
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|68.19% **`+0.72%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|76.22%|:green_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|49.3% **`-0.28%`**|: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.74% **`+11.78%`**|:green_circle:|
|catalog-glue|68.98% **`+1.91%`**|:green_circle:|
|catalog-hive|79.42% **`+2.41%`**|:green_circle:|
|catalog-jdbc-common|45.65% **`-11.08%`**|: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% **`+18.95%`**|:green_circle:|
|catalog-lakehouse-generic|59.18% **`-8.29%`**|:green_circle:|
|catalog-lakehouse-hudi|79.1% **`-2.89%`**|:green_circle:|
|catalog-lakehouse-iceberg|85.94% **`-2.0%`**|:green_circle:|
|catalog-lakehouse-paimon|84.25% **`-3.11%`**|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.48%|:green_circle:|
|client-java|78.29% **`+4.64%`**|:green_circle:|
|common|52.09% **`-0.19%`**|:green_circle:|
|core|83.14% **`-0.77%`**|: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-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|66.17% **`-0.84%`**|:green_circle:|
|lance-common|24.5%|:red_circle:|
|lance-rest-server|64.23%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|83.24%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|85.79% **`+0.88%`**|:green_circle:|
|server-common|76.45%|: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/74d3e8490c8bf969dcf31321efebdfc49f1bba25/api/src/main/java/org/apache/gravitino/SupportsCatalogs.java)|0.0%|:red_circle:|
||[SupportsSchemas.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/api/src/main/java/org/apache/gravitino/SupportsSchemas.java)|0.0%|:red_circle:|
||[FilesetCatalog.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/api/src/main/java/org/apache/gravitino/file/FilesetCatalog.java)|0.0%|:red_circle:|
||[SecretConstants.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/api/src/main/java/org/apache/gravitino/secret/SecretConstants.java)|0.0%|:red_circle:|
|catalog-fileset|[FilesetCatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/catalogs/catalog-fileset/src/main/java/org/apache/gravitino/catalog/fileset/FilesetCatalogOperations.java)|81.81%|:green_circle:|
|catalog-glue|[GlueCatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/catalogs/catalog-glue/src/main/java/org/apache/gravitino/catalog/glue/GlueCatalogOperations.java)|72.63%|:green_circle:|
|catalog-hive|[HiveCatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/catalogs/catalog-hive/src/main/java/org/apache/gravitino/catalog/hive/HiveCatalogOperations.java)|81.68%|:green_circle:|
|catalog-jdbc-common|[JdbcCatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/JdbcCatalogOperations.java)|5.66%|:red_circle:|
|catalog-kafka|[KafkaCatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/catalogs/catalog-kafka/src/main/java/org/apache/gravitino/catalog/kafka/KafkaCatalogOperations.java)|81.12%|:green_circle:|
|catalog-lakehouse-generic|[GenericCatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/GenericCatalogOperations.java)|27.87%|:red_circle:|
|catalog-lakehouse-hudi|[HudiCatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/catalogs/catalog-lakehouse-hudi/src/main/java/org/apache/gravitino/catalog/lakehouse/hudi/HudiCatalogOperations.java)|60.61%|:green_circle:|
|catalog-lakehouse-iceberg|[IcebergCatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergCatalogOperations.java)|78.64%|:green_circle:|
|catalog-lakehouse-paimon|[PaimonCatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/PaimonCatalogOperations.java)|71.5%|:green_circle:|
|client-java|[BaseSchemaCatalog.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/clients/client-java/src/main/java/org/apache/gravitino/client/BaseSchemaCatalog.java)|100.0%|:green_circle:|
||[FilesetCatalog.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/clients/client-java/src/main/java/org/apache/gravitino/client/FilesetCatalog.java)|100.0%|:green_circle:|
||[GravitinoMetalake.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoMetalake.java)|92.56%|:green_circle:|
||[GravitinoClient.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/clients/client-java/src/main/java/org/apache/gravitino/client/GravitinoClient.java)|71.95%|:green_circle:|
|common|[CatalogCreateRequest.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/common/src/main/java/org/apache/gravitino/dto/requests/CatalogCreateRequest.java)|75.0%|:green_circle:|
||[FilesetCreateRequest.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/common/src/main/java/org/apache/gravitino/dto/requests/FilesetCreateRequest.java)|0.0%|:red_circle:|
||[SchemaCreateRequest.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/common/src/main/java/org/apache/gravitino/dto/requests/SchemaCreateRequest.java)|0.0%|:red_circle:|
||[SecretProvider.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/common/src/main/java/org/apache/gravitino/secret/SecretProvider.java)|0.0%|:red_circle:|
|core|[SchemaNormalizeDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/catalog/SchemaNormalizeDispatcher.java)|100.0%|:green_circle:|
||[SupportsSchemas.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/connector/SupportsSchemas.java)|100.0%|:green_circle:|
||[FilesetEventDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/listener/FilesetEventDispatcher.java)|100.0%|:green_circle:|
||[OperationType.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java)|100.0%|:green_circle:|
||[SecretPropertyUtils.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/secret/SecretPropertyUtils.java)|100.0%|:green_circle:|
||[CompatibilityUtils.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java)|99.38%|:green_circle:|
||[SchemaEventDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/listener/SchemaEventDispatcher.java)|98.18%|:green_circle:|
||[CatalogEventDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/listener/CatalogEventDispatcher.java)|97.7%|:green_circle:|
||[AuditLog.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/audit/AuditLog.java)|97.62%|:green_circle:|
||[OperationDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/catalog/OperationDispatcher.java)|93.75%|:green_circle:|
||[SchemaHookDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/hook/SchemaHookDispatcher.java)|92.16%|:green_circle:|
||[FilesetNormalizeDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/catalog/FilesetNormalizeDispatcher.java)|90.91%|:green_circle:|
||[AccessControlEventDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/listener/AccessControlEventDispatcher.java)|88.21%|:green_circle:|
||[FilesetHookDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/hook/FilesetHookDispatcher.java)|85.29%|:green_circle:|
||[FilesetOperationDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/catalog/FilesetOperationDispatcher.java)|79.01%|:green_circle:|
||[SchemaOperationDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java)|78.87%|:green_circle:|
||[SecretManager.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/secret/SecretManager.java)|78.02%|:green_circle:|
||[CatalogManager.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java)|70.21%|:green_circle:|
||[BaseCatalog.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java)|63.08%|:green_circle:|
||[CatalogNormalizeDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/catalog/CatalogNormalizeDispatcher.java)|38.71%|:red_circle:|
||[CatalogHookDispatcher.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java)|37.04%|:red_circle:|
||[SupportsCatalogs.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/catalog/SupportsCatalogs.java)|33.33%|:red_circle:|
||[GravitinoEnv.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/GravitinoEnv.java)|30.95%|:red_circle:|
||[ManagedSchemaOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/core/src/main/java/org/apache/gravitino/catalog/ManagedSchemaOperations.java)|29.73%|:red_circle:|
|jobs|[BuiltInJobTemplateProvider.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/maintenance/jobs/src/main/java/org/apache/gravitino/maintenance/jobs/BuiltInJobTemplateProvider.java)|81.82%|:green_circle:|
||[IcebergRewriteDataFilesJob.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/maintenance/jobs/src/main/java/org/apache/gravitino/maintenance/jobs/iceberg/IcebergRewriteDataFilesJob.java)|62.34%|:green_circle:|
|server|[SchemaOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/server/src/main/java/org/apache/gravitino/server/web/rest/SchemaOperations.java)|100.0%|:green_circle:|
||[CatalogOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/server/src/main/java/org/apache/gravitino/server/web/rest/CatalogOperations.java)|99.06%|:green_circle:|
||[FilesetOperations.java](https://github.com/lasdf1234/gravitino/blob/74d3e8490c8bf969dcf31321efebdfc49f1bba25/server/src/main/java/org/apache/gravitino/server/web/rest/FilesetOperations.java)|85.85%|: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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734477714
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -699,6 +715,7 @@ public void testConnection(
}
Map<String, String> mergedConfig = buildCatalogConf(provider, properties);
+ Map<String, String> plaintextConfig = secretManager.toPlaintextProperties(mergedConfig);
Review Comment:
Got 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3747730633
##########
api/src/main/java/org/apache/gravitino/secret/SecretUrn.java:
##########
@@ -69,6 +69,22 @@ public List<String> identifierSegments() {
return identifierSegments;
}
+ /**
+ * Returns the property key encoded as the last identifier segment.
+ *
+ * <p>Gravitino secret URNs end with the entity property key that stores the URN (see {@link
+ * #buildWriteThrough}).
+ *
+ * @return the property key
+ * @throws IllegalArgumentException if this URN has no identifier segments
+ */
+ public String propertyKey() {
Review Comment:
This logic is weird. Why do we need to throw the exception after validating segments in the constructor 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3748120978
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -144,75 +234,155 @@ public List<SecretUrn> getSecretBindingUrns(
* Writes plaintext secrets from {@code secretBindings} values into the write-through providers
* for {@code secretUrns} (e.g. Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretUrns} must come from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}. On failure, already-written URNs are rolled back. When using {@link
+ * #assembleSecretUrns}, URN strings are already in properties; otherwise callers must put them
+ * themselves (e.g. via {@link SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * @param secretBindings property key → write-through binding (null or empty is a no-op)
+ * @param secretUrns write-through URNs from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}
*/
- public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
+ public void writeSecrets(
+ @Nullable Map<String, SecretBinding> secretBindings, @Nullable List<SecretUrn> secretUrns) {
Review Comment:
Yes, I agree. @nullable 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
Re: [PR] [#12297] feat(secret): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734474685
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretReferenceDTO.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretReference;
+
+/** Data transfer object for an external {@link SecretReference}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString
+public class SecretReferenceDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @Builder.Default
+ @JsonProperty("attributes")
+ private Map<String, String> attributes = ImmutableMap.of();
+
+ /**
+ * Converts this DTO to a {@link SecretReference}.
+ *
+ * @return the secret reference
+ */
+ public SecretReference toSecretReference() {
+ Map<String, String> attrs = attributes == null ? ImmutableMap.of() : attributes;
+ return new SecretReference(provider, attrs);
Review Comment:
Got. 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756098206
##########
api/src/main/java/org/apache/gravitino/secret/SecretMaterial.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.secret;
+
+import com.google.common.base.Preconditions;
+import java.util.Objects;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Write-through secret material: the target {@link SecretUrn} paired with the plaintext to store.
+ *
+ * <p>Produced by {@code SecretManager#assembleSecretUrns} and consumed by {@code
+ * SecretManager#writeSecrets} / {@code SecretManager#rollbackSecrets}.
+ */
+@Evolving
+public final class SecretMaterial {
+
+ private final SecretUrn urn;
+ private final String plaintext;
+
+ /**
+ * Creates secret material for a write-through secret.
+ *
+ * @param urn write-through URN (provider + entity locator)
+ * @param plaintext plaintext secret to write
+ */
+ public SecretMaterial(SecretUrn urn, String plaintext) {
Review Comment:
Yes, only in the SecretBinding scenario will SecretMaterial be used. This class will only be used the methods "deleteSecret" and "writeSecret" (and only in the context of SecretBinding).
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi merged PR #12366:
URL: https://github.com/apache/gravitino/pull/12366
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734476077
##########
clients/client-python/gravitino/api/secret.py:
##########
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from dataclasses import dataclass, field
+from typing import Dict
+
+
+@dataclass
+class SecretBinding:
+ """Write-through secret binding: provider instance name plus plaintext."""
+
+ provider: str
+ plaintext: str
+
+ def __repr__(self) -> str:
+ return f"SecretBinding(provider={self.provider!r}, plaintext=***)"
+
+
+@dataclass
+class SecretReference:
+ """External secret locator: provider instance name plus provider-specific attributes."""
+
+ provider: str
+ attributes: Dict[str, str] = field(default_factory=dict)
+
+ def __post_init__(self):
+ if not self.attributes:
+ raise ValueError("attributes must not be null or empty")
Review Comment:
Got 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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3728627156
##########
core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java:
##########
@@ -101,84 +108,119 @@ public NameIdentifier[] listSchemas(Namespace namespace) throws NoSuchCatalogExc
* @throws SchemaAlreadyExistsException If a schema with the same identifier already exists.
*/
@Override
- public Schema createSchema(NameIdentifier ident, String comment, Map<String, String> properties)
+ 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();
Review Comment:
Got. Use assembleSecretUrns.
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3725413571
##########
api/src/main/java/org/apache/gravitino/secret/SecretConstants.java:
##########
@@ -37,5 +37,21 @@ public final class SecretConstants {
/** Write attribute: entity property key that holds the secret. */
public static final String ATTR_PROPERTY_KEY = "propertyKey";
+ /**
+ * Required key in each {@code secretBindings} / {@code secretReferences} map: registered provider
+ * instance name.
+ */
+ public static final String PROVIDER_KEY = "provider";
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3754638481
##########
core/src/main/java/org/apache/gravitino/catalog/FilesetOperationDispatcher.java:
##########
@@ -143,45 +148,67 @@ public Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
+ // System entrance: normalize null secret maps to empty so SecretManager.writeSecrets can
Review Comment:
Could u put these code into the method `assembleSecretUrns` method? Could we reduce the code in the dispatcher? It will help review and code maintain.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#issuecomment-5248711549
> @mchades I want to call out one concern about defining rollback semantics here.
>
> For operations that involve external systems, rollback is not equivalent to a local transaction. If the create path has already touched an external catalog or an external table location, a rollback/drop cleanup may delete externally owned directories or partially created resources. In Gravitino we generally avoid destructive rollback for external dependencies unless the resource ownership is explicit and the cleanup is known to be safe.
>
> My suggestion is to keep the contract conservative:
>
> * perform validation before external side effects whenever possible;
> * do not promise generic rollback after external side effects;
> * only allow best-effort cleanup for resources that Gravitino definitely created and owns;
> * document any remaining partial-failure behavior explicitly.
>
> So I prefer to revert the rollback-oriented change and keep this as an explicit design point unless we agree on a safe ownership model.
I agree. Let's keep it as it is.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756127023
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -141,78 +242,153 @@ public List<SecretUrn> getSecretBindingUrns(
}
/**
- * Writes plaintext secrets from {@code secretBindings} values into the write-through providers
- * for {@code secretUrns} (e.g. Vault).
+ * Writes plaintext secrets into the write-through providers for each {@link SecretMaterial} (e.g.
+ * Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretMaterials} must come from {@link #assembleSecretUrns}. On failure,
+ * already-written URNs are rolled back. When using {@link #assembleSecretUrns}, URN strings are
+ * already in properties; otherwise callers must put them themselves (e.g. via {@link
+ * SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * @param secretMaterials write-through secret materials (empty is a no-op; must not be null)
*/
- public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
- validateSecretBindings(secretBindings);
+ public void writeSecrets(List<SecretMaterial> secretMaterials) {
Review Comment:
The scenario of secretBinding requires write secret because there is no encrypted data stored in the external secret manager system. Therefore, gravitino needs to write the secret information.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756141064
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -141,78 +242,153 @@ public List<SecretUrn> getSecretBindingUrns(
}
/**
- * Writes plaintext secrets from {@code secretBindings} values into the write-through providers
- * for {@code secretUrns} (e.g. Vault).
+ * Writes plaintext secrets into the write-through providers for each {@link SecretMaterial} (e.g.
+ * Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretMaterials} must come from {@link #assembleSecretUrns}. On failure,
+ * already-written URNs are rolled back. When using {@link #assembleSecretUrns}, URN strings are
+ * already in properties; otherwise callers must put them themselves (e.g. via {@link
+ * SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * @param secretMaterials write-through secret materials (empty is a no-op; must not be null)
*/
- public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
- validateSecretBindings(secretBindings);
+ public void writeSecrets(List<SecretMaterial> secretMaterials) {
Review Comment:
The logic isn't clear enough.
You can use similar steps
```
urns = buildSecretUrns(bindings)
putSecretUrnToProps(urns)
writeBindingServerUrns(materials)
```
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3747598966
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -144,75 +234,155 @@ public List<SecretUrn> getSecretBindingUrns(
* Writes plaintext secrets from {@code secretBindings} values into the write-through providers
* for {@code secretUrns} (e.g. Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretUrns} must come from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}. On failure, already-written URNs are rolled back. When using {@link
+ * #assembleSecretUrns}, URN strings are already in properties; otherwise callers must put them
+ * themselves (e.g. via {@link SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * @param secretBindings property key → write-through binding (null or empty is a no-op)
+ * @param secretUrns write-through URNs from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}
*/
- public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
+ public void writeSecrets(
+ @Nullable Map<String, SecretBinding> secretBindings, @Nullable List<SecretUrn> secretUrns) {
Review Comment:
You shouldn't mark this variable nullable and add a null value check. We shouldn't assume null value everywhere. We should try check value in the system entrance.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3747522538
##########
api/src/main/java/org/apache/gravitino/file/FilesetCatalog.java:
##########
@@ -105,6 +108,43 @@ default Fileset createFileset(
properties);
}
+ /**
+ * Create a fileset metadata with a default location and optional create-time secrets.
+ *
+ * @param ident A fileset identifier.
+ * @param comment The comment of the fileset.
+ * @param type The type of the fileset.
+ * @param storageLocation The storage location of the fileset.
+ * @param properties The properties of the fileset.
+ * @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 fileset metadata
+ * @throws NoSuchSchemaException If the schema does not exist.
+ * @throws FilesetAlreadyExistsException If the fileset already exists.
+ */
+ default Fileset createFileset(
+ NameIdentifier ident,
+ String comment,
+ Fileset.Type type,
+ String storageLocation,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
Review Comment:
Why do we need a map here? Should it be a list here?
Map seems not clear enough?
--
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734484821
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretBindingDTO.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretBinding;
+
+/** Data transfer object for a write-through {@link SecretBinding}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString(exclude = "plaintext")
+public class SecretBindingDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @JsonProperty("plaintext")
+ private String plaintext;
+
+ /**
+ * Converts this DTO to a {@link SecretBinding}.
+ *
+ * @return the secret binding
+ */
+ public SecretBinding toSecretBinding() {
+ return new SecretBinding(provider, plaintext);
+ }
+
+ /**
+ * Creates a DTO from a {@link SecretBinding}.
+ *
+ * @param binding the secret binding
+ * @return the secret binding DTO
+ */
+ public static SecretBindingDTO fromSecretBinding(SecretBinding binding) {
+ return new SecretBindingDTO(binding.provider(), binding.plaintext());
+ }
+
+ /**
+ * Converts a property-key map of DTOs to {@link SecretBinding}s.
+ *
+ * @param dtos property key → binding DTO; {@code null} or empty returns an empty map
+ * @return property key → binding (never {@code null})
+ */
+ public static Map<String, SecretBinding> toSecretBindings(
+ @Nullable Map<String, SecretBindingDTO> dtos) {
+ if (dtos == null || dtos.isEmpty()) {
+ return ImmutableMap.of();
+ }
+ ImmutableMap.Builder<String, SecretBinding> bindings = ImmutableMap.builder();
+ for (Map.Entry<String, SecretBindingDTO> entry : dtos.entrySet()) {
+ bindings.put(entry.getKey(), entry.getValue().toSecretBinding());
+ }
Review Comment:
Got 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): Support secretBindings/secretReferences on create [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3734488698
##########
core/src/main/java/org/apache/gravitino/catalog/CatalogManager.java:
##########
@@ -593,12 +596,20 @@ 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 {
NameIdentifier metalakeIdent = NameIdentifier.of(ident.namespace().levels());
- Map<String, String> mergedConfig = buildCatalogConf(provider, properties);
+ final Map<String, String> mergedConfig = new HashMap<>(buildCatalogConf(provider, properties));
long uid = idGenerator.nextId();
+
+ List<SecretUrn> secretUrns =
+ secretManager.assembleSecretUrns(
+ properties, mergedConfig, "catalog", uid, secretBindings, secretReferences);
+ secretManager.writeSecrets(secretBindings, secretUrns);
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): Support secretBindings/secretReferences on create [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3725735461
##########
common/src/main/java/org/apache/gravitino/dto/secret/SecretReferenceDTO.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.secret;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.ImmutableMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import org.apache.gravitino.secret.SecretReference;
+
+/** Data transfer object for an external {@link SecretReference}. */
+@Getter
+@EqualsAndHashCode
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+@AllArgsConstructor
+@Builder(setterPrefix = "with")
+@ToString
+public class SecretReferenceDTO {
+
+ @JsonProperty("provider")
+ private String provider;
+
+ @Nullable
+ @JsonProperty("attributes")
+ private Map<String, String> attributes;
+
+ /**
+ * Converts this DTO to a {@link SecretReference}.
+ *
+ * @return the secret reference
+ */
+ public SecretReference toSecretReference() {
+ return new SecretReference(provider, attributes == null ? ImmutableMap.of() : attributes);
+ }
+
+ /**
+ * Creates a DTO from a {@link SecretReference}.
+ *
+ * @param reference the secret reference
+ * @return the secret reference DTO
+ */
+ public static SecretReferenceDTO fromSecretReference(SecretReference reference) {
+ return new SecretReferenceDTO(reference.provider(), reference.attributes());
+ }
+
+ /**
+ * Converts a property-key map of DTOs to {@link SecretReference}s.
+ *
+ * @param dtos property key → reference DTO; {@code null} returns {@code null}
+ * @return property key → reference, or {@code null}
+ */
+ @Nullable
+ public static Map<String, SecretReference> toSecretReferences(
+ @Nullable Map<String, SecretReferenceDTO> dtos) {
+ if (dtos == null) {
+ return null;
+ }
+ Map<String, SecretReference> references = new LinkedHashMap<>(dtos.size());
+ for (Map.Entry<String, SecretReferenceDTO> entry : dtos.entrySet()) {
+ references.put(entry.getKey(), entry.getValue().toSecretReference());
+ }
+ return references;
+ }
+
+ /**
+ * Converts a property-key map of {@link SecretReference}s to DTOs.
+ *
+ * @param references property key → reference; {@code null} returns {@code null}
+ * @return property key → reference DTO, or {@code null}
+ */
+ @Nullable
Review Comment:
Could we avoid null value?
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3755074615
##########
core/src/main/java/org/apache/gravitino/hook/SchemaHookDispatcher.java:
##########
@@ -91,7 +98,8 @@ public Schema createSchema(NameIdentifier ident, String comment, Map<String, Str
// ancestor's owner is never overwritten.
List<NameIdentifier> newAncestors = findMissingAncestors(normalizedIdent);
- Schema schema = dispatcher.createSchema(ident, comment, properties);
+ Schema schema =
+ dispatcher.createSchema(ident, comment, properties, secretBindings, secretReferences);
Review Comment:
The latest discussion is that this should remain as it is.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756020730
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -144,75 +234,154 @@ public List<SecretUrn> getSecretBindingUrns(
* Writes plaintext secrets from {@code secretBindings} values into the write-through providers
* for {@code secretUrns} (e.g. Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretUrns} must come from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}. On failure, already-written URNs are rolled back. When using {@link
+ * #assembleSecretUrns}, URN strings are already in properties; otherwise callers must put them
+ * themselves (e.g. via {@link SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * <p>Callers must pass non-null maps/lists (use empty collections when there are no secrets).
+ * Null checking belongs at the system entrance before invoking this method.
+ *
+ * @param secretBindings property key → write-through binding (empty is a no-op)
+ * @param secretUrns write-through URNs from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}
*/
public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
+ Preconditions.checkArgument(secretBindings != null, "secretBindings must not be null");
+ Preconditions.checkArgument(secretUrns != null, "secretUrns must not be null");
+ if (secretBindings.isEmpty()) {
+ Preconditions.checkArgument(
+ secretUrns.isEmpty(), "secretUrns must be empty when bindings are empty");
+ return;
+ }
+ Preconditions.checkArgument(!secretUrns.isEmpty(), "secretUrns must not be empty");
validateSecretBindings(secretBindings);
List<SecretUrn> written = new ArrayList<>(secretUrns.size());
try {
for (SecretUrn urn : secretUrns) {
List<String> segments = urn.identifierSegments();
- Preconditions.checkArgument(
- segments.size() == 3,
- "Write-through secret URN must have entityType, entityId, propertyKey segments: %s",
- urn);
+ if (segments.size() != 3) {
+ throw new IllegalArgumentException(
+ "Write-through secret URN must have entityType, entityId, propertyKey segments: "
+ + urn);
+ }
String entityType = segments.get(0);
String entityId = segments.get(1);
- String propertyKey = segments.get(2);
+ String propertyKey = urn.propertyKey();
SecretBinding binding = secretBindings.get(propertyKey);
- Preconditions.checkArgument(
- binding != null, "No secretBindings entry for property key \"%s\"", propertyKey);
- String plaintext = binding.plaintext();
+ if (binding == null) {
Review Comment:
Got resolved.
##########
core/src/main/java/org/apache/gravitino/catalog/FilesetOperationDispatcher.java:
##########
@@ -143,45 +148,67 @@ public Fileset createMultipleLocationFileset(
String comment,
Fileset.Type type,
Map<String, String> storageLocations,
- Map<String, String> properties)
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
+ Map<String, SecretReference> secretReferences)
throws NoSuchSchemaException, FilesetAlreadyExistsException {
+ // System entrance: normalize null secret maps to empty so SecretManager.writeSecrets can
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756046549
##########
api/src/main/java/org/apache/gravitino/secret/SecretMaterial.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.secret;
+
+import com.google.common.base.Preconditions;
+import java.util.Objects;
+import org.apache.gravitino.annotation.Evolving;
+
+/**
+ * Write-through secret material: the target {@link SecretUrn} paired with the plaintext to store.
+ *
+ * <p>Produced by {@code SecretManager#assembleSecretUrns} and consumed by {@code
+ * SecretManager#writeSecrets} / {@code SecretManager#rollbackSecrets}.
+ */
+@Evolving
+public final class SecretMaterial {
Review Comment:
Could u put this class into core module? This is necessary to expose to users.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3756174570
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -63,20 +66,116 @@ public SecretProviderRegistry getRegistry() {
return registry;
}
+ /**
+ * Ensures each property key appears at most once across {@code properties}, {@code
+ * secretBindings}, and {@code secretReferences}, and that {@code properties} do not contain raw
+ * secret URN values.
+ *
+ * <p>{@code null} maps are treated as empty. Callers must bind/reference secrets via the typed
+ * maps rather than embedding {@code urn:gravitino-secret:} values in properties.
+ *
+ * @param properties entity properties from the create request (may be null)
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ */
+ public void checkSecretKeys(
+ @Nullable Map<String, String> properties,
+ @Nullable Map<String, SecretBinding> secretBindings,
+ @Nullable Map<String, SecretReference> secretReferences) {
+ // Reject raw URNs in request properties: they bypass typed secretBindings/secretReferences
+ // and can be used to resolve another entity's secret.
+ if (properties != null && !properties.isEmpty()) {
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ String key = entry.getKey();
+ String value = entry.getValue();
+ if (SecretPropertyUtils.isSecretProperty(key, value)) {
+ throw new IllegalArgumentException(
+ "Property \""
+ + key
+ + "\" must not contain a raw gravitino secret URN; use secretBindings or"
+ + " secretReferences instead");
+ }
+ }
+ }
+ Set<String> keys = new HashSet<>();
+ int count = 0;
+ if (properties != null) {
+ keys.addAll(properties.keySet());
+ count += properties.size();
+ }
+ if (secretBindings != null) {
+ keys.addAll(secretBindings.keySet());
+ count += secretBindings.size();
+ }
+ if (secretReferences != null) {
+ keys.addAll(secretReferences.keySet());
+ count += secretReferences.size();
+ }
+ if (keys.size() != count) {
+ throw new IllegalArgumentException(
+ "Duplicate property key across properties, secretBindings and secretReferences");
+ }
+ }
+
+ /**
+ * Checks secret keys and puts reference / write-through URN strings into {@code
+ * targetProperties}.
+ *
+ * <p>Callers typically validate {@code targetProperties}, then call {@link #writeSecrets} with
+ * the returned secret materials, and {@link #rollbackSecrets} on failure. {@code properties} is
+ * used only for key uniqueness checks (e.g. the original request map); {@code targetProperties}
+ * is the mutable map that will be stored (may already contain merged catalog conf).
+ *
+ * @param properties properties used for key uniqueness checks (may be null)
+ * @param targetProperties mutable properties that receive URN values
+ * @param entityType {@code catalog}, {@code schema}, or {@code fileset}
+ * @param entityId stable numeric entity id
+ * @param secretBindings property key → write-through binding (may be null)
+ * @param secretReferences property key → secret locator (may be null)
+ * @return write-through secret materials for {@link #writeSecrets} / {@link #rollbackSecrets}
+ * (empty when there are no bindings)
+ */
+ public List<SecretMaterial> assembleSecretUrns(
+ @Nullable Map<String, String> properties,
+ Map<String, String> targetProperties,
+ String entityType,
+ long entityId,
+ @Nullable Map<String, SecretBinding> secretBindings,
+ @Nullable Map<String, SecretReference> secretReferences) {
+ checkSecretKeys(properties, secretBindings, secretReferences);
+ Map<String, SecretBinding> bindings = secretBindings == null ? Map.of() : secretBindings;
+ Map<String, SecretReference> references =
+ secretReferences == null ? Map.of() : secretReferences;
+ SecretPropertyUtils.putSecretUrns(targetProperties, getSecretReferenceUrns(references));
+ List<SecretUrn> bindingUrns = getSecretBindingUrns(entityType, entityId, bindings);
+ List<SecretMaterial> secretMaterials = new ArrayList<>(bindingUrns.size());
+ for (SecretUrn urn : bindingUrns) {
+ String propertyKey = urn.propertyKey();
+ SecretBinding binding = bindings.get(propertyKey);
+ Preconditions.checkArgument(
+ binding != null, "No secretBindings entry for property key \"%s\"", propertyKey);
+ secretMaterials.add(new SecretMaterial(urn, binding.plaintext()));
+ }
+ SecretPropertyUtils.putSecretUrns(targetProperties, bindingUrns);
+ return List.copyOf(secretMaterials);
+ }
+
/**
* Builds external-reference URNs from {@code secretReferences} without writing secret material.
*
* <p>Callers must put the returned URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}). External-ref URNs are owned outside Gravitino and must
- * not be passed to {@link #rollbackWritten}.
+ * SecretPropertyUtils#putSecretUrns}). External-ref URNs are owned outside Gravitino and must not
+ * be passed to {@link #rollbackSecrets}.
*
- * @param secretReferences property key → secret locator
+ * @param secretReferences property key → secret locator (empty returns an empty list; must not be
+ * null)
* @return external-reference URNs (insertion order)
*/
public List<SecretUrn> getSecretReferenceUrns(Map<String, SecretReference> secretReferences) {
Review Comment:
buildSecretReferenceUrns.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3754651322
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -144,75 +234,154 @@ public List<SecretUrn> getSecretBindingUrns(
* Writes plaintext secrets from {@code secretBindings} values into the write-through providers
* for {@code secretUrns} (e.g. Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretUrns} must come from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}. On failure, already-written URNs are rolled back. When using {@link
+ * #assembleSecretUrns}, URN strings are already in properties; otherwise callers must put them
+ * themselves (e.g. via {@link SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * <p>Callers must pass non-null maps/lists (use empty collections when there are no secrets).
+ * Null checking belongs at the system entrance before invoking this method.
+ *
+ * @param secretBindings property key → write-through binding (empty is a no-op)
+ * @param secretUrns write-through URNs from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}
*/
public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
+ Preconditions.checkArgument(secretBindings != null, "secretBindings must not be null");
+ Preconditions.checkArgument(secretUrns != null, "secretUrns must not be null");
+ if (secretBindings.isEmpty()) {
+ Preconditions.checkArgument(
+ secretUrns.isEmpty(), "secretUrns must be empty when bindings are empty");
+ return;
+ }
+ Preconditions.checkArgument(!secretUrns.isEmpty(), "secretUrns must not be empty");
validateSecretBindings(secretBindings);
List<SecretUrn> written = new ArrayList<>(secretUrns.size());
try {
for (SecretUrn urn : secretUrns) {
List<String> segments = urn.identifierSegments();
- Preconditions.checkArgument(
- segments.size() == 3,
- "Write-through secret URN must have entityType, entityId, propertyKey segments: %s",
- urn);
+ if (segments.size() != 3) {
+ throw new IllegalArgumentException(
+ "Write-through secret URN must have entityType, entityId, propertyKey segments: "
+ + urn);
+ }
String entityType = segments.get(0);
String entityId = segments.get(1);
- String propertyKey = segments.get(2);
+ String propertyKey = urn.propertyKey();
SecretBinding binding = secretBindings.get(propertyKey);
- Preconditions.checkArgument(
- binding != null, "No secretBindings entry for property key \"%s\"", propertyKey);
- String plaintext = binding.plaintext();
+ if (binding == null) {
Review Comment:
You should use `checkArgument` 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3747873223
##########
api/src/main/java/org/apache/gravitino/file/FilesetCatalog.java:
##########
@@ -105,6 +108,43 @@ default Fileset createFileset(
properties);
}
+ /**
+ * Create a fileset metadata with a default location and optional create-time secrets.
+ *
+ * @param ident A fileset identifier.
+ * @param comment The comment of the fileset.
+ * @param type The type of the fileset.
+ * @param storageLocation The storage location of the fileset.
+ * @param properties The properties of the fileset.
+ * @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 fileset metadata
+ * @throws NoSuchSchemaException If the schema does not exist.
+ * @throws FilesetAlreadyExistsException If the fileset already exists.
+ */
+ default Fileset createFileset(
+ NameIdentifier ident,
+ String comment,
+ Fileset.Type type,
+ String storageLocation,
+ Map<String, String> properties,
+ Map<String, SecretBinding> secretBindings,
Review Comment:
Thank you very much for you suggestions.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3748113657
##########
core/src/main/java/org/apache/gravitino/secret/SecretManager.java:
##########
@@ -144,75 +234,155 @@ public List<SecretUrn> getSecretBindingUrns(
* Writes plaintext secrets from {@code secretBindings} values into the write-through providers
* for {@code secretUrns} (e.g. Vault).
*
- * <p>{@code secretUrns} must come from {@link #getSecretBindingUrns}. On failure, already-written
- * URNs are rolled back. Callers must put URN strings into properties themselves (e.g. via {@link
- * SecretPropertyUtils#applySecretUrns}).
+ * <p>{@code secretUrns} must come from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}. On failure, already-written URNs are rolled back. When using {@link
+ * #assembleSecretUrns}, URN strings are already in properties; otherwise callers must put them
+ * themselves (e.g. via {@link SecretPropertyUtils#putSecretUrns}).
*
- * @param secretBindings property key → write-through binding
- * @param secretUrns write-through URNs from {@link #getSecretBindingUrns}
+ * @param secretBindings property key → write-through binding (null or empty is a no-op)
+ * @param secretUrns write-through URNs from {@link #assembleSecretUrns} or {@link
+ * #getSecretBindingUrns}
*/
- public void writeSecrets(Map<String, SecretBinding> secretBindings, List<SecretUrn> secretUrns) {
- Preconditions.checkArgument(
- secretBindings != null && !secretBindings.isEmpty(),
- "secretBindings must not be null or empty");
- Preconditions.checkArgument(
- secretUrns != null && !secretUrns.isEmpty(), "secretUrns must not be null or empty");
+ public void writeSecrets(
+ @Nullable Map<String, SecretBinding> secretBindings, @Nullable List<SecretUrn> secretUrns) {
+ if (secretBindings == null || secretBindings.isEmpty()) {
Review Comment:
Thank you very much for your suggestion. The 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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#discussion_r3749279800
##########
common/src/main/java/org/apache/gravitino/dto/requests/FilesetCreateRequest.java:
##########
@@ -64,6 +67,36 @@ public class FilesetCreateRequest implements RESTRequest {
@JsonProperty("properties")
private Map<String, String> properties;
+ @Nullable
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ @JsonProperty("secretBindings")
+ private Map<String, SecretBindingDTO> secretBindings;
+
+ @Nullable
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ @JsonProperty("secretReferences")
+ private Map<String, SecretReferenceDTO> secretReferences;
+
+ /**
+ * Constructor for FilesetCreateRequest without secret maps.
+ *
+ * @param name The name of the fileset.
+ * @param comment The comment of the fileset.
+ * @param type The type of the fileset.
+ * @param storageLocation The storage location of the fileset.
+ * @param storageLocations The storage locations of the fileset.
+ * @param properties The properties of the fileset.
+ */
+ public FilesetCreateRequest(
+ String name,
+ String comment,
+ Fileset.Type type,
+ String storageLocation,
+ Map<String, String> storageLocations,
+ Map<String, String> properties) {
+ this(name, comment, type, storageLocation, storageLocations, properties, null, null);
Review Comment:
Yes, I agree. Use Empty collections instead.
--
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): Support fileset create-time secretBindings/secretReferences [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on PR #12366:
URL: https://github.com/apache/gravitino/pull/12366#issuecomment-5239980373
@lasdf1234 I want to call out one concern about defining rollback semantics here.
For operations that involve external systems, rollback is not equivalent to a local transaction. If the create path has already touched an external catalog or an external table location, a rollback/drop cleanup may delete externally owned directories or partially created resources. In Gravitino we generally avoid destructive rollback for external dependencies unless the resource ownership is explicit and the cleanup is known to be safe.
My suggestion is to keep the contract conservative:
- perform validation before external side effects whenever possible;
- do not promise generic rollback after external side effects;
- only allow best-effort cleanup for resources that Gravitino definitely created and owns;
- document any remaining partial-failure behavior explicitly.
So I prefer to revert the rollback-oriented change and keep this as an explicit design point unless we agree on a safe ownership model.
--
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