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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Bump `org.apache.avro:avro` from 1.12.0 to 1.12.1 ([#19692](https://github.com/opensearch-project/OpenSearch/pull/19692))
- Bump `com.github.spotbugs:spotbugs-annotations` from 4.9.6 to 4.9.8 ([#19691](https://github.com/opensearch-project/OpenSearch/pull/19691))
- Bump `stefanzweifel/git-auto-commit-action` from 6 to 7 ([#19689](https://github.com/opensearch-project/OpenSearch/pull/19689))
- Bump ch.qos.logback modules from 1.5.18 to 1.5.20 in HDFS test fixture ([#19763](https://github.com/opensearch-project/OpenSearch/pull/19763))
- Bump `github/codeql-action` from 3 to 4 ([#19785](https://github.com/opensearch-project/OpenSearch/pull/19785))
- Bump `gradle/actions` from 4 to 5 ([#19781](https://github.com/opensearch-project/OpenSearch/pull/19781))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,21 @@
import org.opensearch.plugins.Plugin;
import org.opensearch.plugins.RepositoryPlugin;
import org.opensearch.repositories.Repository;
import org.opensearch.secure_sm.AccessController;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collections;
import java.util.Map;

@SuppressWarnings("removal")
public final class HdfsPlugin extends Plugin implements RepositoryPlugin {

// initialize some problematic classes with elevated privileges
static {
SpecialPermission.check();
AccessController.doPrivileged((PrivilegedAction<Void>) HdfsPlugin::evilHadoopInit);
AccessController.doPrivileged((PrivilegedAction<Void>) HdfsPlugin::eagerInit);
AccessController.doPrivileged(HdfsPlugin::evilHadoopInit);
AccessController.doPrivileged(HdfsPlugin::eagerInit);
}

@SuppressForbidden(reason = "Needs a security hack for hadoop on windows, until HADOOP-XXXX is fixed")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@
import org.opensearch.env.Environment;
import org.opensearch.indices.recovery.RecoverySettings;
import org.opensearch.repositories.blobstore.BlobStoreRepository;
import org.opensearch.secure_sm.AccessController;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Locale;

Expand Down Expand Up @@ -254,14 +254,11 @@ private static String getHostName() {
}
}

@SuppressWarnings("removal")
@Override
protected HdfsBlobStore createBlobStore() {
// initialize our blobstore using elevated privileges.
SpecialPermission.check();
final HdfsBlobStore blobStore = AccessController.doPrivileged(
(PrivilegedAction<HdfsBlobStore>) () -> createBlobstore(uri, pathSetting, getMetadata().settings())
);
final HdfsBlobStore blobStore = AccessController.doPrivileged(() -> createBlobstore(uri, pathSetting, getMetadata().settings()));
return blobStore;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,20 @@
import org.opensearch.client.Response;
import org.opensearch.client.RestClient;
import org.opensearch.common.io.PathUtils;
import org.opensearch.secure_sm.AccessController;
import org.opensearch.test.rest.OpenSearchRestTestCase;
import org.junit.Assert;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.List;

/**
* Integration test that runs against an HA-Enabled HDFS instance
*/
@SuppressWarnings("removal")
public class HaHdfsFailoverTestSuiteIT extends OpenSearchRestTestCase {

public void testHAFailoverWithRepository() throws Exception {
Expand All @@ -76,9 +73,7 @@ public void testHAFailoverWithRepository() throws Exception {
String nn2Port = "10002";
if (ports.length() > 0) {
final Path path = PathUtils.get(ports);
final List<String> lines = AccessController.doPrivileged((PrivilegedExceptionAction<List<String>>) () -> {
return Files.readAllLines(path);
});
final List<String> lines = AccessController.doPrivilegedChecked(() -> Files.readAllLines(path));
nn1Port = lines.get(0);
nn2Port = lines.get(1);
}
Expand All @@ -94,7 +89,7 @@ public void testHAFailoverWithRepository() throws Exception {
"org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider"
);

AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
AccessController.doPrivilegedChecked(() -> {
if (securityEnabled) {
// ensure that keytab exists
Path kt = PathUtils.get(kerberosKeytabLocation);
Expand Down Expand Up @@ -287,20 +282,20 @@ public void close() {
*/
private void failoverHDFS(String from, String to, Configuration configuration) throws IOException {
logger.info("Swapping active namenodes: [{}] to standby and [{}] to active", from, to);
try {
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
CloseableHAAdmin haAdmin = new CloseableHAAdmin();
haAdmin.setConf(configuration);
AccessController.doPrivileged(() -> {
CloseableHAAdmin haAdmin = new CloseableHAAdmin();
haAdmin.setConf(configuration);
try {
try {
haAdmin.transitionToStandby(from);
haAdmin.transitionToActive(to);
} finally {
haAdmin.close();
} catch (Exception e) {
throw new RuntimeException("Unable to perform namenode failover", e);
}
return null;
});
} catch (PrivilegedActionException pae) {
throw new IOException("Unable to perform namenode failover", pae);
}
} finally {
haAdmin.close();
}
return null;
});
}
}
4 changes: 2 additions & 2 deletions test/fixtures/hdfs-fixture/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ dependencies {
api 'org.apache.zookeeper:zookeeper:3.9.4'
api "org.apache.commons:commons-text:1.13.1"
api "commons-net:commons-net:3.12.0"
api "ch.qos.logback:logback-core:1.5.18"
api "ch.qos.logback:logback-classic:1.5.18"
api "ch.qos.logback:logback-core:1.5.20"
api "ch.qos.logback:logback-classic:1.5.20"
api "org.jboss.xnio:xnio-nio:3.8.17.Final"
api 'org.jline:jline:3.30.5'
api 'org.apache.commons:commons-configuration2:2.12.0'
Expand Down
Loading