Skip to content

Commit

Permalink
HDDS-11580. Validate 'hdds.datanode.dir.du.reserved' property (apache…
Browse files Browse the repository at this point in the history
…#7328)

(cherry picked from commit 3f98df5)
  • Loading branch information
Daniilchik authored Oct 22, 2024
1 parent 8764a78 commit 70bb416
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.hadoop.ozone.container.common.volume;

import com.google.common.annotations.VisibleForTesting;
import org.apache.hadoop.hdds.conf.ConfigurationException;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.conf.StorageSize;
import org.apache.hadoop.hdds.conf.StorageUnit;
Expand Down Expand Up @@ -220,9 +221,8 @@ private static long getReserved(ConfigurationSource conf, String rootDir,
for (String reserve : reserveList) {
String[] words = reserve.split(":");
if (words.length < 2) {
LOG.error("Reserved space should be configured in a pair, but current value is {}",
reserve);
continue;
throw new ConfigurationException("hdds.datanode.dir.du.reserved - " +
"Reserved space should be configured in a pair, but current value is " + reserve);
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.hadoop.conf.StorageUnit;
import org.apache.hadoop.hdds.HddsConfigKeys;
import org.apache.hadoop.hdds.conf.ConfigurationException;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.fs.MockSpaceUsageCheckFactory;
import org.apache.hadoop.hdds.scm.ScmConfigKeys;
Expand All @@ -37,6 +38,7 @@
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_DATANODE_DIR_DU_RESERVED_PERCENT;
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_DATANODE_DIR_DU_RESERVED_PERCENT_DEFAULT;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

/**
Expand Down Expand Up @@ -166,6 +168,16 @@ public void testInvalidConfig() throws Exception {
assertEquals(getExpectedDefaultReserved(hddsVolume2), reservedFromVolume2);
}

@Test
public void testInvalidConfigThrowsException() {
OzoneConfiguration conf = new OzoneConfiguration();
conf.set(ScmConfigKeys.HDDS_DATANODE_DIR_DU_RESERVED, "15GB");

assertThrows(ConfigurationException.class,
() -> volumeBuilder.conf(conf).build(),
"Reserved space should be configured in a pair");
}

@Test
public void testPathsCanonicalized() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
Expand Down

0 comments on commit 70bb416

Please sign in to comment.