Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable use of udev for the OSHI system information library #12443

Merged
merged 1 commit into from
Jan 12, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import oshi.software.os.OperatingSystem;
import oshi.util.GlobalConfig;
import oshi.util.Util;

import java.util.Optional;

import static oshi.util.GlobalConfig.OSHI_OS_LINUX_ALLOWUDEV;

public class SystemInfo {
private static final Logger LOG = LoggerFactory.getLogger(SystemInfo.class);
private static final String OS_COMPLETE_NAME = determineOperatingSystemCompleteName();
Expand Down Expand Up @@ -54,6 +57,11 @@ private static void useAgentTmpDirIfNecessary() {
}

static oshi.SystemInfo newSystemInfo() {
// Allowing OSHI to load information from udev causes issues on Alpine due to use of glibc JVMs,
// if the musl udev is installed. Since we don't rely on this hardware info, we can disable it
// but better to remove this if Alpine is no longer supported for agents, or we have a more MUSL
// Alpine environment.
GlobalConfig.set(OSHI_OS_LINUX_ALLOWUDEV, "false");
return new oshi.SystemInfo();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,27 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.MockedStatic;
import oshi.util.GlobalConfig;
import uk.org.webcompere.systemstubs.jupiter.SystemStub;
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
import uk.org.webcompere.systemstubs.properties.SystemProperties;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mockStatic;
import static oshi.util.GlobalConfig.OSHI_OS_LINUX_ALLOWUDEV;

@ExtendWith(SystemStubsExtension.class)
class SystemInfoTest {

@SystemStub
SystemProperties props;

@Test
public void shouldDisableUdevUsage() {
SystemInfo.determineOperatingSystemCompleteName();
assertThat(GlobalConfig.get(OSHI_OS_LINUX_ALLOWUDEV, true)).isFalse();
}

@Test
public void shouldDefaultJnaTmpDirIfUnset() {
SystemInfo.determineOperatingSystemCompleteName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ enum Distro implements DistroBehavior {
return alpine.getInstallPrerequisitesCommands(v) +
[
'apk add --no-cache sudo',
'rm -rf /lib/libudev.so*', // btrfs is installed by Docker, but requires eudev-libs, which causes issues with OSHI JNA libary on Alpine with glibc and JVM crashes. Dont think we need udev as it's only needed by btrfs for multipath support.
]
}

Expand Down
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ final Map<String, String> libraries = [
mysql : 'com.mysql:mysql-connector-j:8.2.0',
objenesis : 'org.objenesis:objenesis:3.3',
oscache : 'opensymphony:oscache:2.4.1',
oshi : 'com.github.oshi:oshi-core-java11:6.4.10',
oshi : 'com.github.oshi:oshi-core-java11:6.4.11',
postgresql : 'org.postgresql:postgresql:42.7.1',
quartz : 'org.quartz-scheduler:quartz:2.3.2',
rack : 'org.jruby.rack:jruby-rack:1.1.22',
Expand Down