Skip to content

Commit 03714b7

Browse files
Cherry picks for "Adjustable limit on the number of locations per storage config" (apache#26)
* b93e97b * Adjustable limit on the number of locations per storage config (apache#1068) * initial commit * autolint * change the config store access * autolint * add support for 01 * autolint * fix test * autolint * retest * rebase * autolint * change the config store access * autolint * add support for 01 * autolint * fix test * autolint * retest * fix a test * autolint * fix another test * autolint * remove catalog config for now as it's not used * changes * autolint * update test to reflect -1 default * autolint * autolint * move the check * changes per review * ready * autolint * spotless --------- Co-authored-by: Eric Maynard <[email protected]>
1 parent e1dac66 commit 03714b7

File tree

47 files changed

+563
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+563
-280
lines changed

extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
import java.util.Objects;
3737
import java.util.stream.Stream;
3838
import org.apache.polaris.core.PolarisCallContext;
39-
import org.apache.polaris.core.PolarisConfigurationStore;
4039
import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
4140
import org.apache.polaris.core.PolarisDiagnostics;
41+
import org.apache.polaris.core.config.PolarisConfigurationStore;
4242
import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
4343
import org.apache.polaris.core.persistence.BasePolarisMetaStoreManagerTest;
4444
import org.apache.polaris.core.persistence.PolarisMetaStoreManagerImpl;

integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisApplicationIntegrationTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@
9494
/**
9595
* @implSpec This test expects the server to be configured with the following features configured:
9696
* <ul>
97-
* <li>{@link org.apache.polaris.core.PolarisConfiguration#ALLOW_OVERLAPPING_CATALOG_URLS}:
97+
* <li>{@link
98+
* org.apache.polaris.core.config.FeatureConfiguration#ALLOW_OVERLAPPING_CATALOG_URLS}:
9899
* {@code true}
99100
* <li>{@link
100-
* org.apache.polaris.core.PolarisConfiguration#SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION}:
101+
* org.apache.polaris.core.config.FeatureConfiguration#SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION}:
101102
* {@code true}
102103
* </ul>
103104
* The server must also be configured to reject request body sizes larger than 1MB (1000000

integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisManagementServiceIntegrationTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@
9090
* @implSpec @implSpec This test expects the server to be configured with the following features
9191
* configured:
9292
* <ul>
93-
* <li>{@link org.apache.polaris.core.PolarisConfiguration#ALLOW_OVERLAPPING_CATALOG_URLS}:
93+
* <li>{@link
94+
* org.apache.polaris.core.config.FeatureConfiguration#ALLOW_OVERLAPPING_CATALOG_URLS}:
9495
* {@code true}
9596
* <li>{@link
96-
* org.apache.polaris.core.PolarisConfiguration#ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING}:
97+
* org.apache.polaris.core.config.FeatureConfiguration#ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING}:
9798
* {@code true}
9899
* </ul>
99100
*/

integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import org.apache.iceberg.rest.RESTCatalog;
5959
import org.apache.iceberg.rest.responses.ErrorResponse;
6060
import org.apache.iceberg.types.Types;
61-
import org.apache.polaris.core.PolarisConfiguration;
6261
import org.apache.polaris.core.admin.model.AwsStorageConfigInfo;
6362
import org.apache.polaris.core.admin.model.Catalog;
6463
import org.apache.polaris.core.admin.model.CatalogGrant;
@@ -76,6 +75,8 @@
7675
import org.apache.polaris.core.admin.model.TablePrivilege;
7776
import org.apache.polaris.core.admin.model.ViewGrant;
7877
import org.apache.polaris.core.admin.model.ViewPrivilege;
78+
import org.apache.polaris.core.config.FeatureConfiguration;
79+
import org.apache.polaris.core.config.PolarisConfiguration;
7980
import org.apache.polaris.core.entity.CatalogEntity;
8081
import org.apache.polaris.core.entity.PolarisEntityConstants;
8182
import org.apache.polaris.service.it.env.CatalogApi;
@@ -449,7 +450,7 @@ public void testCreateTableWithOverriddenBaseLocation() {
449450
Catalog catalog = managementApi.getCatalog(currentCatalogName);
450451
Map<String, String> catalogProps = new HashMap<>(catalog.getProperties().toMap());
451452
catalogProps.put(
452-
PolarisConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "false");
453+
FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "false");
453454
managementApi.updateCatalog(catalog, catalogProps);
454455

455456
restCatalog.createNamespace(Namespace.of("ns1"));
@@ -477,7 +478,7 @@ public void testCreateTableWithOverriddenBaseLocationCannotOverlapSibling() {
477478
Catalog catalog = managementApi.getCatalog(currentCatalogName);
478479
Map<String, String> catalogProps = new HashMap<>(catalog.getProperties().toMap());
479480
catalogProps.put(
480-
PolarisConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "false");
481+
FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "false");
481482
managementApi.updateCatalog(catalog, catalogProps);
482483

483484
restCatalog.createNamespace(Namespace.of("ns1"));
@@ -514,7 +515,7 @@ public void testCreateTableWithOverriddenBaseLocationMustResideInNsDirectory() {
514515
Catalog catalog = managementApi.getCatalog(currentCatalogName);
515516
Map<String, String> catalogProps = new HashMap<>(catalog.getProperties().toMap());
516517
catalogProps.put(
517-
PolarisConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "false");
518+
FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "false");
518519
managementApi.updateCatalog(catalog, catalogProps);
519520

520521
restCatalog.createNamespace(Namespace.of("ns1"));
@@ -563,7 +564,7 @@ public void testLoadTableWithAccessDelegationForExternalCatalogWithConfigDisable
563564
.isInstanceOf(ForbiddenException.class)
564565
.hasMessageContaining("Access Delegation is not enabled for this catalog")
565566
.hasMessageContaining(
566-
PolarisConfiguration.ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING.catalogConfig());
567+
FeatureConfiguration.ALLOW_EXTERNAL_CATALOG_CREDENTIAL_VENDING.catalogConfig());
567568
} finally {
568569
resolvingFileIO.deleteFile(fileLocation);
569570
}

integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewIntegrationBase.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
import java.util.Map;
2525
import org.apache.iceberg.rest.RESTCatalog;
2626
import org.apache.iceberg.view.ViewCatalogTests;
27-
import org.apache.polaris.core.PolarisConfiguration;
2827
import org.apache.polaris.core.admin.model.Catalog;
2928
import org.apache.polaris.core.admin.model.CatalogProperties;
3029
import org.apache.polaris.core.admin.model.PolarisCatalog;
3130
import org.apache.polaris.core.admin.model.PrincipalWithCredentials;
3231
import org.apache.polaris.core.admin.model.StorageConfigInfo;
32+
import org.apache.polaris.core.config.FeatureConfiguration;
3333
import org.apache.polaris.core.entity.CatalogEntity;
3434
import org.apache.polaris.service.it.env.ClientCredentials;
3535
import org.apache.polaris.service.it.env.IcebergHelper;
@@ -50,8 +50,8 @@
5050
* client.
5151
*
5252
* @implSpec This test expects the server to be configured with {@link
53-
* org.apache.polaris.core.PolarisConfiguration#SUPPORTED_CATALOG_STORAGE_TYPES} set to the
54-
* appropriate storage type.
53+
* org.apache.polaris.core.config.FeatureConfiguration#SUPPORTED_CATALOG_STORAGE_TYPES} set to
54+
* the appropriate storage type.
5555
*/
5656
@ExtendWith(PolarisIntegrationTestExtension.class)
5757
public abstract class PolarisRestCatalogViewIntegrationBase extends ViewCatalogTests<RESTCatalog> {
@@ -99,9 +99,9 @@ public void before(TestInfo testInfo) {
9999
CatalogProperties.builder(defaultBaseLocation)
100100
.addProperty(
101101
CatalogEntity.REPLACE_NEW_LOCATION_PREFIX_WITH_CATALOG_DEFAULT_KEY, "file:")
102-
.addProperty(PolarisConfiguration.ALLOW_EXTERNAL_TABLE_LOCATION.catalogConfig(), "true")
102+
.addProperty(FeatureConfiguration.ALLOW_EXTERNAL_TABLE_LOCATION.catalogConfig(), "true")
103103
.addProperty(
104-
PolarisConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "true")
104+
FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "true")
105105
.build();
106106
Catalog catalog =
107107
PolarisCatalog.builder()

integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisSparkIntegrationTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@
6464
* @implSpec This test expects the server to be configured with the following features enabled:
6565
* <ul>
6666
* <li>{@link
67-
* org.apache.polaris.core.PolarisConfiguration#SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION}:
67+
* org.apache.polaris.core.config.FeatureConfiguration#SKIP_CREDENTIAL_SUBSCOPING_INDIRECTION}:
6868
* {@code true}
69-
* <li>{@link org.apache.polaris.core.PolarisConfiguration#ALLOW_OVERLAPPING_CATALOG_URLS}:
69+
* <li>{@link
70+
* org.apache.polaris.core.config.FeatureConfiguration#ALLOW_OVERLAPPING_CATALOG_URLS}:
7071
* {@code true}
7172
* </ul>
7273
*/

polaris-core/src/main/java/org/apache/polaris/core/PolarisCallContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import jakarta.annotation.Nonnull;
2222
import java.time.Clock;
2323
import java.time.ZoneId;
24+
import org.apache.polaris.core.config.PolarisConfigurationStore;
2425
import org.apache.polaris.core.persistence.PolarisMetaStoreSession;
2526

2627
/**

polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@
9898
import java.util.Set;
9999
import java.util.stream.Collectors;
100100
import org.apache.iceberg.exceptions.ForbiddenException;
101-
import org.apache.polaris.core.PolarisConfiguration;
102-
import org.apache.polaris.core.PolarisConfigurationStore;
101+
import org.apache.polaris.core.config.FeatureConfiguration;
102+
import org.apache.polaris.core.config.PolarisConfigurationStore;
103103
import org.apache.polaris.core.context.CallContext;
104104
import org.apache.polaris.core.entity.PolarisBaseEntity;
105105
import org.apache.polaris.core.entity.PolarisEntityConstants;
@@ -510,7 +510,7 @@ public void authorizeOrThrow(
510510
boolean enforceCredentialRotationRequiredState =
511511
featureConfig.getConfiguration(
512512
CallContext.getCurrentContext().getPolarisCallContext(),
513-
PolarisConfiguration.ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING);
513+
FeatureConfiguration.ENFORCE_PRINCIPAL_CREDENTIAL_ROTATION_REQUIRED_CHECKING);
514514
if (enforceCredentialRotationRequiredState
515515
&& authenticatedPrincipal
516516
.getPrincipalEntity()
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.core.config;
20+
21+
import java.util.Optional;
22+
23+
/**
24+
* Internal configuration flags for non-feature behavior changes in Polaris. These flags control
25+
* subtle behavior adjustments and bug fixes, not user-facing catalog settings. They are intended
26+
* for internal use only, are inherently unstable, and may be removed at any time. When introducing
27+
* a new flag, consider the trade-off between maintenance burden and the risk of an unguarded
28+
* behavior change. Flags here are generally short-lived and should either be removed or promoted to
29+
* stable feature flags before the next release.
30+
*
31+
* @param <T> The type of the configuration
32+
*/
33+
public class BehaviorChangeConfiguration<T> extends PolarisConfiguration<T> {
34+
35+
protected BehaviorChangeConfiguration(
36+
String key, String description, T defaultValue, Optional<String> catalogConfig) {
37+
super(key, description, defaultValue, catalogConfig);
38+
}
39+
40+
public static final BehaviorChangeConfiguration<Boolean> VALIDATE_VIEW_LOCATION_OVERLAP =
41+
PolarisConfiguration.<Boolean>builder()
42+
.key("STORAGE_CREDENTIAL_CACHE_DURATION_SECONDS")
43+
.description("If true, validate that view locations don't overlap when views are created")
44+
.defaultValue(true)
45+
.buildBehaviorChangeConfiguration();
46+
47+
public static final BehaviorChangeConfiguration<Integer> STORAGE_CONFIGURATION_MAX_LOCATIONS =
48+
PolarisConfiguration.<Integer>builder()
49+
.key("STORAGE_CONFIGURATION_MAX_LOCATIONS")
50+
.description(
51+
"How many locations can be associated with a storage configuration, or -1 for"
52+
+ " unlimited locations")
53+
.defaultValue(-1)
54+
.buildBehaviorChangeConfiguration();
55+
}

0 commit comments

Comments
 (0)