This is an automated email from the ASF dual-hosted git repository.
diqiu50 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 1dbd1d8b8b [#14351] fix(flink-connector): Give Paimon's OSSFileIO its
fs.oss.* options back (#14352)
1dbd1d8b8b is described below
commit 1dbd1d8b8b209edb6fc38a600845b4c7513f8cd2
Author: dengc367 <[email protected]>
AuthorDate: Mon Nov 16 15:10:04 2026 +0800
[#14351] fix(flink-connector): Give Paimon's OSSFileIO its fs.oss.* options
back (#14352)
### What changes were proposed in this pull request?
`GravitinoPaimonCatalog#open()` now copies the `fs.oss.*` entries of the
Hadoop `Configuration`
back into the inner Paimon catalog's option map after
`movePaimonStorageOptionsToConf` has moved
them out.
Paimon's `OSSFileIO` builds its Hadoop configuration only from
`CatalogContext#options()` and
never reads `CatalogContext#hadoopConf()`, so those entries have to be
visible in both places.
Only the `fs.oss.` prefix is copied, and only when the warehouse uses
the `oss://` scheme; every
other filesystem keeps using the Hadoop configuration and the
connector's own option map does not
gain the keys back.
### Why are the changes needed?
Fixes #14351
Without this, a Paimon catalog backed by Aliyun OSS cannot be opened
through the Flink connector:
`OSSFileIO` reports `Aliyun OSS endpoint should not be null or empty`
because the endpoint and
credentials were moved to a place it does not read.
### Does this PR introduce _any_ user-facing change?
No API change and no new property key. Paimon catalogs on OSS start
working again; catalogs on
HDFS, S3 and local storage are unaffected.
### How was this patch tested?
- Added assertions to `TestGravitinoPaimonCatalog` covering the OSS
option hand-off; it runs for
every supported Flink version (1.19, 1.20, 2.1, 2.2).
`./gradlew :flink-connector:flink-2.2:test --tests
"*TestGravitinoPaimonCatalog*"`
- `./gradlew :flink-connector:flink-common:spotlessCheck`
- Manually against a real OSS warehouse on Flink 2.2.1: create catalog,
create a primary-key
table, upsert, read back, drop.
---------
Co-authored-by: 刘存玉 <[email protected]>
---
.../connector/paimon/GravitinoPaimonCatalog.java | 40 ++++++++++++++++++++--
.../paimon/TestGravitinoPaimonCatalog.java | 35 +++++++++++++++++--
2 files changed, 70 insertions(+), 5 deletions(-)
diff --git
a/flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/paimon/GravitinoPaimonCatalog.java
b/flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/paimon/GravitinoPaimonCatalog.java
index 8b1de42206..a0551abe68 100644
---
a/flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/paimon/GravitinoPaimonCatalog.java
+++
b/flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/paimon/GravitinoPaimonCatalog.java
@@ -87,10 +87,13 @@ public abstract class GravitinoPaimonCatalog extends
BaseCatalog {
private static final String HADOOP_S3_ENDPOINT = "fs.s3a.endpoint";
private static final String HADOOP_S3_ACCESS_KEY = "fs.s3a.access.key";
private static final String HADOOP_S3_SECRET_KEY = "fs.s3a.secret.key";
+ private static final String OSS_OPTION_PREFIX = "fs.oss.";
+ private static final String OSS_WAREHOUSE_SCHEME = "oss://";
private final CatalogFactory.Context context;
// Mutable copy shared with BaseCatalog.catalogOptions. The inner Paimon
catalog is created from a
- // sanitized copy so Hadoop-prefixed options can be moved to Hadoop
configuration before logging.
+ // copy so Hadoop-prefixed options can be moved to Hadoop configuration
before logging. For OSS
+ // warehouses that copy keeps the fs.oss.* entries, because Paimon's
OSSFileIO only reads options.
private final Map<String, String> mutableOptions;
private AbstractCatalog paimonCatalog;
@@ -155,14 +158,17 @@ public abstract class GravitinoPaimonCatalog extends
BaseCatalog {
e);
}
movePaimonStorageOptionsToConf(paimonOptions, hadoopConf);
+ copyOssOptionsBackToPaimonOptions(hadoopConf, paimonOptions);
this.paimonCatalog = createInnerCatalog(paimonOptions, hadoopConf);
super.open();
}
/**
- * Creates the inner Paimon Flink catalog from sanitized Paimon options and
Hadoop configuration.
+ * Creates the inner Paimon Flink catalog from Paimon options and Hadoop
configuration.
*
- * @param paimonOptions Paimon catalog options without Hadoop-prefixed
sensitive properties.
+ * @param paimonOptions Paimon catalog options without Hadoop-prefixed
properties, except for OSS
+ * warehouses where {@code fs.oss.*} is kept because Paimon's OSSFileIO
does not read the
+ * Hadoop configuration.
* @param hadoopConf Hadoop configuration carrying filesystem credentials
and Hadoop options.
* @return the created inner Paimon catalog.
*/
@@ -197,6 +203,34 @@ public abstract class GravitinoPaimonCatalog extends
BaseCatalog {
paimonOptions, hadoopConf, PaimonConstants.OSS_SECRET_KEY,
PaimonConstants.OSS_SECRET_KEY);
}
+ /**
+ * Paimon's OSSFileIO (paimon-oss 1.x) builds its Hadoop configuration only
from the catalog
+ * options and never reads the Hadoop configuration, so after the move above
the OSS endpoint and
+ * keys would be invisible to it ("Aliyun OSS endpoint should not be null or
empty"). Hand those
+ * entries back to the inner catalog's options; they stay out of this
connector's own option map.
+ *
+ * <p>Only OSS warehouses get the entries back. For HDFS, S3 and local
warehouses the entries live
+ * in the Hadoop configuration alone, so OSS settings that come from {@code
core-site.xml} under
+ * {@code HADOOP_CONF_DIR} are not copied into Paimon options that Paimon
may log.
+ */
+ @VisibleForTesting
+ static void copyOssOptionsBackToPaimonOptions(
+ Configuration hadoopConf, Map<String, String> paimonOptions) {
+ String warehouse = paimonOptions.get(PaimonConstants.WAREHOUSE);
+ if (warehouse == null
+ || !warehouse.regionMatches(
+ true, 0, OSS_WAREHOUSE_SCHEME, 0, OSS_WAREHOUSE_SCHEME.length())) {
+ return;
+ }
+ // extractHadoopConfiguration and the move above already removed every
fs.* key, so no
+ // catalog-level value can be overwritten here.
+ for (Map.Entry<String, String> entry : hadoopConf) {
+ if (entry.getKey().startsWith(OSS_OPTION_PREFIX)) {
+ paimonOptions.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
private static void moveOptionToHadoopConf(
Map<String, String> paimonOptions,
Configuration hadoopConf,
diff --git
a/flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/paimon/TestGravitinoPaimonCatalog.java
b/flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/paimon/TestGravitinoPaimonCatalog.java
index 519b2c33a0..979a3cd703 100644
---
a/flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/paimon/TestGravitinoPaimonCatalog.java
+++
b/flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/paimon/TestGravitinoPaimonCatalog.java
@@ -547,6 +547,12 @@ public abstract class TestGravitinoPaimonCatalog {
Assertions.assertFalse(
catalog.capturedOptions.containsKey("hadoop." +
PaimonConstants.OSS_SECRET_KEY));
Assertions.assertFalse(catalog.capturedOptions.containsKey("hadoop.fs.oss.endpoint"));
+ // Paimon's OSSFileIO reads fs.oss.* only from catalog options, so they
must reach it there.
+ Assertions.assertEquals("oss-endpoint",
catalog.capturedOptions.get("fs.oss.endpoint"));
+ Assertions.assertEquals(
+ "catalog-access-key",
catalog.capturedOptions.get(PaimonConstants.OSS_ACCESS_KEY));
+ Assertions.assertEquals(
+ "catalog-secret-key",
catalog.capturedOptions.get(PaimonConstants.OSS_SECRET_KEY));
Assertions.assertFalse(catalog.capturedOptions.containsKey("fs.bos.access.key"));
Assertions.assertFalse(catalog.capturedOptions.containsKey("fs.bos.secret.access.key"));
Assertions.assertEquals(
@@ -559,6 +565,29 @@ public abstract class TestGravitinoPaimonCatalog {
"bos-secret-key",
catalog.capturedHadoopConf.get("fs.bos.secret.access.key"));
}
+ /** Verifies that fs.oss.* options stay out of Paimon options for non-OSS
warehouses. */
+ @Test
+ public void testOpenKeepsOssOptionsOutOfPaimonOptionsForNonOssWarehouse() {
+ Catalog mockCatalog = catalogWithCredentials();
+ Map<String, String> options = new HashMap<>();
+ options.put("warehouse", "s3://bucket/path");
+ options.put("hadoop." + PaimonConstants.OSS_ACCESS_KEY, "oss-access-key");
+ options.put("hadoop." + PaimonConstants.OSS_SECRET_KEY, "oss-secret-key");
+ options.put("hadoop.fs.oss.endpoint", "oss-endpoint");
+
+ CapturingPaimonCatalog catalog = new CapturingPaimonCatalog(options,
mockCatalog);
+ catalog.open();
+
+
Assertions.assertFalse(catalog.capturedOptions.containsKey(PaimonConstants.OSS_ACCESS_KEY));
+
Assertions.assertFalse(catalog.capturedOptions.containsKey(PaimonConstants.OSS_SECRET_KEY));
+
Assertions.assertFalse(catalog.capturedOptions.containsKey("fs.oss.endpoint"));
+ Assertions.assertEquals(
+ "oss-access-key",
catalog.capturedHadoopConf.get(PaimonConstants.OSS_ACCESS_KEY));
+ Assertions.assertEquals(
+ "oss-secret-key",
catalog.capturedHadoopConf.get(PaimonConstants.OSS_SECRET_KEY));
+ Assertions.assertEquals("oss-endpoint",
catalog.capturedHadoopConf.get("fs.oss.endpoint"));
+ }
+
/** Verifies that vended filesystem credentials are moved to Hadoop
configuration. */
@Test
public void testOpenMovesStorageCredentialsToHadoopConf() {
@@ -578,8 +607,10 @@ public abstract class TestGravitinoPaimonCatalog {
Assertions.assertFalse(catalog.capturedOptions.containsKey(PaimonConstants.S3_ACCESS_KEY));
Assertions.assertFalse(catalog.capturedOptions.containsKey(PaimonConstants.S3_SECRET_KEY));
-
Assertions.assertFalse(catalog.capturedOptions.containsKey(PaimonConstants.OSS_ACCESS_KEY));
-
Assertions.assertFalse(catalog.capturedOptions.containsKey(PaimonConstants.OSS_SECRET_KEY));
+ // Vended OSS keys win over stale catalog values and are handed to
Paimon's OSSFileIO.
+ Assertions.assertEquals("oss-key",
catalog.capturedOptions.get(PaimonConstants.OSS_ACCESS_KEY));
+ Assertions.assertEquals(
+ "oss-secret",
catalog.capturedOptions.get(PaimonConstants.OSS_SECRET_KEY));
Assertions.assertEquals("s3-key",
catalog.capturedHadoopConf.get("fs.s3a.access.key"));
Assertions.assertEquals("s3-secret",
catalog.capturedHadoopConf.get("fs.s3a.secret.key"));
Assertions.assertEquals(