Skip to content

Commit

Permalink
Added metrics widget to OOD demo app to deploy to Dev environments
Browse files Browse the repository at this point in the history
  • Loading branch information
abujeda committed Nov 5, 2024
1 parent 7d5ced8 commit 40beefc
Show file tree
Hide file tree
Showing 24 changed files with 189 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ build_latest_ood:
# BUILD OOD WITH SID OOD IMAGE
#docker run --rm -v $(WORKING_DIR):/usr/local/app -w /usr/local/app $(SID_OOD_IMAGE) ./ood_build.sh
# BUILD OOD WITH ROCKY8 IMAGE
cp -f config/local/.env ondemand/apps/dashboard
cp -R config/local/dashboard/. ondemand/apps/dashboard
docker run --rm -v $(WORKING_DIR):/usr/local/app -w /usr/local/app -e ROOT_URL=$(ROOT_URL) $(SID_BUILDER_IMAGE) ./ood_build.sh
build_system_demo build_user_demo: build_latest_ood
# COPY DEMO CONFIGURATION
cp -R config/demo/. ondemand/apps/dashboard
# COPY METRICS WIDGET
mkdir -p ondemand/apps/dashboard/plugins
cp -R dev/metrics ondemand/apps/dashboard/plugins/metrics

start_ood_installer:
docker create --rm --name ood_installer --privileged -p 43000:443 ood_puppet:5.0.1
Expand Down
1 change: 1 addition & 0 deletions config/demo/.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ ENABLE_NATIVE_VNC=true
OOD_DATAROOT_BAK=~/.fasrcood/data/sys/dashboard
OOD_VERSION=latest
OOD_CONFIG_D_DIRECTORY=app_overrides/ondemand.d
OOD_PLUGINS_DIRECTORY=plugins
OOD_LOAD_EXTERNAL_CONFIG=true
OOD_APP_CONFIG_ROOT=app_overrides
7 changes: 7 additions & 0 deletions config/demo/app_overrides/ondemand.d/metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
custom_pages:
metrics:
rows:
- columns:
- width: 12
widgets:
- "metrics/metrics"
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SessionsHelper extension to support TurboVNC and KVM
# frozen_string_literal: true
# ConfigurationSingleton extension
Rails.application.config.after_initialize do
Rails.logger.info 'Executing Configuration extension ...'
class ConfigurationSingleton
Expand Down
6 changes: 6 additions & 0 deletions config/local/app_overrides/jobs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Create Slurm Data For Metrics
Execute the following script to create jobs in Slurm and generate metrics data:
- `/etc/ood/config/apps/ood/jobs/submit_jobs.sh`

The script will take some time to complete.
Check the status of the jobs in the active jobs page in OOD: https://localhost:33000/pun/sys/ood/activejobs
18 changes: 18 additions & 0 deletions config/local/app_overrides/jobs/example_job.sbatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
#SBATCH --time=00:05:00
#SBATCH --mail-type=NONE

case $MODE in
'stress')
srun yes > /dev/null
;;
'sleep')
srun sleep 120
;;
'timeout')
srun sleep 100000
;;
*)
exit 1
;;
esac
12 changes: 12 additions & 0 deletions config/local/app_overrides/jobs/submit_jobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

users='ood'
opmodes='sleep stress timeout'

for ((node_count=1; node_count <= 2; node_count++)); do
for user in $users; do
for mode in $opmodes; do
su - ood -c "sbatch -n $node_count --job-name=$user_$script_$node_count --export='ALL,MODE='$mode /etc/ood/config/apps/ood/jobs/example_job.sbatch"
done
done
done
File renamed without changes.
62 changes: 62 additions & 0 deletions config/local/dashboard/config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# CUSTOM VERSION OF THE config/application.rb FILE TO LOAD CUSTOMIZATIONS AS PLUGINS
# EASIER TO DEPLOY AND DEVELOP LOCALLY
require_relative 'boot'

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
# require "action_mailbox/engine"
# require "action_text/engine"
require "action_view/railtie"
# require "action_cable/engine"
require "sprockets/railtie"
require "rails/test_unit/railtie"

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Dashboard
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults(7.0)

# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")

config.autoload_paths << Rails.root.join('lib')

# Locales are handled in config/initializers/locales.rb.

# Custom error pages
config.exceptions_app = self.routes

if ::Configuration.load_external_config?
# Ensuring OOD initializers run last so that user's cannot override what we
# specify unless we allow the override as well in our own initializers.
config.paths["config/initializers"] << ::Configuration.config_root.join("initializers").to_s
config.autoload_paths << ::Configuration.config_root.join("lib").to_s
config.paths["app/views"].unshift ::Configuration.config_root.join("views").to_s
end

# Enable installed plugins
plugins_dir = Pathname.new(ENV['OOD_PLUGINS_DIRECTORY'] || '/var/www/ood/apps/plugins')
if plugins_dir.directory?
plugins_dir.children.select(&:directory?).each do |installed_plugin|
config.paths["config/initializers"] << installed_plugin.join("initializers").to_s
config.autoload_paths << installed_plugin.join("lib").to_s
config.paths["app/views"].unshift installed_plugin.join("views").to_s
end
end
end
end
41 changes: 41 additions & 0 deletions dev/metrics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## IQSS Metrics Widget For OnDemand
Open OnDemand metrics widget displaying information about fairshare, job status summary, memory, CPU, GPU, and time. Data is retrieved directly from Slurm using the `sacct` and `sshare` commands.

The metrics widget consist of four panels:
- Fairshare
- CPU Jobs by state
- GPU Jobs by state
- Jobs Stats Summary

### Implementation Summary
The implementation consist of three components
- OOD Slurm adapter extension
- ./initializers/slurm_extension.rb
- Metrics calculations utility classes
- ./lib/slurm_metrics
- Metrics widget templates
- ./views/widgets/metrics

### Deployment
Using the customization feature from OnDemand, with the default location under: `/etc/ood/config/apps/dashboard`
- copy `./initializers/slurm_extension.rb` into `/etc/ood/config/apps/dashboard/intializers`
- copy `./lib/slurm_metrics` into `/etc/ood/config/apps/dashboard/lib`
- copy `./views/widgets/metrics` into `/etc/ood/config/apps/dashboard/views/widgets`

Restart the OnDemand application for the customizations to take effect.

### Deployment With FASRC Puppet
The widget components need to be deployed using FASRC Puppet control repo. We are already using the OOD Puppet module feature to add files to the OOD dashboard location to add/extend functionality:
`openondemand::apps_config_source:`

The folder that we are deploying is: `site-modules/profile/files/openondemand/common/apps_config`

In the Puppet control repo, we need to add the files for the three components to the following folders:
- site-modules/profile/files/openondemand/common/apps_config/dashboard/intializers
- site-modules/profile/files/openondemand/common/apps_config/dashboard/lib
- site-modules/profile/files/openondemand/common/apps_config/dashboard/views/widgets

To review and test the new widget, we could use a custom page to display it. This is a sample configuration:
https://github.com/hmdc/ondemand_development/blob/main/config/local/ondemand.d/metrics.yml

This will create a custom page under: `/pun/sys/dashboard/custom/metrics
File renamed without changes.
7 changes: 7 additions & 0 deletions dev/metrics/metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
custom_pages:
metrics:
rows:
- columns:
- width: 12
widgets:
- "metrics/metrics"
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ services:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- ./data:/home/ood/ondemand/data
- ./ondemand/apps/dashboard:/var/www/ood/apps/sys/ood
- ./config/local/.env:/var/www/ood/apps/sys/ood/.env
- ./config/local/dashboard/.env:/var/www/ood/apps/sys/ood/.env
- ./config/local/public:/var/www/ood/public
- ./config/local/ondemand.d:/etc/ood/config/ondemand.d
- ./config/local/app_overrides:/etc/ood/config/apps/ood
- ./dev/metrics:/var/www/ood/apps/plugins/metrics
ports:
- "33000:443"
expose:
Expand Down
27 changes: 27 additions & 0 deletions docs/fasrc_puppet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### FASRC Puppet YAML Hierarchy
```yaml
hierarchy:
- name: "Secret data (encrypted)"
lookup_key: eyaml_lookup_key
paths:
- "nodes/%{trusted.certname}.yaml"
- "secrets/%{trusted.certname}.yaml"
- "nodes/%{hostname}.yaml"
- "secrets/%{hostname_base}.yaml"
- "nodes/%{hostname_base}.yaml"
- "ib_islands/%{::ib_island}.yaml"
- "vlans/%{vlan}.yaml"
- "vlans/%{vlan}_%{facts.os.family}_%{facts.os.release.major}.yaml"
- "cluster/%{cluster}.yaml"
- "groups/%{group}.yaml"
- "kempner_%{kempner}.yaml"
- "datacenter/%{datacenter}/proxy_%{needs_proxy}.yaml"
- "datacenter/%{datacenter}.yaml"
- "security_level/level%{security_level}/%{facts.os.family}/%{facts.os.release.major}.yaml"
- "os/%{facts.os.family}.yaml"
- "os/%{facts.os.family}/%{facts.os.release.major}.yaml"
- 'common/mounts.yaml'
- "common/is_virtual_%{is_virtual}.yaml"
- 'common/common.yaml'
- "secrets/common.yaml"
```

0 comments on commit 40beefc

Please sign in to comment.