Skip to content

Commit

Permalink
[SP-4263 | Abhishek/Anuja] Fixed failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
anujachaitanya committed Nov 25, 2024
1 parent 2033bfd commit 592b50d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 43 deletions.
18 changes: 11 additions & 7 deletions skaha/src/main/java/org/opencadc/skaha/K8SUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -94,11 +95,13 @@ public static String getWorkloadNamespace() {

/**
* Filter out anything not in the alphanumeric or hyphen character set.
* @see <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/names/">Kubernetes Object names</a>
* @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 <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/names/">Kubernetes Object
* names</a>
*/
public static String getJobName(String sessionID, String type, String userID) {
// Replace values that are NOT alphanumeric or a hyphen.
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions skaha/src/main/java/org/opencadc/skaha/SkahaAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
38 changes: 15 additions & 23 deletions skaha/src/main/java/org/opencadc/skaha/session/PostAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -873,16 +871,10 @@ List<PosixGroup> toGIDs(final List<GroupURI> groupURIS) throws Exception {
}

/**
* Create the image, command, args, and env sections of the job launch yaml. Example:
* <p />
* 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:
*
* <p>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<String> envs) {
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down

0 comments on commit 592b50d

Please sign in to comment.