Skip to content

Commit

Permalink
feat: linux control group version 2 API support cgroup v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ChangxinDong committed Oct 26, 2022
1 parent 075b43a commit d9201ba
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;

import java.io.IOException;
Expand Down Expand Up @@ -96,7 +95,6 @@
class GenericExternalServiceIntegTest extends BaseITCase {
private Kernel kernel;

@Spy
LinuxPlatform linuxPlatform;

private final static String ROOT_PATH_STRING = "/systest21/fs/cgroup";
Expand Down Expand Up @@ -657,7 +655,7 @@ void GIVEN_linux_resource_limits_WHEN_it_changes_THEN_component_runs_with_new_re
}
});

linuxPlatform = spy(kernel.getContext().get(LinuxPlatform.class));
linuxPlatform = kernel.getContext().get(LinuxPlatform.class);

createComponentData(echoComponentName);
createComponentData(mainComponentName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

package com.aws.greengrass.util.platforms.unix.linux;

import com.aws.greengrass.logging.api.Logger;
import com.aws.greengrass.logging.impl.LogManager;
import com.aws.greengrass.util.platforms.SystemResourceController;
import com.aws.greengrass.util.platforms.unix.UnixPlatform;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand All @@ -19,20 +17,15 @@
justification = "Cgroup Controller virtual filesystem path cannot be relative")
public class LinuxPlatform extends UnixPlatform {
private static final Path CGROUP_CONTROLLERS = Paths.get("/sys/fs/cgroup/cgroup.controllers");
private final Logger log = LogManager.getLogger(LinuxPlatform.class);
SystemResourceController systemResourceController;

@Override
public SystemResourceController getSystemResourceController() {
//if the path exists, identify it as cgroupv2, otherwise identify it as cgroupv1
log.atInfo().log("LinuxPlatform-->CGROUP_CONTROLLERS:" + CGROUP_CONTROLLERS);

if (Files.exists(CGROUP_CONTROLLERS)) {
systemResourceController = new LinuxSystemResourceControllerV2(this);
log.atInfo().log("LinuxPlatform-->V2");
} else {
systemResourceController = new LinuxSystemResourceController(this);
log.atInfo().log("LinuxPlatform-->V1");
}

return systemResourceController;
Expand Down

0 comments on commit d9201ba

Please sign in to comment.