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

Cadc 12356 Add support for desktop-app to Skaha API #464

Merged
merged 57 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
70062c7
CADC-12356 Updated desktop-app creation to accept cores and ram and r…
yeunga May 1, 2023
61f0d18
CADC-12356 Implemented skaha API for desktop-app. Updated unit tests.
yeunga May 1, 2023
4ba3f7b
CADC-12356 Added Skaha API DELETE /session/{session}/app/{appID}
yeunga May 3, 2023
8193bb7
CADC-12356 Updated swagger doc.
yeunga May 3, 2023
480fcb6
CADC-12356 Updated swagger doc.
yeunga May 3, 2023
a6c8729
CADC-12356 Renamed LifeCycleTest and updated GetAction and PostAction…
yeunga May 5, 2023
be8f632
CADC-12356 Updated SessionLifecycleTest.
yeunga May 5, 2023
f556818
CADC-12356 Incremented skaha version and added desktop-app integratio…
yeunga May 7, 2023
71dabe1
CADC-12356 Corrected comment.
yeunga May 10, 2023
5473f43
CADC-12356 Updated build-menu.sh to start an xterm when launching a d…
yeunga May 15, 2023
64ca715
CADC-12356 Updated start-software-sh.template to check user input aga…
yeunga May 16, 2023
be16694
CADC-12356 Updated start-software-sh.template to hang on to the xterm…
yeunga May 17, 2023
2ed398a
CADC-12356 Added k8s-resources.properties to shaka-desktop to be used…
yeunga May 17, 2023
6c349ed
CADC-12356 Added app ID to launch-desktop-app.
yeunga May 29, 2023
9a0c0ae
CADC-12356 Incremented skaha-tomcat deployment version to 0.9.23. Thi…
yeunga May 29, 2023
6984ad8
CADC-12356 Updated skaha version and skaha-desktop version. Added mis…
yeunga Jun 2, 2023
9f28dde
CADC-12356 Fixed templates and kustomization.
yeunga Jun 2, 2023
22f3106
CADC-12356 Fixed software-sh.template
yeunga Jun 2, 2023
dcadab7
CADC-12356 Fixed placement issue of sleep-forever.sh.
yeunga Jun 5, 2023
2d0fb38
CADC-12356 Added /config in desktop for k8s-resources.properties.
Jun 6, 2023
0c3d0ef
CADC-12356 Added /config to desktop in keel-prod.
yeunga Jun 6, 2023
139657e
CADC-12356 Fixed default core and ram values in start-software-sh.tem…
yeunga Jun 6, 2023
bfa3c75
CADC-12356 Updated start-software-sh.template to check the status of …
yeunga Jun 6, 2023
0291b1a
CADC-12356 Updated check status logic in start-software-sh.template.
Jun 8, 2023
57d244e
Merge branch 'master' into cadc-12356
yeunga Jun 8, 2023
1ac3d42
CADC-12356 Resolved merge conflicts.
yeunga Jun 8, 2023
e13789e
CADC-12356 xterm was not available on skaha-desktop. Added installati…
yeunga Jun 12, 2023
0263aad
CADC-12356 Resolved conflicts when merging codes from master branch.
yeunga Jun 13, 2023
c992bde
CADC-12356 Changed start-software-sh.template to use system cURL as s…
yeunga Jun 13, 2023
9ae8067
CADC-12356 Changed skaha-tomcat to version 0.12.0.
yeunga Jun 14, 2023
6db5d89
CADC-12356 Reworked based on review comments. Fixed an integration te…
yeunga Jun 15, 2023
ae6fd1d
CADC-12356 Fixed skaha integration tests.
yeunga Jun 16, 2023
b482114
CADC-12356 Updated xfce-applications.menu to stop Applications->Syste…
yeunga Jun 16, 2023
c123ffc
CADC-12356 Updated /config/k8s-resources.properties to /desktop-confi…
yeunga Jun 16, 2023
1d3a077
CADC-12356 Removed XTerm menu item from Applications->Other.
yeunga Jun 16, 2023
7b63de6
CADC-12356 Updated skaha-desktop Dockerfile and software-sh.template …
yeunga Jun 21, 2023
51d6f38
CADC-12356 minor update.
yeunga Jun 21, 2023
dd16966
CADC-12356 Added code to hide the Terminal from Applications->System …
yeunga Jun 21, 2023
9e15882
CADC-12356 Removed desktop-config and use curl command to get the k8s…
yeunga Jun 27, 2023
b793f48
CADC-12356 Cleaned up start-software-sh.template. Updated skaha-deskt…
yeunga Jun 28, 2023
4844bc3
CADC-12356 Cleaned up catalina.properties files in skaha/config.
yeunga Jun 28, 2023
7ce9028
CADC-12356 Updated check_status() in start-software-sh.template to pr…
yeunga Jun 30, 2023
751fe8a
CADC-12356 Changed user interaction in start-software-sh.template.
yeunga Jul 4, 2023
8a1c90d
CADC-12356 Updated error handling in start-software-sh.template.
yeunga Jul 6, 2023
574e90d
CADC-12356 Removed timer on user input prompt in start-software-sh.te…
yeunga Jul 6, 2023
f5502be
CADC-12356 Updated launch scripts and resource context.
yeunga Jul 6, 2023
c758be4
CADC-12356 Resolved merge conflicts.
yeunga Jul 11, 2023
58e58ca
CADC-12356 Updated user prompts in start-software-sh.template.
yeunga Jul 12, 2023
7cd5a43
CADC-12356 Fixed syntax errors in start-software-sh.template.
yeunga Jul 12, 2023
982173f
CADC-12356 Fixed title in software-sh.template.
yeunga Jul 12, 2023
9fb307e
CADC-12356 Changed the way we handle desktop app launch failures.
yeunga Jul 17, 2023
7011614
CADC-12356 Added more log messages.
yeunga Jul 17, 2023
6d29b3d
CADC-12356 Updated desktop app launcher to retry indefinitely on erro…
yeunga Jul 18, 2023
bcd7106
CADC-12356 Removed unnecessary statements from desktop app launcher s…
yeunga Jul 18, 2023
0318cd7
cadc-12356 Minor update to desktop app launcher.
yeunga Jul 18, 2023
0c7161a
CADC-12356 Added a 1 sec delay to allow time for a user to read the s…
yeunga Jul 18, 2023
85744a2
CADC-12356 Resolved merge conflicts.
yeunga Jul 21, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ LABEL io.k8s.description="Headless VNC Container with Xfce window manager, firef
io.openshift.non-scalable=true

# BM: Install fonts so remote displays work
RUN yum update -y && yum install -y xorg-x11-fonts* gedit rsync gimp gimp-gmic
RUN yum update -y && yum install -y xorg-x11-fonts* gedit rsync gimp gimp-gmic gnome-terminal epel-release
RUN yum update -y && yum install -y jq
yeunga marked this conversation as resolved.
Show resolved Hide resolved

## Connection ports for controlling the UI:
# VNC port:5901
Expand Down
2 changes: 1 addition & 1 deletion containers/session-containers/skaha-desktop/VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## deployable containers have a semantic and build tag
# semantic version tag: major.minor
# build version tag: timestamp
TAGS="1.0.2 $(date -u +"%Y%m%dT%H%M%S")"
TAGS="1.1.0 $(date -u +"%Y%m%dT%H%M%S")"
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,25 @@
</Or>
<Not><Category>Settings</Category></Not>
<Not><Category>Screensaver</Category></Not>
<Not><Category>TerminalEmulator</Category></Not>
<Not><Filename>gpk-application.desktop</Filename></Not>
<Not><Filename>gpk-update-viewer.desktop</Filename></Not>
<Not><Filename>xfce4-session-logout.desktop</Filename></Not>
</And>
</Include>
<Exclude>
<Or>
<Filename>xfce4-session-logout.desktop</Filename>
</Or>
</Exclude>
</Menu>

<Menu>
<Name>Other</Name>
<Directory>xfce-other.directory</Directory>
<OnlyUnallocated/>
<Include>
<All/>
<And>
<Or>
<All/>
</Or>
<Not><Category>TerminalEmulator</Category></Not>
</And>
</Include>
</Menu>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ init () {
mkdir -p ${XFCE_DESKTOP_DIR_PARENT}
ln -s ${DESKTOP_DIR} ${XFCE_DESKTOP_DIR}
fi

# sleep-forever.sh is used on desktop-app start up, refer to start-software-sh.template
cp /skaha-system/sleep-forever.sh ${EXECUTABLE_DIR}/.
}

build_resolution_items () {
Expand Down Expand Up @@ -131,11 +134,15 @@ build_menu_item () {
name=$2
category=$3
executable="${EXECUTABLE_DIR}/${name}.sh"
start_executable="${EXECUTABLE_DIR}/start-${name}.sh"
desktop="${DESKTOP_DIR}/${name}.desktop"
cp ${STARTUP_DIR}/software-sh.template $executable
cp ${STARTUP_DIR}/start-software-sh.template ${start_executable}
cp ${STARTUP_DIR}/software-category.template $desktop
sed -i -e "s#(IMAGE_ID)#${image_id}#g" $executable
sed -i -e "s#(NAME)#${name}#g" $executable
sed -i -e "s#(IMAGE_ID)#${image_id}#g" ${start_executable}
sed -i -e "s#(NAME)#${name}#g" ${start_executable}
sed -i -e "s#(NAME)#${name}#g" $desktop
sed -i -e "s#(EXECUTABLE)#${EXECUTABLE_DIR}#g" $desktop
sed -i -e "s#(CATEGORY)#${category}#g" $desktop
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# sleep forever
while true; do
sleep 1000
done
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

/opt/shibboleth/bin/curl -v -L -k -E ${HOME}/.ssl/cadcproxy.pem -d "image=(IMAGE_ID)" --data-urlencode "param=(NAME)" https://${skaha_hostname}/skaha/v0/session/${VNC_PW}/app
gnome-terminal -q --title="(NAME) launcher" -- ${HOME}/.local/skaha/bin/start-(NAME).sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#!/bin/bash

handle_error() {
echo "$1"
echo "Please enter Ctl+C when you are ready to exit the xterm."
${HOME}/.local/skaha/bin/sleep-forever.sh &
wait
exit 1
}

get_resource_options() {
resources=`curl -s -L -k -E ${HOME}/.ssl/cadcproxy.pem https://${skaha_hostname}/skaha/v0/context`
core_default=`echo $resources | jq .defaultCores`
core_options=`echo $resources | jq .availableCores[] | tr '\n' ' '`
ram_default=`echo $resources | jq .defaultRAM`
ram_options=`echo $resources | jq .availableRAM[] | tr '\n' ' '`
}

get_cores() {
local core_list=( ${core_options} )
for v in "${core_list[@]}"; do
local core_map[$v]=1
done

cores=${core_default}
local c=0
read -p "Please enter the number of cores (${core_options}) [${core_default}]: " input_cores
while (( c < 3 )); do
if [[ -z "${input_cores}" ]]; then
cores=${core_default}
echo "${cores}"
break
elif [[ -n "${core_map[${input_cores}]}" ]]; then
cores=${input_cores}
break
else
read -p "Please enter the number of cores (${core_options}) [${core_default}]: " input_cores
c=$(( c + 1 ))
fi
done

if (( c > 2 )); then
handle_error "Failed to get the number of cores from user."
fi
}

get_ram() {
local ram_list=( ${ram_options} )
for v in "${ram_list[@]}"; do
local ram_map[$v]=1
done

ram=${ram_default}
local c=0
read -p "Please enter the amount of memory in GB (${ram_options}) [${ram_default}]: " input_ram
while (( c < 3 )); do
if [[ -z "${input_ram}" ]]; then
ram=${ram_default}
echo "${ram}"
break
elif [[ -n "${ram_map[${input_ram}]}" ]]; then
ram=${input_ram}
break
else
read -p "Please enter the amount of memory in GB (${ram_options}) [${ram_default}]: " input_ram
c=$(( c + 1 ))
fi
done

if (( c > 2 )); then
handle_error "Failed to get the amount of ram from user."
fi
}

prompt_user() {
while true; do
read -p "Do you want to specify resources for (NAME)? (y/n) [n]" yn
if [[ -z "${yn}" || ${yn} == "n" || ${yn} == "N" ]]; then
echo "Launching (NAME)..."
app_id=`curl -s -L -k -E ${HOME}/.ssl/cadcproxy.pem -d "image=(IMAGE_ID)" --data-urlencode "param=(NAME)" https://${skaha_hostname}/skaha/v0/session/${VNC_PW}/app`
break
elif [[ ${yn} == "y" || ${yn} == "Y" ]]; then
get_resource_options || handle_error "Error obtaining resource defaults or options."
get_cores || handle_error "Error obtaining the number of cores to allocate."
get_ram || handle_error "Error obtaining the amount of ram to allocate."
echo "Launching (NAME)..."
app_id=`curl -s -L -k -E ${HOME}/.ssl/cadcproxy.pem -d "cores=${cores}" -d "ram=$ram" -d "image=(IMAGE_ID)" --data-urlencode "param=(NAME)" https://${skaha_hostname}/skaha/v0/session/${VNC_PW}/app`
break
else
echo invalid response
fi
done
}

launch_app() {
get_resource_options || handle_error "Error obtaining resource defaults or options."
prompt_user || handle_error "Error prompting user inputs."
}

get_status() {
curl_out=""
status=""
local n=0
sleep 1
curl_out=`curl -s -L -k -E ${HOME}/.ssl/cadcproxy.pem https://${skaha_hostname}/skaha/v0/session/${VNC_PW}/app/$1`
while [[ ${curl_out} != *"status"* ]]; do
n=$(( n + 1 ))
if test $n -eq 10 ; then
echo "Failed to get status, ${curl_out}, retrying..."
n=0
fi
sleep 1
curl_out=`curl -s -L -k -E ${HOME}/.ssl/cadcproxy.pem https://${skaha_hostname}/skaha/v0/session/${VNC_PW}/app/$1`
done
}

check_status() {
get_status $1
status=`echo ${curl_out} | jq .status`
echo "status: ${status}"
local count=0
while [[ ${status} == *"Pending"* ]]
do
count=$(( $count + 1 ))
get_status $1
status=`echo ${curl_out} | jq .status`
if test $count -eq 10 ; then
echo "status: ${status}"
count=0
fi
done

if [[ ${status} == *"Running"* ]]; then
echo "Successfully launched app."
sleep 1
else
handle_error "Failed to launch app, status is ${status}."
fi
}

launch_app
check_status ${app_id}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ configMapGenerator:
files:
- config/start-desktop.sh
- config/build-menu.sh
- config/sleep-forever.sh
- name: templates
files:
- config/templates/skaha-resolutions.properties
- config/templates/xfce-directory.template
- config/templates/xfce-applications-menu-item.template
- config/templates/software-sh.template
- config/templates/start-software-sh.template
- config/templates/software-category.template
- config/templates/resolution-sh.template
- config/templates/resolution-desktop.template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ ca.nrc.cadc.auth.PrincipalExtractor.enableClientCertHeader=true
ca.nrc.cadc.util.Log4jInit.messageOnly=true
# (default: ca.nrc.cadc.auth.NoOpIdentityManager)
ca.nrc.cadc.auth.IdentityManager=ca.nrc.cadc.auth.ACIdentityManager

Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# Defines the resources available to science containers
###

# Default number of cores when not specified
# Default number of requested cores when not specified
cores-default-request = 1

# Default maximum number of cores when not specified
cores-default-limit = 16

# Default number of cores (request=limit) when not specified
cores-default = 2

# Default cores for headless jobs
cores-default-headless = 1

# Default memory (RAM) in GB when not specified
# Default requested memory (RAM) in GB when not specified
mem-gb-default-request = 4

# Default maximum memory (RAM) in GB when not specified
mem-gb-default-limit = 192

# Default memory (RAM) in GB (request=limit) when not specified
mem-gb-default = 16

# Default RAM for headless jobs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: Job
metadata:
labels:
canfar-net-sessionID: "${skaha.sessionid}"
canfar-net-appID: "${software.appid}"
canfar-net-sessionType: "${skaha.sessiontype}"
canfar-net-userid: "${skaha.userid}"
name: "${software.jobname}"
Expand All @@ -14,6 +15,7 @@ spec:
metadata:
labels:
canfar-net-sessionID: "${skaha.sessionid}"
canfar-net-appID: "${software.appid}"
canfar-net-sessionType: "${skaha.sessiontype}"
canfar-net-userid: "${skaha.userid}"
job-name: "${software.jobname}"
Expand Down Expand Up @@ -51,12 +53,12 @@ spec:
imagePullPolicy: Always
resources:
requests:
memory: "4Gi"
cpu: "1"
memory: "${software.requests.ram}"
cpu: "${software.requests.cores}"
ephemeral-storage: "20Gi"
limits:
memory: "192Gi"
cpu: "16"
memory: "${software.limits.ram}"
cpu: "${software.limits.cores}"
ephemeral-storage: "200Gi"
ports:
- containerPort: 6000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
value: "ivo://cadc.nrc.ca/gms?skaha-users"
- name: skaha.adminsgroup
value: "ivo://cadc.nrc.ca/gms?skaha-admins"
image: images.canfar.net/skaha-system/skaha:0.11.1
image: images.canfar.net/skaha-system/skaha:0.12.0
imagePullPolicy: Always
#imagePullPolicy: IfNotPresent
name: skaha-tomcat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# Defines the resources available to science containers
###

# Default number of cores when not specified
# Default number of requested cores when not specified
cores-default-request = 1

# Default maximum number of cores when not specified
cores-default-limit = 8

# Default number of cores (request=limit) when not specified
cores-default = 2

# Default cores for headless jobs
cores-default-headless = 1

# Default memory (RAM) in GB when not specified
# Default requested memory (RAM) in GB when not specified
mem-gb-default-request = 4

# Default maximum memory (RAM) in GB when not specified
mem-gb-default-limit = 192

# Default memory (RAM) in GB (request=limit) when not specified
mem-gb-default = 16

# Default RAM for headless jobs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ kind: Job
metadata:
labels:
canfar-net-sessionID: "${skaha.sessionid}"
canfar-net-appID: "${software.appid}"
canfar-net-sessionType: "${skaha.sessiontype}"
canfar-net-userid: "${skaha.userid}"
name: "${software.jobname}"
Expand All @@ -14,6 +15,7 @@ spec:
metadata:
labels:
canfar-net-sessionID: "${skaha.sessionid}"
canfar-net-appID: "${software.appid}"
canfar-net-sessionType: "${skaha.sessiontype}"
canfar-net-userid: "${skaha.userid}"
job-name: "${software.jobname}"
Expand Down Expand Up @@ -51,12 +53,12 @@ spec:
imagePullPolicy: Always
resources:
requests:
memory: "4Gi"
cpu: "1"
memory: "${software.requests.ram}"
cpu: "${software.requests.cores}"
ephemeral-storage: "20Gi"
limits:
memory: "192Gi"
cpu: "8"
memory: "${software.limits.ram}"
cpu: "${software.limits.cores}"
ephemeral-storage: "200Gi"
ports:
- containerPort: 6000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
value: "345600"
- name: skaha.defaultquotagb
value: "10"
image: images-rc.canfar.net/skaha-system/skaha:0.11.1
image: images-rc.canfar.net/skaha-system/skaha:0.12.0
resources:
requests:
memory: "4Gi"
Expand Down
2 changes: 1 addition & 1 deletion skaha/VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## deployable containers have a semantic and build tag
# semantic version tag: major.minor
# build version tag: timestamp
TAGS="0.11.1 $(date -u +"%Y%m%dT%H%M%S")"
TAGS="0.12.0 $(date -u +"%Y%m%dT%H%M%S")"
Loading