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

Kueue preparation #768

Merged
merged 15 commits into from
Jan 8, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions skaha/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/.settings/
/.tmp/
/.classpth/
src/intTest/resources/*.pem
src/intTest/resources/*.token
24 changes: 17 additions & 7 deletions skaha/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id 'com.diffplug.spotless' version '6.25.0'
id 'java'
id 'jacoco'
id 'checkstyle'
id 'org.jetbrains.dokka' version '1.6.0'
}

Expand Down Expand Up @@ -37,7 +38,10 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'commons-io:commons-io:[2.14.0,3.0.0)'

// Used to merge YAML sections to fully configure Job files.
implementation 'io.kubernetes:client-java:21.0.2'

implementation 'org.opencadc:cadc-access-control:[1.1.23,)'
implementation 'org.opencadc:cadc-access-control-identity:[1.1.0,)'
implementation 'org.opencadc:cadc-cdp:[1.2,)'
Expand Down Expand Up @@ -72,6 +76,12 @@ spotless {
palantirJavaFormat('2.50.0').formatJavadoc(true)
// Format annotations on a single line
formatAnnotations()

// Checks for javadoc formatting
checkstyle {
// Point to the same checkstyle.xml file as the checkstyle task
configFile file("$rootDir/checkstyle.xml")
}
}
}
check.dependsOn spotlessCheck
Expand Down Expand Up @@ -105,12 +115,12 @@ tasks.dokkaHtml.configure {
register("main") {
sourceRoots.from(file("src/main/java"))
}
configureEach {
jdkVersion.set(11)
sourceLink {
localDirectory.set(file("src/main/java"))
remoteUrl.set("https://github.com/opencadc/science-platform/tree/main/skaha/src/main/java")
}
}
configureEach {
jdkVersion.set(11)
sourceLink {
localDirectory.set(file("src/main/java"))
remoteUrl.set("https://github.com/opencadc/science-platform/tree/main/skaha/src/main/java")
}
}
}
}
11 changes: 11 additions & 0 deletions skaha/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocStyle">
<property name="checkEmptyJavadoc" value="true"/>
<property name="scope" value="public"/>
</module>
</module>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
import org.opencadc.skaha.session.SessionAction;

/**
* Integration test for session lifecycle creation and deletion for Desktops and their applications.
*
* @author majorb
*/
public class DesktopAppLifecycleTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@
import org.opencadc.skaha.session.SessionAction;

/**
* Integration Test to test renewing existing Sessions.
*
* @author majorb
*/
public class ExpiryTimeRenewalTest {

public static final String CARTA_IMAGE_SUFFIX = "/skaha/carta:3.0";
public static final String CARTA_IMAGE_SUFFIX = "/skaha/carta:latest";
at88mph marked this conversation as resolved.
Show resolved Hide resolved
public static final int SLEEP_TIME_SECONDS = 5;
private static final Logger log = Logger.getLogger(ExpiryTimeRenewalTest.class);

Expand Down
2 changes: 2 additions & 0 deletions skaha/src/intTest/java/org/opencadc/skaha/ImagesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
import org.opencadc.skaha.image.Image;

/**
* Integration test for Image GET requests.
*
* @author yeunga
*/
public class ImagesTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
import org.opencadc.skaha.session.SessionAction;

/**
* Integration test for session lifecycle creation and deletion.
*
* @author majorb
*/
public class SessionLifecycleTest {
Expand Down
96 changes: 81 additions & 15 deletions skaha/src/main/java/org/opencadc/skaha/K8SUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,41 +67,39 @@

package org.opencadc.skaha;

import java.util.List;
import org.apache.log4j.Logger;

public class K8SUtil {

static final String ARC_USER_QUOTA_IN_GB_NAME = "skaha.defaultquotagb";

private static final Logger log = Logger.getLogger(K8SUtil.class);

public static String getHostName() {
return System.getenv("skaha.hostname");
}

/**
* Helps reduce string constants in many places.
* @return The Skaha namespace
*/
public static String getNamespace() {
return "skaha-system";
}

public static String getWorkloadNamespace() {
return System.getenv("skaha.namespace");
}

/**
* 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.
*
* @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.
*/
public static String getJobName(String sessionID, String type, String userID) {
// Replace values that are NOT alphanumeric or a hyphen.
final String userJobID = userID.replaceAll("[^0-9a-zA-Z-]", "-");
return ("skaha-" + type + "-" + userJobID + "-" + sessionID).toLowerCase();
}

// skaha-notebook-svc-rdcc0219
public static String getServiceName(String sessionID, String type) {
return "skaha-" + type + "-svc-" + sessionID;
}
Expand All @@ -128,7 +126,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 All @@ -137,4 +136,71 @@ public static String getDefaultQuota() {
public static String getPreAuthorizedTokenSecretName() {
return "pre-auth-token-skaha";
}

public static String getSkahaTld() {
return System.getenv("SKAHA_TLD");
}

public static boolean isGpuEnabled() {
return Boolean.parseBoolean(System.getenv("GPU_ENABLED"));
}

public static List<String> getHarborHosts() {
String rawHosts = System.getenv("skaha.harborhosts");
if (rawHosts == null) {
log.warn("No harbor hosts configured.");
return List.of();
}

return List.of(rawHosts.split(","));
}

public static String getSkahaUsersGroup() {
return System.getenv("skaha.usersgroup");
}

public static String getSkahaAdminsGroup() {
return System.getenv("skaha.adminsgroup");
}

public static String getSkahaHeadlessGroup() {
return System.getenv("skaha.headlessgroup");
}

public static String getSkahaHeadlessPriorityGroup() {
return System.getenv("skaha.headlessprioritygroup");
}

public static String getSkahaHeadlessPriorityClass() {
return System.getenv("skaha.headlesspriortyclass");
}

public static Integer getMaxUserSessions() {
String noOfSessions = System.getenv("skaha.maxusersessions");
if (noOfSessions == null) {
log.warn("no max user sessions value configured.");
return 1;
}
return Integer.parseInt(noOfSessions);
}

public static String getPosixCacheUrl(String packageName) {
return System.getProperty(packageName + ".posixCache.url");
}

public static String getPosixMapperResourceId() {
return System.getenv("skaha.posixmapper.resourceid");
}

public static String getRedisHost() {
return System.getenv("REDIS_HOST");
}

public static String getRedisPort() {
return System.getenv("REDIS_PORT");
}

public static String getUserHome() {
return System.getProperty("user.home");
}
}
Loading
Loading