diff --git a/CHANGELOG.md b/CHANGELOG.md index 54b77ddfed88d..0add59e863f69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsPlugin.java b/plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsPlugin.java index af49cd3c579e6..429dc924d22f1 100644 --- a/plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsPlugin.java +++ b/plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsPlugin.java @@ -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) HdfsPlugin::evilHadoopInit); - AccessController.doPrivileged((PrivilegedAction) 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") diff --git a/plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsRepository.java b/plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsRepository.java index 4b38e62b2525a..fb708631dce8a 100644 --- a/plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsRepository.java +++ b/plugins/repository-hdfs/src/main/java/org/opensearch/repositories/hdfs/HdfsRepository.java @@ -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; @@ -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) () -> createBlobstore(uri, pathSetting, getMetadata().settings()) - ); + final HdfsBlobStore blobStore = AccessController.doPrivileged(() -> createBlobstore(uri, pathSetting, getMetadata().settings())); return blobStore; } diff --git a/plugins/repository-hdfs/src/test/java/org/opensearch/repositories/hdfs/HaHdfsFailoverTestSuiteIT.java b/plugins/repository-hdfs/src/test/java/org/opensearch/repositories/hdfs/HaHdfsFailoverTestSuiteIT.java index 89ba8d51cf7f7..455b800b2f80d 100644 --- a/plugins/repository-hdfs/src/test/java/org/opensearch/repositories/hdfs/HaHdfsFailoverTestSuiteIT.java +++ b/plugins/repository-hdfs/src/test/java/org/opensearch/repositories/hdfs/HaHdfsFailoverTestSuiteIT.java @@ -46,6 +46,7 @@ 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; @@ -53,16 +54,12 @@ 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 { @@ -76,9 +73,7 @@ public void testHAFailoverWithRepository() throws Exception { String nn2Port = "10002"; if (ports.length() > 0) { final Path path = PathUtils.get(ports); - final List lines = AccessController.doPrivileged((PrivilegedExceptionAction>) () -> { - return Files.readAllLines(path); - }); + final List lines = AccessController.doPrivilegedChecked(() -> Files.readAllLines(path)); nn1Port = lines.get(0); nn2Port = lines.get(1); } @@ -94,7 +89,7 @@ public void testHAFailoverWithRepository() throws Exception { "org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider" ); - AccessController.doPrivileged((PrivilegedExceptionAction) () -> { + AccessController.doPrivilegedChecked(() -> { if (securityEnabled) { // ensure that keytab exists Path kt = PathUtils.get(kerberosKeytabLocation); @@ -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) () -> { - 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; + }); } } diff --git a/test/fixtures/hdfs-fixture/build.gradle b/test/fixtures/hdfs-fixture/build.gradle index de79fdd836c04..2d3baaf41e308 100644 --- a/test/fixtures/hdfs-fixture/build.gradle +++ b/test/fixtures/hdfs-fixture/build.gradle @@ -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'