Class: OodCore::Job::Adapters::Kubernetes
- Inherits:
-
OodCore::Job::Adapter
- Object
- OodCore::Job::Adapter
- OodCore::Job::Adapters::Kubernetes
- Defined in:
- lib/ood_core/job/adapters/kubernetes.rb
Overview
The adapter class for Kubernetes.
Defined Under Namespace
Modules: Resources Classes: Batch, Helper, K8sJobInfo
Instance Attribute Summary collapse
-
#batch ⇒ Object
readonly
Returns the value of attribute batch.
Instance Method Summary collapse
-
#delete(id) ⇒ void
Delete the submitted job.
-
#hold(id) ⇒ void
abstract
Put the submitted job on hold.
-
#info(id) ⇒ Info
abstract
Retrieve job info from the resource manager.
-
#info_all(attrs: nil) ⇒ Array<Info>
abstract
Retrieve info for all jobs from the resource manager.
-
#info_all_each(attrs: nil) {|Info| ... } ⇒ Enumerator
Iterate over each job Info object.
-
#info_where_owner(owner, attrs: nil) ⇒ Array<Info>
Retrieve info for all jobs for a given owner or owners from the resource manager.
-
#info_where_owner_each(owner, attrs: nil) {|Info| ... } ⇒ Enumerator
Iterate over each job Info object.
-
#initialize(batch) ⇒ Kubernetes
constructor
A new instance of Kubernetes.
-
#release(id) ⇒ void
abstract
Release the job that is on hold.
-
#status(id) ⇒ Status
abstract
Retrieve job status from resource manager.
-
#submit(script, after: [], afterok: [], afternotok: [], afterany: []) ⇒ String
abstract
Submit a job with the attributes defined in the job template instance.
-
#supports_job_arrays? ⇒ Boolean
Whether the adapter supports job arrays.
Methods inherited from OodCore::Job::Adapter
#accounts, #cluster_info, #directive_prefix, #job_name_illegal_chars, #nodes, #queues, #sanitize_job_name
Constructor Details
#initialize(batch) ⇒ Kubernetes
Returns a new instance of Kubernetes.
27 28 29 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 27 def initialize(batch) @batch = batch end |
Instance Attribute Details
#batch ⇒ Object (readonly)
Returns the value of attribute batch.
25 26 27 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 25 def batch @batch end |
Instance Method Details
#delete(id) ⇒ void
This method returns an undefined value.
Delete the submitted job.
187 188 189 190 191 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 187 def delete(id) batch.delete(id.to_s) rescue Batch::Error => e raise JobAdapterError, e. end |
#hold(id) ⇒ void
Subclass is expected to implement #hold
This method returns an undefined value.
Put the submitted job on hold
170 171 172 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 170 def hold(id) raise NotImplementedError, 'subclass did not define #hold' end |
#info(id) ⇒ Info
Subclass is expected to implement #info
Retrieve job info from the resource manager
149 150 151 152 153 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 149 def info(id) batch.info(id.to_s) rescue Batch::Error => e raise JobAdapterError, e. end |
#info_all(attrs: nil) ⇒ Array<Info>
Subclass is expected to implement #info_all
Retrieve info for all jobs from the resource manager
74 75 76 77 78 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 74 def info_all(attrs: nil) batch.info_all(attrs: attrs) rescue Batch::Error => e raise JobAdapterError, e. end |
#info_all_each(attrs: nil) {|Info| ... } ⇒ Enumerator
Iterate over each job Info object
110 111 112 113 114 115 116 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 110 def info_all_each(attrs: nil) return to_enum(:info_all_each, attrs: attrs) unless block_given? info_all(attrs: attrs).each do |job| yield job end end |
#info_where_owner(owner, attrs: nil) ⇒ Array<Info>
Retrieve info for all jobs for a given owner or owners from the resource manager
91 92 93 94 95 96 97 98 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 91 def info_where_owner(owner, attrs: nil) owner = Array.wrap(owner).map(&:to_s) # must at least have job_owner to filter by job_owner attrs = Array.wrap(attrs) | [:job_owner] unless attrs.nil? info_all(attrs: attrs).select { |info| owner.include? info.job_owner } end |
#info_where_owner_each(owner, attrs: nil) {|Info| ... } ⇒ Enumerator
Iterate over each job Info object
129 130 131 132 133 134 135 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 129 def info_where_owner_each(owner, attrs: nil) return to_enum(:info_where_owner_each, owner, attrs: attrs) unless block_given? info_where_owner(owner, attrs: attrs).each do |job| yield job end end |
#release(id) ⇒ void
Subclass is expected to implement #release
This method returns an undefined value.
Release the job that is on hold
179 180 181 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 179 def release(id) raise NotImplementedError, 'subclass did not define #release' end |
#status(id) ⇒ Status
Subclass is expected to implement #status
Optimized slightly over retrieving complete job information from server
Retrieve job status from resource manager
161 162 163 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 161 def status(id) info(id).status end |
#submit(script, after: [], afterok: [], afternotok: [], afterany: []) ⇒ String
Subclass is expected to implement #submit
Submit a job with the attributes defined in the job template instance
54 55 56 57 58 59 60 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 54 def submit(script, after: [], afterok: [], afternotok: [], afterany: []) raise ArgumentError, 'Must specify the script' if script.nil? batch.submit(script) rescue Batch::Error => e raise JobAdapterError, e. end |
#supports_job_arrays? ⇒ Boolean
Whether the adapter supports job arrays
140 141 142 |
# File 'lib/ood_core/job/adapters/kubernetes.rb', line 140 def supports_job_arrays? false end |