Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
import org.apache.hadoop.conf.ReconfigurationException;
import org.apache.hadoop.hdds.conf.ReconfigurationHandler;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ADMINISTRATORS;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_READONLY_ADMINISTRATORS;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_KEY_DELETING_LIMIT_PER_TASK;
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.junit.jupiter.api.Assertions.assertEquals;

/**
Expand All @@ -43,6 +47,7 @@ ReconfigurationHandler getSubject() {
void reconfigurableProperties() {
assertProperties(getSubject(),
ImmutableSet.of(OZONE_ADMINISTRATORS, OZONE_READONLY_ADMINISTRATORS,
OZONE_OM_VOLUME_LISTALL_ALLOWED,
OZONE_KEY_DELETING_LIMIT_PER_TASK));
}

Expand Down Expand Up @@ -81,4 +86,22 @@ public void keyDeletingLimitPerTask() throws ReconfigurationException {
.getKeyManager().getDeletingService().getKeyLimitPerTask());
}

@Test
void allowListAllVolumes() throws ReconfigurationException {
final boolean newValue = !getCluster().getOzoneManager().getAllowListAllVolumes();

getSubject().reconfigurePropertyImpl(OZONE_OM_VOLUME_LISTALL_ALLOWED,
String.valueOf(newValue));

assertEquals(newValue, getCluster().getOzoneManager().getAllowListAllVolumes());
}

@ParameterizedTest
@ValueSource(strings = {"", "invalid"})
void unsetAllowListAllVolumes(String newValue) throws ReconfigurationException {
getSubject().reconfigurePropertyImpl(OZONE_OM_VOLUME_LISTALL_ALLOWED, newValue);

assertEquals(OZONE_OM_VOLUME_LISTALL_ALLOWED_DEFAULT, getCluster().getOzoneManager().getAllowListAllVolumes());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ private OzoneManager(OzoneConfiguration conf, StartupOption startupOption)
.register(OZONE_ADMINISTRATORS, this::reconfOzoneAdmins)
.register(OZONE_READONLY_ADMINISTRATORS,
this::reconfOzoneReadOnlyAdmins)
.register(OZONE_OM_VOLUME_LISTALL_ALLOWED, this::reconfigureAllowListAllVolumes)
.register(OZONE_KEY_DELETING_LIMIT_PER_TASK,
this::reconfOzoneKeyDeletingLimitPerTask);

Expand Down Expand Up @@ -759,7 +760,11 @@ public String getThreadNamePrefix() {
private void setInstanceVariablesFromConf() {
this.isAclEnabled = configuration.getBoolean(OZONE_ACL_ENABLED,
OZONE_ACL_ENABLED_DEFAULT);
this.allowListAllVolumes = configuration.getBoolean(
setAllowListAllVolumesFromConfig();
}

public void setAllowListAllVolumesFromConfig() {
allowListAllVolumes = configuration.getBoolean(
OZONE_OM_VOLUME_LISTALL_ALLOWED,
OZONE_OM_VOLUME_LISTALL_ALLOWED_DEFAULT);
}
Expand Down Expand Up @@ -4978,6 +4983,12 @@ private String reconfOzoneKeyDeletingLimitPerTask(String newVal) {
return newVal;
}

private String reconfigureAllowListAllVolumes(String newVal) {
getConfiguration().set(OZONE_OM_VOLUME_LISTALL_ALLOWED, newVal);
setAllowListAllVolumesFromConfig();
return String.valueOf(allowListAllVolumes);
}

public void validateReplicationConfig(ReplicationConfig replicationConfig)
throws OMException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static OzoneNativeAuthorizer configure(
authorizer.setPrefixManager(pm);
authorizer.setAdminCheck(om::isAdmin);
authorizer.setReadOnlyAdminCheck(om::isReadOnlyAdmin);
authorizer.setAllowListAllVolumes(om.getAllowListAllVolumes());
authorizer.setAllowListAllVolumes(om::getAllowListAllVolumes);
return authorizer;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.slf4j.LoggerFactory;

import java.util.Objects;
import java.util.function.BooleanSupplier;
import java.util.function.Predicate;

import static org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.INVALID_REQUEST;
Expand All @@ -54,7 +55,7 @@ public class OzoneNativeAuthorizer implements IAccessAuthorizer {
private PrefixManager prefixManager;
private Predicate<UserGroupInformation> adminCheck = NO_ADMIN;
private Predicate<UserGroupInformation> readOnlyAdminCheck = NO_ADMIN;
private boolean allowListAllVolumes;
private BooleanSupplier allowListAllVolumes = () -> false;

public OzoneNativeAuthorizer() {
// required for instantiation in OmMetadataReader#getACLAuthorizerInstance
Expand Down Expand Up @@ -222,12 +223,12 @@ public void setReadOnlyAdminCheck(Predicate<UserGroupInformation> check) {
readOnlyAdminCheck = Objects.requireNonNull(check, "read-only admin check");
}

public void setAllowListAllVolumes(boolean allowListAllVolumes) {
this.allowListAllVolumes = allowListAllVolumes;
public void setAllowListAllVolumes(BooleanSupplier allowListAllVolumes) {
this.allowListAllVolumes = Objects.requireNonNull(allowListAllVolumes, "allowListAllVolumes");
}

public boolean getAllowListAllVolumes() {
return allowListAllVolumes;
return allowListAllVolumes.getAsBoolean();
}

private static boolean isOwner(UserGroupInformation ugi, String ownerName) {
Expand Down