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

3081: auto_environment_variable smart attr for scripts #3230

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0786594
WIP: Starts auto_environment_variable smart attr for scripts
HazelGrant Dec 6, 2023
b9d5fdf
Fixes broken test
HazelGrant Dec 6, 2023
75c3c72
remove el7 from the CI (#3232)
johrstrom Dec 6, 2023
13b5843
lint a random file (#3234)
osc-bot Dec 7, 2023
717c32d
remove featured routes and views (#3231)
johrstrom Dec 7, 2023
8246f3d
add test for DOS encoded files (#3228)
johrstrom Dec 7, 2023
12f2cfe
Ensures auto_environment_variable is picked up in the form correctly
HazelGrant Dec 7, 2023
06e0ec9
Changes strategy for auto_environment_variable
HazelGrant Dec 7, 2023
c359f7c
enhance this helper for building test assets (#3238)
johrstrom Dec 7, 2023
fbcc2b3
update dependencies (#3245)
osc-bot Dec 11, 2023
7f365e9
Update Changelog (#3244)
osc-bot Dec 11, 2023
86f2c50
Fixes to SettingsController after CurrentUser settings refactoring (#…
abujeda Dec 11, 2023
88efd9e
fix cache key for path selector (#3247)
johrstrom Dec 12, 2023
3292b1f
lint a random file (#3243)
osc-bot Dec 12, 2023
7fe8208
lint a random file (#3250)
osc-bot Dec 13, 2023
fe9a2da
Display errors in projects show page when fetching job information (#…
abujeda Dec 13, 2023
fdf234d
WIP - reads auto_environment_variable values to_yaml correctly
HazelGrant Dec 11, 2023
b688eb3
Allows multiple environment variables
HazelGrant Dec 13, 2023
8dac86d
Fixes failing specs
HazelGrant Dec 13, 2023
9cd0f01
fix the CI for new chrome version (#3256)
johrstrom Dec 19, 2023
d0c3788
bc apps rsync with safer args (#3239)
johrstrom Dec 19, 2023
ef3dd02
Added cluster validation to projects.show page to disable script acti…
abujeda Dec 20, 2023
36454ff
only test the first 5 so we dont have to update these all the time (#…
johrstrom Dec 20, 2023
bf38433
update dependencies (#3261)
osc-bot Dec 20, 2023
f5b404d
lint a random file (#3265)
osc-bot Dec 27, 2023
645b5bb
update dependencies (#3267)
osc-bot Dec 27, 2023
3910052
Update Changelog (#3266)
osc-bot Dec 27, 2023
b99394c
Adding custom completed.{md, html}.erb (#3269)
canoalberto Dec 27, 2023
748d0cd
update dependencies (#3272)
osc-bot Jan 2, 2024
4fcb9bc
lint a random file (#3270)
osc-bot Jan 2, 2024
85d8e5b
Update Changelog (#3271)
osc-bot Jan 2, 2024
8aa5bea
Improvements to automatic profile selection (#3252)
abujeda Jan 2, 2024
20283d3
Added support for multiple domains for Apache config in portal gener…
abujeda Jan 2, 2024
f97c901
refactor session_time method with partial (#3229)
akuppa9 Jan 2, 2024
c750ad2
correctly handle options that start with numbers (#3241)
johrstrom Jan 2, 2024
5ae612e
add the config option to disable uploads and downloads (#3236)
johrstrom Jan 2, 2024
5170447
path selector bugfix (#3274)
johrstrom Jan 3, 2024
a23c2f7
refactor completed_view method (#3277)
akuppa9 Jan 5, 2024
d2ae0ee
WIP: Starts auto_environment_variable smart attr for scripts
HazelGrant Dec 6, 2023
d60d112
Fixes broken test
HazelGrant Dec 6, 2023
68f5061
Ensures auto_environment_variable is picked up in the form correctly
HazelGrant Dec 7, 2023
4d91db8
Changes strategy for auto_environment_variable
HazelGrant Dec 7, 2023
2a3148d
WIP - reads auto_environment_variable values to_yaml correctly
HazelGrant Dec 11, 2023
ce00d63
Allows multiple environment variables
HazelGrant Dec 13, 2023
8f8c4b6
Fixes failing specs
HazelGrant Dec 13, 2023
c84c098
WIP
HazelGrant Jan 8, 2024
51015da
WIP - bundle install
HazelGrant Jan 8, 2024
7d992b5
Merge branch '3081-pm-scripts-support-env-vars' of https://github.com…
HazelGrant Jan 8, 2024
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
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ jobs:
- name: Run ShellCheck
run: bundle exec rake test:shellcheck

- name: Check file encodings
run: bundle exec rake test:unix

- name: Run Zeitwerk check
run: |
cd apps/dashboard
Expand Down Expand Up @@ -114,7 +117,6 @@ jobs:
matrix:
os: [ubuntu-22.04]
dist:
- el7
- el8
- el9
- amzn2023
Expand Down
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build-nightly:
- bundle exec rake package:build[$OOD_PACKAGING_DIST,$OOD_PACKAGING_ARCH,true]
parallel:
matrix:
- OOD_PACKAGING_DIST: [el7, el8]
- OOD_PACKAGING_DIST: [el8]
OOD_PACKAGING_ARCH: [x86_64, aarch64, ppc64le]
OOD_PACKAGING_GPG_PRIVATE_KEY: /systems/osc_certs/gpg/ondemand/ondemand.sec
- OOD_PACKAGING_DIST: [el9, debian-12]
Expand Down Expand Up @@ -51,7 +51,7 @@ build:
- bundle exec rake package:build[$OOD_PACKAGING_DIST,$OOD_PACKAGING_ARCH]
parallel:
matrix:
- OOD_PACKAGING_DIST: [el7, el8]
- OOD_PACKAGING_DIST: [el8]
OOD_PACKAGING_ARCH: [x86_64, aarch64, ppc64le]
OOD_PACKAGING_GPG_PRIVATE_KEY: /systems/osc_certs/gpg/ondemand/ondemand.sec
- OOD_PACKAGING_DIST: [el9, debian-12]
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Admins can now set a `default_profile` in [3200](https://github.com/OSC/ondemand/pull/3200).
- The files table now has a select all checkbox in [3212](https://github.com/OSC/ondemand/pull/3212).
- Centers can now disable shell links at the app level in [3206](https://github.com/OSC/ondemand/pull/3206).
- Added a rake task to determine ensure unix file formats in [3227](https://github.com/OSC/ondemand/pull/3227).
- Batch Connect apps can now provide a completed.{md, html}.erb in [3269](https://github.com/OSC/ondemand/pull/3269).

### Fixed
- Develop menu now correctly shows/hides when given a configuration in [2848](https://github.com/OSC/ondemand/pull/2848).
Expand All @@ -48,6 +50,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- auto_modules can correctly set their label in [3139](https://github.com/OSC/ondemand/pull/3139).
- Gnome desktops correctly work in [3188](https://github.com/OSC/ondemand/pull/3188).
- `staged_root` is created as 700 to ensure it's writable by the user in [3202](https://github.com/OSC/ondemand/pull/3202).
- MOTD correclty shows up in custom pages in [3216](https://github.com/OSC/ondemand/pull/3216).
- Open OnDemand no longer builds el7 packages in [3232](https://github.com/OSC/ondemand/pull/3232).
- BatchConnect apps now use rsync with safer arguments in [3239](https://github.com/OSC/ondemand/pull/3239).

### Changed
- Open OnDemand now requires NodeJS 18 and Ruby 3.1 on applicable platforms in [2885](https://github.com/OSC/ondemand/pull/2885).
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gem 'sdoc', group: :doc, require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'pry'
gem 'climate_control', '~> 0.2'
gem 'timecop', '~> 0.9'
end
Expand Down
26 changes: 14 additions & 12 deletions apps/dashboard/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.5)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
autoprefixer-rails (10.2.5.1)
execjs (> 0)
base64 (0.2.0)
bootstrap_form (4.5.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
Expand Down Expand Up @@ -137,7 +138,7 @@ GEM
method_source (1.0.0)
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.1003)
mime-types-data (3.2023.1205)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.20.0)
Expand Down Expand Up @@ -173,12 +174,13 @@ GEM
ood_support (0.0.5)
pbs (2.2.1)
ffi (~> 1.9, >= 1.9.6)
psych (5.1.1.1)
psych (5.1.2)
stringio
public_suffix (5.0.4)
racc (1.7.3)
rack (2.2.8)
rack-protection (3.1.0)
rack-protection (3.2.0)
base64 (>= 0.1.0)
rack (~> 2.2, >= 2.2.4)
rack-test (2.1.0)
rack (>= 1.3)
Expand Down Expand Up @@ -211,10 +213,10 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
rake (13.1.0)
rdoc (6.6.0)
rdoc (6.6.2)
psych (>= 4.0.0)
redcarpet (3.6.0)
regexp_parser (2.8.2)
regexp_parser (2.8.3)
request_store (1.5.1)
rack (>= 1.4)
rest-client (2.1.0)
Expand All @@ -234,16 +236,16 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sinatra (3.1.0)
sinatra (3.2.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.1.0)
rack-protection (= 3.2.0)
tilt (~> 2.0)
sinatra-contrib (3.1.0)
multi_json
sinatra-contrib (3.2.0)
multi_json (>= 0.0.2)
mustermann (~> 3.0)
rack-protection (= 3.1.0)
sinatra (= 3.1.0)
rack-protection (= 3.2.0)
sinatra (= 3.2.0)
tilt (~> 2.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
Expand Down
Binary file added apps/dashboard/app/assets/images/favicon.ico
Binary file not shown.
8 changes: 8 additions & 0 deletions apps/dashboard/app/assets/stylesheets/projects.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@
text-decoration: none !important;
}
}

.job-info {
cursor: default;
}

.job-info .job-info-description{
display: block;
}
11 changes: 0 additions & 11 deletions apps/dashboard/app/controllers/apps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ def index
set_metadata_columns
end

def featured
if OodSupport::Process.groups_changed?
redirect_to apps_restart_url
else
@title = nil
@groups = OodAppGroup.groups_for(apps: nav_usr_apps)
set_motd
set_my_quotas
end
end

def restart
end

Expand Down
25 changes: 20 additions & 5 deletions apps/dashboard/app/controllers/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def fs
if @path.directory?
@path.raise_if_cant_access_directory_contents

request.format = 'zip' if params[:download]
request.format = 'zip' if download?

respond_to do |format|

Expand All @@ -25,7 +25,12 @@ def fs
response.headers['Cache-Control'] = 'no-store'
if params[:can_download]
# check to see if this directory can be downloaded as a zip
can_download, error_message = @path.can_download_as_zip?
can_download, error_message = if ::Configuration.download_enabled?
@path.can_download_as_zip?
else
[false, t('dashboard.files_download_not_enabled')]
end

render json: { can_download: can_download, error_message: error_message }
else
@files = @path.ls
Expand All @@ -39,7 +44,11 @@ def fs
# and we can avoid rescuing in a block so we can reintroduce
# the block braces which is the Rails convention with the respond_to formats.
format.zip do
can_download, error_message = @path.can_download_as_zip?
can_download, error_message = if ::Configuration.download_enabled?
@path.can_download_as_zip?
else
raise(StandardError, t('dashboard.files_download_not_enabled'))
end

if can_download
zipname = @path.basename.to_s.gsub('"', '\"') + '.zip'
Expand Down Expand Up @@ -211,6 +220,10 @@ def posix_file?
@path.is_a?(PosixFile)
end

def download?
params[:download]
end

def uppy_upload_path
# careful:
#
Expand All @@ -226,6 +239,8 @@ def uppy_upload_path
end

def show_file
raise(StandardError, t('dashboard.files_download_not_enabled')) unless ::Configuration.download_enabled?

if posix_file?
send_posix_file
else
Expand All @@ -237,7 +252,7 @@ def send_posix_file
type = Files.mime_type_by_extension(@path).presence || PosixFile.new(@path).mime_type

# svgs aren't safe to view until we update our CSP
if params[:download] || type.to_s == 'image/svg+xml'
if download? || type.to_s == 'image/svg+xml'
type = 'text/plain; charset=utf-8' if type.to_s == 'image/svg+xml'
send_file @path, type: type
else
Expand All @@ -261,7 +276,7 @@ def send_remote_file
end

# svgs aren't safe to view until we update our CSP
download = params[:download] || type.to_s == "image/svg+xml"
download = download? || type.to_s == "image/svg+xml"
type = "text/plain; charset=utf-8" if type.to_s == "image/svg+xml"

response.set_header('X-Accel-Buffering', 'no')
Expand Down
2 changes: 2 additions & 0 deletions apps/dashboard/app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def show
redirect_to(projects_path, alert: I18n.t('dashboard.jobs_project_not_found', project_id: project_id))
else
@scripts = Script.all(@project.directory)
@valid_project = Script.clusters?
flash.now[:alert] = I18n.t("dashboard.jobs_project_invalid_configuration_clusters") unless @valid_project
end
end

Expand Down
10 changes: 7 additions & 3 deletions apps/dashboard/app/controllers/scripts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

require 'pry'
# The controller for apps pages /dashboard/projects/:project_id/scripts
class ScriptsController < ApplicationController

Expand Down Expand Up @@ -45,7 +45,7 @@ def destroy
end
end

# POST /projects/:project_id/scripts/:id/save
# POST /projects/:project_id/:id/save
# save the script after editing
def save
@script.update(save_script_params[:script])
Expand Down Expand Up @@ -90,7 +90,11 @@ def submit_script_params
end

def save_script_params
params.permit({ script: SAVE_SCRIPT_KEYS }, :project_id, :id)
params.permit({ script: SAVE_SCRIPT_KEYS + auto_environment_variable_params }, :project_id, :id)
end

def auto_environment_variable_params
params[:script].keys.select { |key| key.match("auto_environment_variable") }
end

def find_project
Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/app/controllers/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

# The Controller for user level settings /dashboard/settings.
class SettingsController < ApplicationController
include UserSettingStore
ALLOWED_SETTINGS = [:profile].freeze

def update
new_settings = read_settings(settings_param)
CurrentUser.update_user_settings(new_settings) unless new_settings.empty?
update_user_settings(new_settings) unless new_settings.empty?

logger.info "settings: updated user settings to: #{new_settings}"
respond_to do |format|
Expand Down
8 changes: 8 additions & 0 deletions apps/dashboard/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ def fa_icon(icon, fa_style: 'fas', id: '', classes: 'app-icon', title: "FontAwes
title: title, "aria-hidden": true)
end

def favicon
if Rails.env.production?
favicon_link_tag('favicon.ico', href: @user_configuration.public_url.join('favicon.ico'), skip_pipeline: true)
else
favicon_link_tag('favicon.ico')
end
end

def app_icon_tag(app)
if app.image_icon?
image_tag app.icon_uri, class: 'app-icon', title: app.icon_path
Expand Down
38 changes: 19 additions & 19 deletions apps/dashboard/app/helpers/batch_connect/sessions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ def session_view(session)
concat content_tag(:div, cancel_or_delete(session), class: 'float-right')
concat host(session)
concat created(session)
concat session_time(session)
concat render_session_time(session)
concat id(session)
concat support_ticket(session) unless @user_configuration.support_ticket.empty?
concat display_choices(session)
safe_concat custom_info_view(session) if session.app.session_info_view
safe_concat completed_view(session) if session.app.session_completed_view && session.completed?
end
)
concat content_tag(:div) { yield }
Expand All @@ -68,35 +69,34 @@ def custom_info_view(session)
end
end

def completed_view(session)
render(partial: 'batch_connect/sessions/card/completed_view', locals: { session: session })
end

def created(session)
render(partial: 'batch_connect/sessions/card/created', locals: { session: session })
end

def session_time(session)
time_limit = session.info.wallclock_limit
time_used = session.info.wallclock_time

content_tag(:p) do
if session.starting? || session.running?
if time_limit && time_used
concat content_tag(:strong, t('dashboard.batch_connect_sessions_stats_time_remaining'))
concat " "
concat distance_of_time_in_words(time_limit - time_used, 0, false, :only => [:minutes, :hours], :accumulate_on => :hours)
elsif time_used
concat content_tag(:strong, t('dashboard.batch_connect_sessions_stats_time_used'))
concat " "
concat distance_of_time_in_words(time_used, 0, false, :only => [:minutes, :hours], :accumulate_on => :hours)
end
else # not starting or running
if time_limit
concat content_tag(:strong, t('dashboard.batch_connect_sessions_stats_time_requested'))
concat " "
concat distance_of_time_in_words(time_limit, 0, false, :only => [:minutes, :hours], :accumulate_on => :hours)
end
if session.starting? || session.running?
if time_limit && time_used
[t('dashboard.batch_connect_sessions_stats_time_remaining'), distance_of_time_in_words(time_limit - time_used, 0, false, :only => [:minutes, :hours], :accumulate_on => :hours)]
elsif time_used
[t('dashboard.batch_connect_sessions_stats_time_used'), distance_of_time_in_words(time_used, 0, false, :only => [:minutes, :hours], :accumulate_on => :hours)]
end
else
if time_limit
[t('dashboard.batch_connect_sessions_stats_time_requested'), distance_of_time_in_words(time_limit, 0, false, :only => [:minutes, :hours], :accumulate_on => :hours)]
end
end
end

def render_session_time(session)
render(partial: 'batch_connect/sessions/card/session_time', locals: { session: session })
end

def host(session)
render(partial: 'batch_connect/sessions/card/host', locals: { session: session })
end
Expand Down
Loading
Loading