Skip to content

Commit 5427715

Browse files
authored
[AMORO-4063] Fix missing S3 AK/SK in Apache Paimon format (#4064)
1 parent 75f3a60 commit 5427715

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

amoro-common/src/main/java/org/apache/amoro/table/TableMetaStore.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ public class TableMetaStore implements Serializable {
127127
private final boolean disableAuth;
128128
private final String accessKey;
129129
private final String secretKey;
130+
private final String storageType;
130131

131132
private transient RuntimeContext runtimeContext;
132133
private transient String authInformation;
@@ -146,6 +147,7 @@ private TableMetaStore(
146147
String krbPrincipal,
147148
String accessKey,
148149
String secretKey,
150+
String storageType,
149151
boolean disableAuth) {
150152
Preconditions.checkArgument(
151153
authMethod == null
@@ -165,6 +167,7 @@ private TableMetaStore(
165167
this.disableAuth = disableAuth;
166168
this.accessKey = accessKey;
167169
this.secretKey = secretKey;
170+
this.storageType = storageType;
168171
}
169172

170173
private TableMetaStore(Configuration configuration) {
@@ -179,6 +182,7 @@ private TableMetaStore(Configuration configuration) {
179182
this.krbPrincipal = null;
180183
this.accessKey = null;
181184
this.secretKey = null;
185+
this.storageType = null;
182186
this.runtimeContext = new RuntimeContext();
183187
runtimeContext.setConfiguration(configuration);
184188
}
@@ -219,6 +223,10 @@ public String getSecretKey() {
219223
return secretKey;
220224
}
221225

226+
public String getStorageType() {
227+
return storageType;
228+
}
229+
222230
public boolean isKerberosAuthMethod() {
223231
return AUTH_METHOD_KERBEROS.equalsIgnoreCase(authMethod);
224232
}
@@ -586,6 +594,7 @@ public static class Builder {
586594
private String krbPrincipal;
587595
private String accessKey;
588596
private String secretKey;
597+
private String storageType;
589598
private boolean disableAuth = true;
590599
private final Map<String, String> properties = Maps.newHashMap();
591600
private Configuration configuration;
@@ -640,11 +649,12 @@ public Builder withBase64CoreSite(String encodedCoreSite) {
640649
return this;
641650
}
642651

643-
public Builder withAkSkAuth(String accessKey, String secretKey) {
652+
public Builder withAkSkAuth(String accessKey, String secretKey, String storageType) {
644653
this.disableAuth = false;
645654
this.authMethod = AUTH_METHOD_AK_SK;
646655
this.accessKey = accessKey;
647656
this.secretKey = secretKey;
657+
this.storageType = storageType;
648658
return this;
649659
}
650660

@@ -785,6 +795,7 @@ public TableMetaStore build() {
785795
} else if (AUTH_METHOD_AK_SK.equals(authMethod)) {
786796
Preconditions.checkNotNull(accessKey);
787797
Preconditions.checkNotNull(secretKey);
798+
Preconditions.checkNotNull(storageType);
788799
} else if (authMethod != null) {
789800
throw new IllegalArgumentException("Unsupported auth method:" + authMethod);
790801
}
@@ -805,6 +816,7 @@ public TableMetaStore build() {
805816
krbPrincipal,
806817
accessKey,
807818
secretKey,
819+
storageType,
808820
disableAuth);
809821
}
810822
}

amoro-common/src/main/java/org/apache/amoro/utils/CatalogUtil.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ public static TableMetaStore buildMetaStore(CatalogMeta catalogMeta) {
168168
authType)) {
169169
String accessKey = authConfigs.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_ACCESS_KEY);
170170
String secretKey = authConfigs.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_SECRET_KEY);
171-
builder.withAkSkAuth(accessKey, secretKey);
171+
String storageType =
172+
catalogMeta.getStorageConfigs().get(CatalogMetaProperties.STORAGE_CONFIGS_KEY_TYPE);
173+
builder.withAkSkAuth(accessKey, secretKey, storageType);
172174
}
173175
}
174176
}
@@ -204,7 +206,9 @@ public static TableMetaStore buildMetaStore(CatalogMeta catalogMeta) {
204206
catalogMeta
205207
.getCatalogProperties()
206208
.get(CatalogMetaProperties.AUTH_CONFIGS_KEY_SECRET_KEY);
207-
builder.withAkSkAuth(accessKey, secretKey);
209+
String storageType =
210+
catalogMeta.getStorageConfigs().get(CatalogMetaProperties.STORAGE_CONFIGS_KEY_TYPE);
211+
builder.withAkSkAuth(accessKey, secretKey, storageType);
208212
}
209213
}
210214
}

amoro-format-paimon/src/main/java/org/apache/amoro/formats/paimon/PaimonCatalogFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public PaimonCatalog create(
6363
HiveCatalogOptions.HIVE_CONF_DIR.key(), new File(url.getPath()).getParent()));
6464
if (CatalogMetaProperties.AUTH_CONFIGS_VALUE_TYPE_AK_SK.equalsIgnoreCase(
6565
metaStore.getAuthMethod())) {
66-
if (CatalogMetaProperties.STORAGE_CONFIGS_VALUE_TYPE_S3.equals(metastoreType)) {
66+
if (CatalogMetaProperties.STORAGE_CONFIGS_VALUE_TYPE_S3.equalsIgnoreCase(
67+
metaStore.getStorageType())) {
6768
// s3.access-key, s3.secret-key
6869
catalogProperties.put(PAIMON_S3_ACCESS_KEY, metaStore.getAccessKey());
6970
catalogProperties.put(PAIMON_S3_SECRET_KEY, metaStore.getSecretKey());

0 commit comments

Comments
 (0)