Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-12303. Move ozone.om.user.max.volume into OmConfig #8082

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions hadoop-hdds/common/src/main/resources/ozone-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -650,18 +650,6 @@
allow group public LIST access.
</description>
</property>
<property>
<name>ozone.om.user.max.volume</name>
<value>1024</value>
<tag>OM, MANAGEMENT</tag>
<description>
The maximum number of volumes a user can have on a cluster.Increasing or
decreasing this number has no real impact on ozone cluster. This is
defined only for operational purposes. Only an administrator can create a
volume, once a volume is created there are no restrictions on the number
of buckets or keys inside each bucket a user can create.
</description>
</property>
<property>
<name>ozone.om.db.dirs</name>
<value/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ private OMConfigKeys() {
public static final String OZONE_OM_VOLUME_LISTALL_ALLOWED =
"ozone.om.volume.listall.allowed";
public static final boolean OZONE_OM_VOLUME_LISTALL_ALLOWED_DEFAULT = true;
public static final String OZONE_OM_USER_MAX_VOLUME =
"ozone.om.user.max.volume";
public static final int OZONE_OM_USER_MAX_VOLUME_DEFAULT = 1024;

public static final String OZONE_KEY_DELETING_LIMIT_PER_TASK =
"ozone.key.deleting.limit.per.task";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.hadoop.ozone.om;

import com.google.common.base.Preconditions;
import org.apache.hadoop.hdds.conf.Config;
import org.apache.hadoop.hdds.conf.ConfigGroup;
import org.apache.hadoop.hdds.conf.ConfigTag;
Expand Down Expand Up @@ -54,6 +55,18 @@ public class OmConfig extends ReconfigurableConfig {
)
private long maxListSize;

@Config(
key = "user.max.volume",
defaultValue = "1024",
description = "The maximum number of volumes a user can have on a cluster.Increasing or " +
"decreasing this number has no real impact on ozone cluster. This is " +
"defined only for operational purposes. Only an administrator can create a " +
"volume, once a volume is created there are no restrictions on the number " +
"of buckets or keys inside each bucket a user can create.",
tags = { ConfigTag.OM, ConfigTag.MANAGEMENT }
)
private int maxUserVolumeCount;

public boolean isFileSystemPathEnabled() {
return fileSystemPathEnabled;
}
Expand All @@ -71,11 +84,23 @@ public void setMaxListSize(long newValue) {
validate();
}

public int getMaxUserVolumeCount() {
return maxUserVolumeCount;
}

public void setMaxUserVolumeCount(int newValue) {
maxUserVolumeCount = newValue;
validate();
}

@PostConstruct
public void validate() {
if (maxListSize <= 0) {
maxListSize = Defaults.SERVER_LIST_MAX_SIZE;
}

Preconditions.checkArgument(this.maxUserVolumeCount > 0,
Keys.USER_MAX_VOLUME + " value should be greater than zero");
}

public OmConfig copy() {
Expand All @@ -87,6 +112,7 @@ public OmConfig copy() {
public void setFrom(OmConfig other) {
fileSystemPathEnabled = other.fileSystemPathEnabled;
maxListSize = other.maxListSize;
maxUserVolumeCount = other.maxUserVolumeCount;
}

/**
Expand All @@ -95,6 +121,7 @@ public void setFrom(OmConfig other) {
public static final class Keys {
public static final String ENABLE_FILESYSTEM_PATHS = "ozone.om.enable.filesystem.paths";
public static final String SERVER_LIST_MAX_SIZE = "ozone.om.server.list.max.size";
public static final String USER_MAX_VOLUME = "ozone.om.user.max.volume";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.apache.hadoop.hdds.conf.MutableConfigurationSource;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
Expand Down Expand Up @@ -52,6 +53,14 @@ void overridesInvalidListSize(long invalidValue) {
.isEqualTo(OmConfig.Defaults.SERVER_LIST_MAX_SIZE);
}

@Test
void throwsOnInvalidMaxUserVolume() {
MutableConfigurationSource conf = new OzoneConfiguration();
conf.setInt(OmConfig.Keys.USER_MAX_VOLUME, 0);

assertThrows(IllegalArgumentException.class, () -> conf.getObject(OmConfig.class));
}

@Test
void testCopy() {
MutableConfigurationSource conf = new OzoneConfiguration();
Expand All @@ -69,6 +78,7 @@ void testSetFrom() {
OmConfig updated = conf.getObject(OmConfig.class);
updated.setFileSystemPathEnabled(!updated.isFileSystemPathEnabled());
updated.setMaxListSize(updated.getMaxListSize() + 1);
updated.setMaxUserVolumeCount(updated.getMaxUserVolumeCount() + 1);

subject.setFrom(updated);

Expand All @@ -78,6 +88,7 @@ void testSetFrom() {
private static void assertConfigEquals(OmConfig expected, OmConfig actual) {
assertEquals(expected.getMaxListSize(), actual.getMaxListSize());
assertEquals(expected.isFileSystemPathEnabled(), actual.isFileSystemPathEnabled());
assertEquals(expected.getMaxUserVolumeCount(), actual.getMaxUserVolumeCount());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_READ_THREADPOOL_KEY;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_S3_GPRC_SERVER_ENABLED;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_S3_GRPC_SERVER_ENABLED_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_USER_MAX_VOLUME;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_USER_MAX_VOLUME_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_VOLUME_LISTALL_ALLOWED;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_VOLUME_LISTALL_ALLOWED_DEFAULT;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_SERVER_DEFAULT_REPLICATION_DEFAULT;
Expand Down Expand Up @@ -438,9 +436,6 @@ public final class OzoneManager extends ServiceRuntimeInfoImpl
private final ReplicationConfigValidator replicationConfigValidator;

private boolean allowListAllVolumes;
// Adding parameters needed for VolumeRequests here, so that during request
// execution, we can get from ozoneManager.
private final long maxUserVolumeCount;

private int minMultipartUploadPartSize = OzoneConsts.OM_MULTIPART_MIN_SIZE;

Expand Down Expand Up @@ -549,10 +544,6 @@ private OzoneManager(OzoneConfiguration conf, StartupOption startupOption)
this.threadPrefix = omNodeDetails.threadNamePrefix();
loginOMUserIfSecurityEnabled(conf);
setInstanceVariablesFromConf();
this.maxUserVolumeCount = conf.getInt(OZONE_OM_USER_MAX_VOLUME,
OZONE_OM_USER_MAX_VOLUME_DEFAULT);
Preconditions.checkArgument(this.maxUserVolumeCount > 0,
OZONE_OM_USER_MAX_VOLUME + " value should be greater than zero");

if (omStorage.getState() != StorageState.INITIALIZED) {
throw new OMException("OM not initialized, current OM storage state: "
Expand Down Expand Up @@ -4206,7 +4197,7 @@ public String getComponent() {
* @return maxUserVolumeCount
*/
public long getMaxUserVolumeCount() {
return maxUserVolumeCount;
return config.getMaxUserVolumeCount();
}
/**
* Return true, if the current OM node is leader and in ready state to
Expand Down