Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a8b2d15
HDDS-8166. [Snapshot] Add a config to enable or disable Ozone snapsho…
smengcl May 3, 2023
5019540
Address comment 1.
smengcl May 3, 2023
79e5f7d
More docker compose config additions.
smengcl May 3, 2023
485fe1d
Add new Aspect SnapshotFeatureEnabled.
smengcl May 3, 2023
9c6ef61
Clean up Aspect impl and test.
smengcl May 4, 2023
49ca500
More test changes to enable snapshot feature explicitly.
smengcl May 4, 2023
85c75e6
omSnapshotManager can't easily be null due to the usage in OMDirector…
smengcl May 4, 2023
fcd2c8b
Even more test changes to enable snapshot feature explicitly.
smengcl May 4, 2023
efebf55
Add comments for HDDS-8529; add debug logging when omSnapshotManager …
smengcl May 4, 2023
3df4394
Add workaround for HDDS-8529.
smengcl May 4, 2023
484a529
Rename `SnapshotFeatureEnabled` to `RequireSnapshotFeatureState`; com…
smengcl May 4, 2023
18b39dc
Add debug logging in RequireSnapshotFeatureStateAspect.
smengcl May 4, 2023
a9be442
Add one more `omSnapshotManager` null check in `installCheckpoint`.
smengcl May 4, 2023
48db6b6
Can't disable `omSnapshotManager` as all read paths now requires `omS…
smengcl May 4, 2023
3e4c57c
Disallow snapshot access when feature is disabled by forcing `OmSnaps…
smengcl May 4, 2023
b832a91
Remove workaround now that `omSnapshotManager` won't be null.
smengcl May 4, 2023
c71cf5d
Revert `omSnapshotManager` null handling; add integration test.
smengcl May 4, 2023
7a5357d
Merge remote-tracking branch 'asf/master' into HDDS-8166-snapshot-config
smengcl May 4, 2023
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
10 changes: 10 additions & 0 deletions hadoop-hdds/common/src/main/resources/ozone-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3200,6 +3200,16 @@
</description>
</property>

<property>
<name>ozone.filesystem.snapshot.enabled</name>
<value>true</value>
<tag>OZONE, OM</tag>
<description>
Enables Ozone filesystem snapshot feature if set to true on the OM side.
Disables it otherwise.
</description>
</property>

<property>
<name>ozone.snapshot.deleting.service.timeout</name>
<value>300s</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public final class OMConfigKeys {
private OMConfigKeys() {
}

public static final String OZONE_FILESYSTEM_SNAPSHOT_ENABLED_KEY =
"ozone.filesystem.snapshot.enabled";
public static final boolean OZONE_FILESYSTEM_SNAPSHOT_ENABLED_DEFAULT = true;

// Location where the OM stores its DB files. In the future we may support
// multiple entries for performance (sharding)..
public static final String OZONE_OM_DB_DIRS = "ozone.om.db.dirs";
Expand Down
3 changes: 3 additions & 0 deletions hadoop-ozone/dist/src/main/compose/ozone-om-ha/docker-config
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,6 @@ OZONE_CONF_DIR=/etc/hadoop
OZONE_LOG_DIR=/var/log/hadoop

no_proxy=om,scm,s3g,recon,kdc,localhost,127.0.0.1

# Explicitly enable filesystem snapshot feature for this Docker compose cluster
OZONE-SITE.XML_ozone.filesystem.snapshot.enabled=true
3 changes: 3 additions & 0 deletions hadoop-ozone/dist/src/main/compose/ozone/docker-config
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ OZONE_CONF_DIR=/etc/hadoop
OZONE_LOG_DIR=/var/log/hadoop

no_proxy=om,scm,s3g,recon,kdc,localhost,127.0.0.1

# Explicitly enable filesystem snapshot feature for this Docker compose cluster
OZONE-SITE.XML_ozone.filesystem.snapshot.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,6 @@ OZONE_CONF_DIR=/etc/hadoop
OZONE_LOG_DIR=/var/log/hadoop

no_proxy=om,scm,recon,s3g,kdc,localhost,127.0.0.1

# Explicitly enable filesystem snapshot feature for this Docker compose cluster
OZONE-SITE.XML_ozone.filesystem.snapshot.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,6 @@ OZONE_CONF_DIR=/etc/hadoop
OZONE_LOG_DIR=/var/log/hadoop

no_proxy=om,scm,s3g,recon,kdc,localhost,127.0.0.1

# Explicitly enable filesystem snapshot feature for this Docker compose cluster
OZONE-SITE.XML_ozone.filesystem.snapshot.enabled=true
3 changes: 3 additions & 0 deletions hadoop-ozone/dist/src/main/compose/ozonesecure/docker-config
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,6 @@ OZONE-SITE.XML_ozone.om.multitenancy.ranger.sync.timeout=10s
# change or let all OMs write to AccessController if this dev flag is set.
#
OZONE-SITE.XML_ozone.om.tenant.dev.skip.ranger=true

# Explicitly enable filesystem snapshot feature for this Docker compose cluster
OZONE-SITE.XML_ozone.filesystem.snapshot.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ OZONE-SITE.XML_ozone.recon.address=recon:9891
no_proxy=om1,om2,om3,scm1,scm2,scm3,s3g,kdc,localhost,127.0.0.1

OM_SERVICE_ID=omservice

# Explicitly enable filesystem snapshot feature for this Docker compose cluster
# Does not take effect on Ozone versions < 1.4.0
OZONE-SITE.XML_ozone.filesystem.snapshot.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ OZONE_CONF_DIR=/etc/hadoop
OZONE_LOG_DIR=/var/log/hadoop

no_proxy=om,scm,s3g,kdc,localhost,127.0.0.1

# Explicitly enable filesystem snapshot feature for this Docker compose cluster
# Does not take effect on Ozone versions < 1.4.0
OZONE-SITE.XML_ozone.filesystem.snapshot.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ OZONE-SITE.XML_ozone.recon.address=recon:9891
no_proxy=om1,om2,om3,scm,s3g,kdc,localhost,127.0.0.1

OM_SERVICE_ID=omservice

# Explicitly enable filesystem snapshot feature for this Docker compose cluster
# Does not take effect on Ozone versions < 1.4.0
OZONE-SITE.XML_ozone.filesystem.snapshot.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.OzoneManager;
import org.apache.hadoop.ozone.om.helpers.SnapshotInfo;
import org.apache.hadoop.util.ToolRunner;
Expand Down Expand Up @@ -76,6 +77,8 @@ public class TestOzoneFsSnapshot {
@BeforeAll
public static void initClass() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
// Enable filesystem snapshot feature for the test regardless of the default
conf.setBoolean(OMConfigKeys.OZONE_FILESYSTEM_SNAPSHOT_ENABLED_KEY, true);

// Start the cluster
cluster = MiniOzoneCluster.newOMHABuilder(conf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.hadoop.ozone.client.OzoneBucket;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.OMMetadataManager;
import org.apache.hadoop.ozone.om.OmMetadataManagerImpl;
import org.apache.hadoop.ozone.om.OmSnapshotManager;
Expand Down Expand Up @@ -98,6 +99,8 @@ public static void init() throws Exception {
raftClientConfig.setRpcRequestTimeout(Duration.ofSeconds(3));
raftClientConfig.setRpcWatchRequestTimeout(Duration.ofSeconds(3));
conf.setFromObject(raftClientConfig);
// Enable filesystem snapshot feature for the test regardless of the default
conf.setBoolean(OMConfigKeys.OZONE_FILESYSTEM_SNAPSHOT_ENABLED_KEY, true);

// Set DB CF write buffer to a much lower value so that flush and compaction
// happens much more frequently without having to create a lot of keys.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ private void init() throws Exception {
conf.setBoolean(OMConfigKeys.OZONE_OM_SNAPSHOT_FORCE_FULL_DIFF,
forceFullSnapshotDiff);
conf.setEnum(HDDS_DB_PROFILE, DBProfile.TEST);
// Enable filesystem snapshot feature for the test regardless of the default
conf.setBoolean(OMConfigKeys.OZONE_FILESYSTEM_SNAPSHOT_ENABLED_KEY, true);

cluster = MiniOzoneCluster.newOMHABuilder(conf)
.setClusterId(clusterId)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. The ASF
* licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package org.apache.hadoop.ozone.om;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.utils.IOUtils;
import org.apache.hadoop.hdds.utils.db.DBProfile;
import org.apache.hadoop.ozone.MiniOzoneCluster;
import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl;
import org.apache.hadoop.ozone.client.ObjectStore;
import org.apache.hadoop.ozone.client.OzoneClient;
import org.apache.hadoop.ozone.client.OzoneVolume;
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.helpers.BucketLayout;
import org.apache.ozone.test.LambdaTestUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

import java.util.UUID;

import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_DB_PROFILE;

/**
* Integration test to verify Ozone snapshot RPCs throw exception when called.
*/
public class TestOmSnapshotDisabled {

private static MiniOzoneCluster cluster = null;
private static OzoneClient client;
private static ObjectStore store;

@BeforeAll
@Timeout(60)
public static void init() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
String clusterId = UUID.randomUUID().toString();
String scmId = UUID.randomUUID().toString();
conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT,
BucketLayout.LEGACY.name());
conf.setEnum(HDDS_DB_PROFILE, DBProfile.TEST);
// Disable filesystem snapshot feature for this test
conf.setBoolean(OMConfigKeys.OZONE_FILESYSTEM_SNAPSHOT_ENABLED_KEY, false);

cluster = MiniOzoneCluster.newOMHABuilder(conf)
.setClusterId(clusterId)
.setScmId(scmId)
.setOMServiceId("om-service-test1")
.setNumOfOzoneManagers(3)
.build();
cluster.waitForClusterToBeReady();
client = cluster.newClient();

OzoneManager leaderOzoneManager =
((MiniOzoneHAClusterImpl) cluster).getOMLeader();
OzoneConfiguration leaderConfig = leaderOzoneManager.getConfiguration();
cluster.setConf(leaderConfig);
store = client.getObjectStore();
}

@AfterAll
public static void tearDown() throws Exception {
IOUtils.closeQuietly(client);
if (cluster != null) {
cluster.shutdown();
}
}

@Test
public void testExceptionThrown() throws Exception {
String volumeName = "vol-" + RandomStringUtils.randomNumeric(5);
String bucketName = "buck-" + RandomStringUtils.randomNumeric(5);
String snapshotName = "snap-" + RandomStringUtils.randomNumeric(5);

store.createVolume(volumeName);
OzoneVolume volume = store.getVolume(volumeName);
volume.createBucket(bucketName);

// create snapshot should throw
LambdaTestUtils.intercept(OMException.class, "FEATURE_NOT_ENABLED",
() -> store.createSnapshot(volumeName, bucketName, snapshotName));
// delete snapshot should throw
LambdaTestUtils.intercept(OMException.class, "FEATURE_NOT_ENABLED",
() -> store.deleteSnapshot(volumeName, bucketName, snapshotName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ public class TestOmSnapshotFileSystem {
private static final Logger LOG =
LoggerFactory.getLogger(TestOmSnapshot.class);



@Rule
public Timeout timeout = new Timeout(120, TimeUnit.SECONDS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.hadoop.ozone.client.io.OzoneOutputStream;
import org.apache.hadoop.ozone.client.BucketArgs;
import org.apache.hadoop.ozone.om.KeyManagerImpl;
import org.apache.hadoop.ozone.om.OMConfigKeys;
import org.apache.hadoop.ozone.om.OMStorage;
import org.apache.hadoop.ozone.om.OmSnapshotManager;
import org.apache.hadoop.ozone.om.OzoneManager;
Expand Down Expand Up @@ -91,6 +92,9 @@ private static Stream<Arguments> bucketTypesCombinations() {
@BeforeEach
public void init() throws Exception {
OzoneConfiguration conf = new OzoneConfiguration();
// Enable filesystem snapshot feature for the test regardless of the default
conf.setBoolean(OMConfigKeys.OZONE_FILESYSTEM_SNAPSHOT_ENABLED_KEY, true);

String clusterId = UUID.randomUUID().toString();
String scmId = UUID.randomUUID().toString();
String serviceID = OM_SERVICE_ID + RandomStringUtils.randomNumeric(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ public void start(OzoneConfiguration configuration) {
openKeyCleanupService.start();
}

if (snapshotSstFilteringService == null) {
if (snapshotSstFilteringService == null &&
ozoneManager.isFilesystemSnapshotEnabled()) {

long serviceInterval = configuration.getTimeDuration(
OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL,
OZONE_SNAPSHOT_SST_FILTERING_SERVICE_INTERVAL_DEFAULT,
Expand All @@ -272,7 +274,9 @@ public void start(OzoneConfiguration configuration) {
}
}

if (snapshotDeletingService == null) {
if (snapshotDeletingService == null &&
ozoneManager.isFilesystemSnapshotEnabled()) {

long snapshotServiceInterval = configuration.getTimeDuration(
OZONE_SNAPSHOT_DELETING_SERVICE_INTERVAL,
OZONE_SNAPSHOT_DELETING_SERVICE_INTERVAL_DEFAULT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ public List<BlockGroup> getPendingDeletionKeys(final int keyCount,
* Get the latest OmSnapshot for a snapshot path.
*/
public OmSnapshot getLatestSnapshot(String volumeName, String bucketName,
OmSnapshotManager snapshotManager)
OmSnapshotManager snapshotManager)
throws IOException {

String latestPathSnapshot =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,18 @@ public final class OmSnapshotManager implements AutoCloseable {
// Soft limit of the snapshot cache size.
private final int softCacheSize;

/**
* TODO: [SNAPSHOT] HDDS-8529: Refactor the constructor in a way that when
* ozoneManager.isFilesystemSnapshotEnabled() returns false,
* no snapshot-related background job or initialization would run,
* except for applying previously committed Ratis transactions in e.g.:
* 1. {@link OMKeyPurgeRequest#validateAndUpdateCache}
* 2. {@link OMDirectoriesPurgeRequestWithFSO#validateAndUpdateCache}
*/
public OmSnapshotManager(OzoneManager ozoneManager) {
LOG.info("Ozone filesystem snapshot feature is {}.",
ozoneManager.isFilesystemSnapshotEnabled() ? "enabled" : "disabled");

this.options = new ManagedDBOptions();
this.options.setCreateIfMissing(true);
this.columnFamilyOptions = new ManagedColumnFamilyOptions();
Expand Down Expand Up @@ -259,17 +270,21 @@ public OmSnapshotManager(OzoneManager ozoneManager) {
OZONE_OM_SNAPSHOT_DIFF_CLEANUP_SERVICE_TIMEOUT_DEFAULT,
TimeUnit.MILLISECONDS);

this.snapshotDiffCleanupService = new SnapshotDiffCleanupService(
diffCleanupServiceInterval,
diffCleanupServiceTimeout,
ozoneManager,
snapshotDiffDb,
snapDiffJobCf,
snapDiffPurgedJobCf,
snapDiffReportCf,
codecRegistry
);
this.snapshotDiffCleanupService.start();
if (ozoneManager.isFilesystemSnapshotEnabled()) {
this.snapshotDiffCleanupService = new SnapshotDiffCleanupService(
diffCleanupServiceInterval,
diffCleanupServiceTimeout,
ozoneManager,
snapshotDiffDb,
snapDiffJobCf,
snapDiffPurgedJobCf,
snapDiffReportCf,
codecRegistry
);
this.snapshotDiffCleanupService.start();
} else {
this.snapshotDiffCleanupService = null;
}
}

private CacheLoader<String, OmSnapshot> createCacheLoader() {
Expand Down Expand Up @@ -479,7 +494,7 @@ private static void deleteKeysInSnapshotScopeFromDTableInternal(
public IOmMetadataReader checkForSnapshot(String volumeName,
String bucketName, String keyname)
throws IOException {
if (keyname == null) {
if (keyname == null || !ozoneManager.isFilesystemSnapshotEnabled()) {
return ozoneManager.getOmMetadataReader();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,8 @@ public final class OzoneManager extends ServiceRuntimeInfoImpl
private final OzoneLockProvider ozoneLockProvider;
private OMPerformanceMetrics perfMetrics;

private boolean fsSnapshotEnabled;

/**
* OM Startup mode.
*/
Expand Down Expand Up @@ -544,6 +546,10 @@ private OzoneManager(OzoneConfiguration conf, StartupOption startupOption)
OMConfigKeys.OZONE_OM_RATIS_ENABLE_KEY,
OMConfigKeys.OZONE_OM_RATIS_ENABLE_DEFAULT);

fsSnapshotEnabled = configuration.getBoolean(
OMConfigKeys.OZONE_FILESYSTEM_SNAPSHOT_ENABLED_KEY,
OMConfigKeys.OZONE_FILESYSTEM_SNAPSHOT_ENABLED_DEFAULT);

String defaultBucketLayoutString =
configuration.getTrimmed(OZONE_DEFAULT_BUCKET_LAYOUT,
OZONE_DEFAULT_BUCKET_LAYOUT_DEFAULT);
Expand Down Expand Up @@ -783,6 +789,8 @@ private void instantiateServices(boolean withNewSnapshot) throws IOException {
perfMetrics);
omMetadataReader = new OmMetadataReader(keyManager, prefixManager,
this, LOG, AUDIT, metrics);

// TODO: [SNAPSHOT] Revisit this in HDDS-8529.
omSnapshotManager = new OmSnapshotManager(this);

// Snapshot metrics
Expand Down Expand Up @@ -3994,6 +4002,13 @@ public boolean isRatisEnabled() {
return isRatisEnabled;
}

/**
* @return true if Ozone filesystem snapshot is enabled, false otherwise.
*/
public boolean isFilesystemSnapshotEnabled() {
return fsSnapshotEnabled;
}

/**
* Get DB updates since a specific sequence number.
*
Expand Down
Loading