Skip to content

Commit

Permalink
HDDS-11378. Allow disabling OM version-specific feature via config (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
adoroszlai authored Aug 29, 2024
1 parent 23f3e5b commit 3e9cdb6
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ private OMConfigKeys() {
public static final String OZONE_OM_DECOMMISSIONED_NODES_KEY =
"ozone.om.decommissioned.nodes";

public static final String OZONE_OM_FEATURES_DISABLED =
"ozone.om.features.disabled";

public static final String OZONE_OM_ADDRESS_KEY =
"ozone.om.address";
public static final String OZONE_OM_BIND_HOST_DEFAULT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ OZONE-SITE.XML_hdds.datanode.volume.min.free.space=100MB
OZONE-SITE.XML_ozone.recon.address=recon:9891
OZONE-SITE.XML_hdds.scmclient.max.retry.timeout=30s
OZONE-SITE.XML_ozone.http.basedir=/tmp/ozone_http
OZONE-SITE.XML_ozone.om.features.disabled=ATOMIC_REWRITE_KEY

HADOOP_OPTS="-Dhadoop.opts=test"
HDFS_STORAGECONTAINERMANAGER_OPTS="-Dhdfs.scm.opts=test"
Expand Down
5 changes: 5 additions & 0 deletions hadoop-ozone/dist/src/main/smoketest/compatibility/om.robot
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ Picks up command line options
${processes} = List All Processes
Should Contain ${processes} %{HDFS_OM_OPTS}
Should Contain ${processes} %{HADOOP_OPTS}

Rejects Atomic Key Rewrite
Execute ozone freon ockg -n1 -t1 -p rewrite
${output} = Execute and check rc ozone sh key rewrite -t EC -r rs-3-2-1024k /vol1/bucket1/rewrite/0 255
Should Contain ${output} Feature disabled: ATOMIC_REWRITE_KEY
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private void addPropertiesNotInXml() {
OMConfigKeys.OZONE_FS_TRASH_INTERVAL_KEY,
OMConfigKeys.OZONE_FS_TRASH_CHECKPOINT_INTERVAL_KEY,
OMConfigKeys.OZONE_OM_S3_GPRC_SERVER_ENABLED,
OMConfigKeys.OZONE_OM_FEATURES_DISABLED,
OzoneConfigKeys.OZONE_ACL_AUTHORIZER_CLASS_NATIVE,
OzoneConfigKeys.OZONE_CLIENT_REQUIRED_OM_VERSION_MIN_KEY,
OzoneConfigKeys.OZONE_RECOVERING_CONTAINER_SCRUBBING_SERVICE_WORKERS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5008,4 +5008,11 @@ public void awaitDoubleBufferFlush() throws InterruptedException {
getOmServerProtocol().awaitDoubleBufferFlush();
}
}

public void checkFeatureEnabled(OzoneManagerVersion feature) throws OMException {
String disabledFeatures = configuration.get(OMConfigKeys.OZONE_OM_FEATURES_DISABLED, "");
if (disabledFeatures.contains(feature.name())) {
throw new OMException("Feature disabled: " + feature, OMException.ResultCodes.NOT_SUPPORTED_OPERATION);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.ozone.OzoneManagerVersion;
import org.apache.ratis.server.protocol.TermIndex;
import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.OzoneConfigKeys;
Expand Down Expand Up @@ -96,6 +97,10 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {

KeyArgs keyArgs = commitKeyRequest.getKeyArgs();

if (keyArgs.hasExpectedDataGeneration()) {
ozoneManager.checkFeatureEnabled(OzoneManagerVersion.ATOMIC_REWRITE_KEY);
}

// Verify key name
final boolean checkKeyNameEnabled = ozoneManager.getConfiguration()
.getBoolean(OMConfigKeys.OZONE_OM_KEYNAME_CHARACTER_CHECK_ENABLED_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import com.google.common.base.Preconditions;
import org.apache.hadoop.hdds.client.ReplicationConfig;
import org.apache.hadoop.ozone.OzoneManagerVersion;
import org.apache.ratis.server.protocol.TermIndex;
import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.om.OMConfigKeys;
Expand Down Expand Up @@ -93,6 +94,10 @@ public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {

KeyArgs keyArgs = createKeyRequest.getKeyArgs();

if (keyArgs.hasExpectedDataGeneration()) {
ozoneManager.checkFeatureEnabled(OzoneManagerVersion.ATOMIC_REWRITE_KEY);
}

// Verify key name
OmUtils.verifyKeyNameWithSnapshotReservedWord(keyArgs.getKeyName());
final boolean checkKeyNameEnabled = ozoneManager.getConfiguration()
Expand Down

0 comments on commit 3e9cdb6

Please sign in to comment.