Hello, we could use a bit of help adding a /scratch shortcut to our files menu. None of us know the first thing about Ruby so I apologize for what may be a pretty novice question for others.
We’ve tried the examples listed here and haven’t had much luck: Customizations — Open OnDemand 4.0.0 documentation. Basically, every time we try to implement one of the examples or make changes to one of the examples, nothing shows up underneath our Files menus. Just the home directory by default.
Basically, our /scratch folders are set up as follows:
We have several domains accessing our OOD site, and each scratch directory is grouped by that user’s domain, then the user’s scratch folder is under their respective domain
I don’t know if this complicates things, but technically, when a user signs in, their login name shows up as username@domain1.local. Their scratch directory in their respective subfolder just says ‘username’ and username@domain1.local owns it. I don’t know if we’re running into an issue where OOD sees the username differently from what their scratch directory is actually named, and that’s why nothing shows up?
Any direction on this would be greatly appreciated. Thank you.
Jeff, this is what we were using on our old cluster that worked previously, though we only had one domain.
# /etc/ood/config/apps/dashboard/initializers/ood.rb
OodFilesApp.candidate_favorite_paths.tap do |paths|
paths << FavoritePath.new("/scratch/domain1/#{User.new.name}")
end
Thanks Jeff, yes, it does contain a username on the end i.e. username@domain.local. Is there an easy way to script it to drop the domain.local so it finds that user’s scratch directory without it?
Yea here’s how you can do that, you can call split on the string. Here’s a little program I made to demonstrate this. IDK if you want domain1 in the scratch path or domain1.local so I’ve given both here.
require 'etc'
# login should be Etc.getlogin
login = 'johrstrom@domain1.local'
basename, domain = login.split('@')
puts "/scratch/#{domain}/#{basename}"
# you want domain1 not 'domain1.local'
no_local_domain = domain.split('.').first
puts "/scratch/#{no_local_domain}/#{basename}"
Jeff, thank you! That’s really helpful. The top part of the script returns what it should. However, we still don’t see the /scratch directory showing up in the files menu in OOD. Do we need to have the initializer set up like this for instance? We tried the top part of the script you sent as well, and that didn’t work either. Trying to figure out what we might be missing.
require 'etc'
login = Etc.getlogin
basename, domain = login.split('@')
Rails.application.config.after_initialize do
OodFilesApp.candidate_favorite_paths.tap do |paths|
# add User scratch space directory
paths << FavoritePath.new("/scratch/#{domain}/#{basename}")
puts #{paths}
end
end
Jeff, that’s interesting. We aren’t using allowlists (left everything there default) so everything should be accessible. And, user scratch directories are readable/executable. I can log in to the OOD node and navigate to my /scratch directory via the command line. I’m restarting the web server every time I make a change. If there’s nothing else that could potentially be affecting this, we can continue to chip away at it on our side.
Maybe you can redefine that method to see some debug logs. You can try something like this and name it 00_fav_paths.rb because these run in order, so this will run before ood.rb.
This will spit out what the list is before filtering and detail if you’re keeping the path.
Rails.application.config.after_initialize do
class OodFilesApp
def favorite_paths
Rails.logger.info("favorite paths are currently: #{candidate_favorite_paths.inspect}")
@favorite_paths ||= candidate_favorite_paths.select do |p|
if p.remote?
true
else
keep = AllowlistPolicy.default.permitted?(p.path) && p.path.directory? && p.path.readable? && p.path.executable?
Rails.logger.info("Keeping #{p}? #{keep}")
keep
end
end
end
end
end
Thanks again Jeff! It’s working now - silly NFS config issue we overlooking. This is going to improve the user experience for sure. I really appreciate the example and your willingness to help us out with this.