diff --git a/skaha/src/main/java/org/opencadc/skaha/K8SUtil.java b/skaha/src/main/java/org/opencadc/skaha/K8SUtil.java index 5f936c25..618dd97d 100644 --- a/skaha/src/main/java/org/opencadc/skaha/K8SUtil.java +++ b/skaha/src/main/java/org/opencadc/skaha/K8SUtil.java @@ -82,7 +82,8 @@ public static String getHostName() { /** * Helps reduce string constants in many places. - * @return The Skaha namespace + * + * @return The Skaha namespace */ public static String getNamespace() { return "skaha-system"; @@ -94,11 +95,13 @@ public static String getWorkloadNamespace() { /** * Filter out anything not in the alphanumeric or hyphen character set. - * @see Kubernetes Object names - * @param sessionID The provided session ID. - * @param type The defined type (desktop, notebook, etc.) - * @param userID The running User's ID. - * @return String sanitized name. Never null. + * + * @param sessionID The provided session ID. + * @param type The defined type (desktop, notebook, etc.) + * @param userID The running User's ID. + * @return String sanitized name. Never null. + * @see Kubernetes Object + * names */ public static String getJobName(String sessionID, String type, String userID) { // Replace values that are NOT alphanumeric or a hyphen. @@ -133,7 +136,8 @@ public static String getSessionExpiry() { /** * Obtain the configured default quota size in Gigabytes. - * @return integer in GB. + * + * @return integer in GB. */ public static String getDefaultQuota() { return System.getenv(K8SUtil.ARC_USER_QUOTA_IN_GB_NAME); diff --git a/skaha/src/main/java/org/opencadc/skaha/SkahaAction.java b/skaha/src/main/java/org/opencadc/skaha/SkahaAction.java index cac45fac..bc5342d5 100644 --- a/skaha/src/main/java/org/opencadc/skaha/SkahaAction.java +++ b/skaha/src/main/java/org/opencadc/skaha/SkahaAction.java @@ -397,8 +397,8 @@ public Image getPublicImage(String imageID) { } /** - * It's important to use the correct constructor for the PosixMapperClient, this class will wrap the logic - * based on how the Resource ID of the POSIX mapper was set (URI or URL). + * It's important to use the correct constructor for the PosixMapperClient, this class will wrap the logic based on + * how the Resource ID of the POSIX mapper was set (URI or URL). */ protected static class PosixMapperConfiguration { final URI resourceID; diff --git a/skaha/src/main/java/org/opencadc/skaha/session/DeleteAction.java b/skaha/src/main/java/org/opencadc/skaha/session/DeleteAction.java index 3175a4a0..99421e5c 100644 --- a/skaha/src/main/java/org/opencadc/skaha/session/DeleteAction.java +++ b/skaha/src/main/java/org/opencadc/skaha/session/DeleteAction.java @@ -76,10 +76,7 @@ import org.opencadc.skaha.utils.CommandExecutioner; import org.opencadc.skaha.utils.KubectlCommandBuilder; -/** - * - * @author majorb - */ +/** @author majorb */ public class DeleteAction extends SessionAction { private static final Logger log = Logger.getLogger(DeleteAction.class); diff --git a/skaha/src/main/java/org/opencadc/skaha/session/PostAction.java b/skaha/src/main/java/org/opencadc/skaha/session/PostAction.java index a2c155f6..fbb3b478 100644 --- a/skaha/src/main/java/org/opencadc/skaha/session/PostAction.java +++ b/skaha/src/main/java/org/opencadc/skaha/session/PostAction.java @@ -103,9 +103,7 @@ import org.opencadc.skaha.utils.PosixCache; import org.opencadc.skaha.utils.QueueUtil; -/** - * @author majorb - */ +/** @author majorb */ public class PostAction extends SessionAction { // variables replaced in kubernetes yaml config files for @@ -458,13 +456,13 @@ private void validateName(String name) { } /** - * Validate and return the session type. There exists a loophole + * Validate and return the session type. There exists a loophole * * @param imageID The image to validate - * @param type User-provided session type (optional), defaults to headless + * @param type User-provided session type (optional), defaults to headless * @return The system recognized session type * @throws ResourceNotFoundException If an image with the supplied ID cannot be found - * @throws Exception If Harbor calls fail + * @throws Exception If Harbor calls fail */ private String validateImage(String imageID, String type) throws Exception { if (!StringUtil.hasText(imageID)) { @@ -723,15 +721,15 @@ private String getRegistryHost(final String imageID) { } /** - * Attach a desktop application. - * TODO: This method requires rework. The Job Name does not use the same mechanism as the K8SUtil.getJobName() - * TODO: and will suffer the same issue(s) with invalid characters in the Kubernetes object names. + * Attach a desktop application. TODO: This method requires rework. The Job Name does not use the same mechanism as + * the K8SUtil.getJobName() TODO: and will suffer the same issue(s) with invalid characters in the Kubernetes object + * names. * * @param image Container image name. - * @param requestCores Requested number of cores. - * @param limitCores Max number of cores. - * @param requestRAM Requested amount of RAM in Gi. - * @param limitRAM Max amount of RAM in Gi. + * @param requestCores Requested number of cores. + * @param limitCores Max number of cores. + * @param requestRAM Requested amount of RAM in Gi. + * @param limitRAM Max amount of RAM in Gi. * @throws Exception For any unexpected errors. */ public void attachDesktopApp( @@ -873,16 +871,10 @@ List toGIDs(final List groupURIS) throws Exception { } /** - * Create the image, command, args, and env sections of the job launch yaml. Example: - *

- * image: "${software.imageid}" - * command: ["/skaha-system/start-desktop-software.sh"] - * args: [arg1, arg2] - * env: - * - name: HOME - * value: "/cavern/home/${skaha.userid}" - * - name: SHELL - * value: "/bin/bash" + * Create the image, command, args, and env sections of the job launch yaml. Example: + * + *

image: "${software.imageid}" command: ["/skaha-system/start-desktop-software.sh"] args: [arg1, arg2] env: - + * name: HOME value: "/cavern/home/${skaha.userid}" - name: SHELL value: "/bin/bash" */ private String getHeadlessImageBundle(String image, String cmd, String args, List envs) { StringBuilder sb = new StringBuilder(); diff --git a/skaha/src/main/java/org/opencadc/skaha/session/SessionDAO.java b/skaha/src/main/java/org/opencadc/skaha/session/SessionDAO.java index ae98c7e6..5a966c54 100644 --- a/skaha/src/main/java/org/opencadc/skaha/session/SessionDAO.java +++ b/skaha/src/main/java/org/opencadc/skaha/session/SessionDAO.java @@ -395,7 +395,7 @@ static Session constructSession(String k8sOutput, final String topLevelDirectory } /** - * Example input is [4444 5555 6666]. Convert to an actual integer array. + * Example input is [4444 5555 6666]. Convert to an actual integer array. * * @param inputArray Kubernetes output of an array of integers. * @return integer array, never null. diff --git a/skaha/src/main/java/org/opencadc/skaha/utils/CommandExecutioner.java b/skaha/src/main/java/org/opencadc/skaha/utils/CommandExecutioner.java index 10bb2d63..d74bf439 100644 --- a/skaha/src/main/java/org/opencadc/skaha/utils/CommandExecutioner.java +++ b/skaha/src/main/java/org/opencadc/skaha/utils/CommandExecutioner.java @@ -89,7 +89,7 @@ public static void execute(final String[] command, final OutputStream standardOu * Delete, if necessary, and recreate the image pull secret for the given registry. * * @param registryAuth The registry credentials. - * @param secretName The name of the secret to create. + * @param secretName The name of the secret to create. * @throws Exception If there is an error creating the secret. */ public static void ensureRegistrySecret(final ImageRepositoryAuth registryAuth, final String secretName) diff --git a/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerDelete.java b/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerDelete.java index 9a3ccd6e..f181f9a9 100644 --- a/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerDelete.java +++ b/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerDelete.java @@ -73,7 +73,7 @@ public class DockerDelete extends DeleteAction { private static final Logger log = Logger.getLogger(DockerDelete.class); - + @Override public void stopSession(String userID, String sessionID) throws Exception { // kill the session specified by sessionID @@ -81,5 +81,5 @@ public void stopSession(String userID, String sessionID) throws Exception { String[] stopVNCCmd = new String[] {"/scripts/docker/stop-desktop.sh", userID, sessionID}; execute(stopVNCCmd); } - + } diff --git a/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerGet.java b/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerGet.java index ddb7daeb..d6be51b1 100644 --- a/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerGet.java +++ b/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerGet.java @@ -76,15 +76,15 @@ import ca.nrc.cadc.util.StringUtil; public class DockerGet extends GetAction { - + private static final Logger log = Logger.getLogger(DockerGet.class); - + @Override public void listSessions() throws Exception { String[] getVNCSessions = new String[] {"docker", "ps", "--format", "{{.Names}}\\t{{.Status}}", "--filter", "label=canfar-net-userid=" + userID}; String vncSessions = execute(getVNCSessions); - + if (StringUtil.hasLength(vncSessions)) { String[] lines = vncSessions.split("\n"); if (lines.length > 0) { @@ -120,13 +120,13 @@ public void listSessions() throws Exception { } log.debug("No container listing output"); } - + protected String parseCID(String vncName) { String[] parts = vncName.split("_"); String sessionID = parts[parts.length - 2]; return sessionID; } - + protected String parseCURL(String vncName) throws IOException, InterruptedException { String sessionID = parseCID(vncName); String[] getIpCmd = new String[] { @@ -134,7 +134,7 @@ protected String parseCURL(String vncName) throws IOException, InterruptedExcept String ipAddress = execute(getIpCmd); return getVNCURL(server, sessionID, ipAddress); } - + protected String parseCName(String vncName) { String[] parts = vncName.split("_"); return parts[parts.length - 1]; diff --git a/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerPost.java b/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerPost.java index 789e2262..b218eaa0 100644 --- a/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerPost.java +++ b/skaha/src/obsolete/java/org/opencadc/arcade/docker/DockerPost.java @@ -79,9 +79,9 @@ import ca.nrc.cadc.util.StringUtil; public class DockerPost extends PostAction { - + private static final Logger log = Logger.getLogger(DockerPost.class); - + @Override public void checkForExistingSession(String userid) throws Exception { String[] getVNCSessions = new String[] {"docker", "ps", "--format", "{{.Names}}\\t{{.Status}}", "--filter", "label=canfar-net-userid=" + userID}; @@ -93,21 +93,21 @@ public void checkForExistingSession(String userid) throws Exception { } } } - + @Override public URL createSession(String sessionID, String name) throws Exception { String[] runNoVNCCmd = new String[] {"/scripts/docker/run-desktop.sh", userID, sessionID, name, homedir, scratchdir}; String imageID = execute(runNoVNCCmd); - + // insert the user's proxy cert on the container Subject subject = AuthenticationUtil.getCurrentSubject(); //injectProxyCert("/home", subject, userID); - + String[] getIpCmd = new String[] { "docker", "inspect", "--format", "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}", imageID}; String ipAddress = execute(getIpCmd); - + // give vnc a few seconds to initialize try { log.debug("3 second wait for vnc initialization"); @@ -115,26 +115,26 @@ public URL createSession(String sessionID, String name) throws Exception { } catch (InterruptedException ignore) { } log.debug("wait over"); - + String redirectPath = super.getVNCURL(server, sessionID, ipAddress); return new URL(redirectPath); } - + @Override public void attachSoftware(String software, List params, String targetIP) throws Exception { - + confirmSoftware(software); - + // only one parameter supported for now String param = "xterm"; if (params != null && params.size() > 0) { param = params.get(0); } log.debug("Using parameter: " + param); - + String[] runAppCmd = new String[] {"/scripts/docker/software.sh", software, targetIP, userID, homedir, scratchdir, param}; String imageID = execute(runAppCmd); - + // refresh the user's proxy cert Subject subject = AuthenticationUtil.getCurrentSubject(); //injectProxyCert("/home", subject, userID); diff --git a/skaha/src/test/java/org/opencadc/skaha/image/GetActionTest.java b/skaha/src/test/java/org/opencadc/skaha/image/GetActionTest.java index d65df7b6..06039e5a 100644 --- a/skaha/src/test/java/org/opencadc/skaha/image/GetActionTest.java +++ b/skaha/src/test/java/org/opencadc/skaha/image/GetActionTest.java @@ -70,7 +70,6 @@ import static org.junit.Assert.assertThrows; import static org.mockito.Mockito.when; import static org.opencadc.skaha.utils.TestUtils.set; -import static org.opencadc.skaha.utils.TestUtils.setEnv; import java.util.List; import java.util.Set; @@ -83,10 +82,7 @@ import org.opencadc.skaha.SkahaAction; import org.opencadc.skaha.utils.RedisCache; -/** - * @author majorb - * - */ +/** @author majorb */ @RunWith(MockitoJUnitRunner.class) public class GetActionTest {