This is an automated email from the ASF dual-hosted git repository.

DomGarguilo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new 718d3cf01c Validate properties on load/upgrade instead of on read 
(#6648)
718d3cf01c is described below

commit 718d3cf01c31bfc0360e1313179e74ce27d1bb14
Author: Dom G. <[email protected]>
AuthorDate: Mon Nov 16 13:21:21 2026 -0500

    Validate properties on load/upgrade instead of on read (#6648)
    
    * Validate properties on load/upgrade instead of on read
    * Add test for resource group config validation on load
    
    Co-Authored-By: Claude Opus 5.5
---
 .../accumulo/core/conf/SiteConfiguration.java      | 11 ++--------
 .../server/conf/ResourceGroupConfiguration.java    | 16 +--------------
 .../server/conf/ServerConfigurationFactory.java    |  4 +++-
 .../accumulo/server/conf/SystemConfiguration.java  | 16 +--------------
 .../conf/ServerConfigurationFactoryTest.java       | 24 ++++++++++++++++++++++
 .../server/conf/ZooBasedConfigurationTest.java     |  3 ++-
 .../manager/upgrade/UpgradeCoordinator.java        |  8 +++++++-
 7 files changed, 40 insertions(+), 42 deletions(-)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java 
b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
index aac3f3ecc3..34b870997f 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
@@ -252,15 +252,8 @@ public class SiteConfiguration extends 
AccumuloConfiguration {
 
   @Override
   public String get(Property property) {
-    String value = config.get(property.getKey());
-    if (value == null || !property.getType().isValidFormat(value)) {
-      if (value != null) {
-        log.error("Using default value for {} due to improperly formatted {}: 
{}",
-            property.getKey(), property.getType(), value);
-      }
-      value = parent.get(property);
-    }
-    return value;
+    final String value = config.get(property.getKey());
+    return value != null ? value : parent.get(property);
   }
 
   @Override
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/conf/ResourceGroupConfiguration.java
 
b/server/base/src/main/java/org/apache/accumulo/server/conf/ResourceGroupConfiguration.java
index edd1c6fd9e..3aa3eb4bc0 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/conf/ResourceGroupConfiguration.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/conf/ResourceGroupConfiguration.java
@@ -42,21 +42,7 @@ public class ResourceGroupConfiguration extends 
ZooBasedConfiguration {
     if (Property.isFixedZooPropertyKey(property)) {
       return runtimeFixedProps.get(property);
     }
-
-    String key = property.getKey();
-    String value = null;
-    if (Property.isValidZooPropertyKey(key)) {
-      value = getSnapshot().get(key);
-    }
-
-    if (value == null || !property.getType().isValidFormat(value)) {
-      if (value != null) {
-        LOG.error("Using parent value for {} due to improperly formatted {}: 
{}", key,
-            property.getType(), value);
-      }
-      value = getParent().get(property);
-    }
-    return value;
+    return super.get(property);
   }
 
   @Override
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
 
b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
index 8c9e7c3cf9..1d1674203e 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
@@ -89,8 +89,10 @@ public class ServerConfigurationFactory extends 
ServerConfiguration {
       return sysConf;
     });
     this.resourceGroupConfig = memoize(() -> {
-      return new ResourceGroupConfiguration(context, 
ResourceGroupPropKey.of(rgid),
+      var rgConf = new ResourceGroupConfiguration(context, 
ResourceGroupPropKey.of(rgid),
           (SystemConfiguration) getSystemConfiguration());
+      ConfigCheckUtil.validate(rgConf, "resource group config: " + rgid);
+      return rgConf;
     });
     tableParentConfigs =
         Caches.getInstance().createNewBuilder(CacheName.TABLE_PARENT_CONFIGS, 
false)
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/conf/SystemConfiguration.java
 
b/server/base/src/main/java/org/apache/accumulo/server/conf/SystemConfiguration.java
index c30c7b6b83..9a22957702 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/conf/SystemConfiguration.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/conf/SystemConfiguration.java
@@ -43,21 +43,7 @@ public class SystemConfiguration extends 
ZooBasedConfiguration {
     if (Property.isFixedZooPropertyKey(property)) {
       return runtimeFixedProps.get(property);
     }
-
-    String key = property.getKey();
-    String value = null;
-    if (Property.isValidZooPropertyKey(key)) {
-      value = getSnapshot().get(key);
-    }
-
-    if (value == null || !property.getType().isValidFormat(value)) {
-      if (value != null) {
-        log.error("Using parent value for {} due to improperly formatted {}: 
{}", key,
-            property.getType(), value);
-      }
-      value = getParent().get(property);
-    }
-    return value;
+    return super.get(property);
   }
 
   @Override
diff --git 
a/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java
 
b/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java
index d7a0343afa..33a8e4af7d 100644
--- 
a/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java
+++ 
b/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java
@@ -28,11 +28,14 @@ import static org.easymock.EasyMock.verify;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.accumulo.core.conf.ConfigCheckUtil.ConfigCheckException;
 import org.apache.accumulo.core.conf.DefaultConfiguration;
+import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.conf.SiteConfiguration;
 import org.apache.accumulo.core.data.InstanceId;
 import org.apache.accumulo.core.data.NamespaceId;
@@ -129,4 +132,25 @@ public class ServerConfigurationFactoryTest {
     assertSame(tableConfigSingleton, scf.getTableConfiguration(TID));
   }
 
+  @Test
+  public void testInvalidResourceGroupConfigFailsOnLoad() {
+    PropStore badPropStore = createMock(ZooPropStore.class);
+    expect(badPropStore.get(eq(SystemPropKey.of()))).andReturn(new 
VersionedProperties(Map.of()))
+        .anyTimes();
+    expect(badPropStore.get(eq(ResourceGroupPropKey.DEFAULT)))
+        .andReturn(new 
VersionedProperties(Map.of(Property.TSERV_MAXMEM.getKey(), "notAMemSize")))
+        .anyTimes();
+    badPropStore.registerAsListener(anyObject(), anyObject());
+    expectLastCall().anyTimes();
+
+    ServerContext badContext = createMock(ServerContext.class);
+    expect(badContext.getPropStore()).andReturn(badPropStore).anyTimes();
+    expect(badContext.getSiteConfiguration()).andReturn(siteConfig).anyTimes();
+    replay(badPropStore, badContext);
+
+    var badScf = new ServerConfigurationFactory(badContext, siteConfig, 
ResourceGroupId.DEFAULT);
+    assertThrows(ConfigCheckException.class, 
badScf::getResourceGroupConfiguration,
+        "invalid resource group property should fail when the config is 
loaded");
+  }
+
 }
diff --git 
a/server/base/src/test/java/org/apache/accumulo/server/conf/ZooBasedConfigurationTest.java
 
b/server/base/src/test/java/org/apache/accumulo/server/conf/ZooBasedConfigurationTest.java
index 8855da58da..19f8ee803e 100644
--- 
a/server/base/src/test/java/org/apache/accumulo/server/conf/ZooBasedConfigurationTest.java
+++ 
b/server/base/src/test/java/org/apache/accumulo/server/conf/ZooBasedConfigurationTest.java
@@ -129,7 +129,8 @@ public class ZooBasedConfigurationTest {
     ZooBasedConfiguration configuration = new SystemConfiguration(context, 
sysPropKey, siteConfig);
 
     assertNotNull(configuration);
-    assertEquals("1G", configuration.get(TABLE_SPLIT_THRESHOLD));
+    assertEquals("int expected", configuration.get(TABLE_SPLIT_THRESHOLD),
+        "stored value should be returned without validation on read");
     assertEquals("true", configuration.get(TABLE_BLOOM_ENABLED));
   }
 
diff --git 
a/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java
 
b/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java
index 186a53e299..fb927065ad 100644
--- 
a/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java
+++ 
b/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java
@@ -36,8 +36,10 @@ import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
 import org.apache.accumulo.core.client.NamespaceNotFoundException;
+import org.apache.accumulo.core.client.ResourceGroupNotFoundException;
 import org.apache.accumulo.core.client.TableNotFoundException;
 import org.apache.accumulo.core.conf.ConfigCheckUtil;
+import org.apache.accumulo.core.data.ResourceGroupId;
 import org.apache.accumulo.core.metadata.schema.Ample;
 import org.apache.accumulo.core.util.threads.ThreadPools;
 import org.apache.accumulo.core.volume.Volume;
@@ -322,8 +324,12 @@ public class UpgradeCoordinator {
         
ConfigCheckUtil.validate(context.tableOperations().getTableProperties(table).entrySet(),
             table + " table configuration");
       }
+      for (ResourceGroupId rg : context.resourceGroupOperations().list()) {
+        
ConfigCheckUtil.validate(context.resourceGroupOperations().getProperties(rg).entrySet(),
+            rg + " resource group configuration");
+      }
     } catch (AccumuloException | AccumuloSecurityException | 
NamespaceNotFoundException
-        | TableNotFoundException e) {
+        | TableNotFoundException | ResourceGroupNotFoundException e) {
       throw new IllegalStateException("Error checking properties", e);
     }
     try {

Reply via email to