diff --git a/lib/ood_core/job/adapters/lsf.rb b/lib/ood_core/job/adapters/lsf.rb index d39681b1b..6f5a59823 100644 --- a/lib/ood_core/job/adapters/lsf.rb +++ b/lib/ood_core/job/adapters/lsf.rb @@ -11,6 +11,7 @@ class Factory # @option config [#to_s] :libdir ('') Path to lsf client lib dir # @option config [#to_s] :envdir ('') Path to lsf client conf dir # @option config [#to_s] :serverdir ('') Path to lsf client etc dir + # @option config [#to_s] :cluster ('') name of cluster, if in multi-cluster mode def self.build_lsf(config) batch = Adapters::Lsf::Batch.new(config.to_h.symbolize_keys) Adapters::Lsf.new(batch: batch) diff --git a/lib/ood_core/job/adapters/lsf/batch.rb b/lib/ood_core/job/adapters/lsf/batch.rb index 3d0e3a2b9..991ec9051 100644 --- a/lib/ood_core/job/adapters/lsf/batch.rb +++ b/lib/ood_core/job/adapters/lsf/batch.rb @@ -2,19 +2,20 @@ # # @api private class OodCore::Job::Adapters::Lsf::Batch - attr_reader :bindir, :libdir, :envdir, :serverdir + attr_reader :bindir, :libdir, :envdir, :serverdir, :cluster # The root exception class that all LSF-specific exceptions inherit # from class Error < StandardError; end # @param bin [#to_s] path to LSF installation binaries - def initialize(bindir: "", envdir: "", libdir: "", serverdir: "", **_) + def initialize(bindir: "", envdir: "", libdir: "", serverdir: "", cluster: "", **_) @bindir = Pathname.new(bindir.to_s) @envdir = Pathname.new(envdir.to_s) @libdir = Pathname.new(libdir.to_s) @serverdir = Pathname.new(serverdir.to_s) + @cluster = cluster.to_s end def default_env @@ -127,11 +128,19 @@ def parse_bsub_output(response) end end + def cluster_args + if cluster.nil? || cluster.strip.empty? + [] + else + ["-m", cluster] + end + end + private # Call a forked Lsf command for a given cluster def call(cmd, *args, env: {}, stdin: "") cmd = bindir.join(cmd.to_s).to_s - #TODO: args = ["-m", cluster] + args.map(&:to_s) + args = cluster_args + args env = default_env.merge(env.to_h) o, e, s = Open3.capture3(env, cmd, *(args.map(&:to_s)), stdin_data: stdin.to_s) s.success? ? o : raise(Error, e) diff --git a/spec/job/adapters/lsf/batch_spec.rb b/spec/job/adapters/lsf/batch_spec.rb index 1c3b47be9..857cdb790 100644 --- a/spec/job/adapters/lsf/batch_spec.rb +++ b/spec/job/adapters/lsf/batch_spec.rb @@ -195,4 +195,31 @@ )} end end + + describe "multinode" do + subject(:batch) { described_class.new(config).cluster_args } + context "when cluster not set" do + let(:config) { + { + bindir: "/opt/lsf/8.3/bin", + libdir: "/opt/lsf/8.3/lib", + envdir: "/opt/lsf/conf", + serverdir: "/opt/lsf/8.3/etc" + } + } + it { is_expected.to eq([]) } + end + context "when cluster not set" do + let(:config) { + { + bindir: "/opt/lsf/8.3/bin", + libdir: "/opt/lsf/8.3/lib", + envdir: "/opt/lsf/conf", + serverdir: "/opt/lsf/8.3/etc", + cluster: "curie" + } + } + it { is_expected.to eq(["-m", "curie"]) } + end + end end