Class: KubeQueue::JobSpecification

Inherits:
Object
  • Object
show all
Defined in:
lib/kube_queue/job_specification.rb

Defined Under Namespace

Classes: MissingParameterError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_class) ⇒ JobSpecification

Returns a new instance of JobSpecification.



17
18
19
# File 'lib/kube_queue/job_specification.rb', line 17

def initialize(job_class)
  @job_class = job_class
end

Instance Attribute Details

#active_deadline_secondsObject

Returns the value of attribute active_deadline_seconds.



10
11
12
# File 'lib/kube_queue/job_specification.rb', line 10

def active_deadline_seconds
  @active_deadline_seconds
end

#backoff_limitObject

Returns the value of attribute backoff_limit.



10
11
12
# File 'lib/kube_queue/job_specification.rb', line 10

def backoff_limit
  @backoff_limit
end

#commandObject



41
42
43
# File 'lib/kube_queue/job_specification.rb', line 41

def command
  @command || ['bundle', 'exec', 'kube_queue', 'runner', job_class.name]
end

#concurrent_policyObject



73
74
75
# File 'lib/kube_queue/job_specification.rb', line 73

def concurrent_policy
  @concurrent_policy || 'Allow'
end

#container_nameObject



37
38
39
# File 'lib/kube_queue/job_specification.rb', line 37

def container_name
  @container_name || worker_name
end

#cpu_limitObject

Returns the value of attribute cpu_limit.



10
11
12
# File 'lib/kube_queue/job_specification.rb', line 10

def cpu_limit
  @cpu_limit
end

#cpu_requestObject

Returns the value of attribute cpu_request.



10
11
12
# File 'lib/kube_queue/job_specification.rb', line 10

def cpu_request
  @cpu_request
end

#envObject



57
58
59
# File 'lib/kube_queue/job_specification.rb', line 57

def env
  KubeQueue.default_env.merge(@env || {})
end

#env_from_config_mapObject



61
62
63
# File 'lib/kube_queue/job_specification.rb', line 61

def env_from_config_map
  @env_from_config_map || []
end

#env_from_secretObject



65
66
67
# File 'lib/kube_queue/job_specification.rb', line 65

def env_from_secret
  @env_from_config_map || []
end

#imageObject



25
26
27
# File 'lib/kube_queue/job_specification.rb', line 25

def image
  @image || raise_not_found_required_parameter('image')
end

#job_classObject (readonly)

Returns the value of attribute job_class.



8
9
10
# File 'lib/kube_queue/job_specification.rb', line 8

def job_class
  @job_class
end

#job_labelsObject



49
50
51
# File 'lib/kube_queue/job_specification.rb', line 49

def job_labels
  @job_labels || {}
end

#memory_limitObject

Returns the value of attribute memory_limit.



10
11
12
# File 'lib/kube_queue/job_specification.rb', line 10

def memory_limit
  @memory_limit
end

#memory_requestObject

Returns the value of attribute memory_request.



10
11
12
# File 'lib/kube_queue/job_specification.rb', line 10

def memory_request
  @memory_request
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/kube_queue/job_specification.rb', line 10

def name
  @name
end

#namespaceObject



29
30
31
# File 'lib/kube_queue/job_specification.rb', line 29

def namespace
  @namespace || 'default'
end

#payloadObject

Returns the value of attribute payload.



10
11
12
# File 'lib/kube_queue/job_specification.rb', line 10

def payload
  @payload
end

#pod_labelsObject



53
54
55
# File 'lib/kube_queue/job_specification.rb', line 53

def pod_labels
  @pod_labels || {}
end

#restart_policyObject



45
46
47
# File 'lib/kube_queue/job_specification.rb', line 45

def restart_policy
  @restart_policy || 'Never'
end

#starting_deadline_secondsObject

Returns the value of attribute starting_deadline_seconds.



10
11
12
# File 'lib/kube_queue/job_specification.rb', line 10

def starting_deadline_seconds
  @starting_deadline_seconds
end

#worker_nameObject



33
34
35
# File 'lib/kube_queue/job_specification.rb', line 33

def worker_name
  @worker_name || raise_not_found_required_parameter('worker_name')
end

Instance Method Details

#env_from_exists?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/kube_queue/job_specification.rb', line 69

def env_from_exists?
  !env_from_config_map.empty? && !env_from_secret.empty?
end

#job_name(job_id) ⇒ Object



21
22
23
# File 'lib/kube_queue/job_specification.rb', line 21

def job_name(job_id)
  "#{worker_name}-#{job_id}"
end

#raise_not_found_required_parameter(field) ⇒ Object



81
82
83
# File 'lib/kube_queue/job_specification.rb', line 81

def raise_not_found_required_parameter(field)
  raise MissingParameterError, "#{field} is required"
end

#resources_exists?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/kube_queue/job_specification.rb', line 77

def resources_exists?
  @cpu_limit || @memory_limit || @cpu_request || @memory_request
end