Class: KubernetesDeploy::RunnerTask
- Inherits:
-
Object
- Object
- KubernetesDeploy::RunnerTask
- Defined in:
- lib/kubernetes-deploy/runner_task.rb
Defined Under Namespace
Classes: TaskTemplateMissingError
Instance Attribute Summary collapse
-
#pod_name ⇒ Object
readonly
Returns the value of attribute pod_name.
Instance Method Summary collapse
-
#initialize(namespace:, context:, logger:, max_watch_seconds: nil) ⇒ RunnerTask
constructor
A new instance of RunnerTask.
- #run(*args) ⇒ Object
- #run!(task_template:, entrypoint:, args:, env_vars: [], verify_result: true) ⇒ Object
Constructor Details
#initialize(namespace:, context:, logger:, max_watch_seconds: nil) ⇒ RunnerTask
Returns a new instance of RunnerTask.
13 14 15 16 17 18 |
# File 'lib/kubernetes-deploy/runner_task.rb', line 13 def initialize(namespace:, context:, logger:, max_watch_seconds: nil) @logger = logger @namespace = namespace @context = context @max_watch_seconds = max_watch_seconds end |
Instance Attribute Details
#pod_name ⇒ Object (readonly)
Returns the value of attribute pod_name.
11 12 13 |
# File 'lib/kubernetes-deploy/runner_task.rb', line 11 def pod_name @pod_name end |
Instance Method Details
#run(*args) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/kubernetes-deploy/runner_task.rb', line 20 def run(*args) run!(*args) true rescue DeploymentTimeoutError, FatalDeploymentError false end |
#run!(task_template:, entrypoint:, args:, env_vars: [], verify_result: true) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/kubernetes-deploy/runner_task.rb', line 27 def run!(task_template:, entrypoint:, args:, env_vars: [], verify_result: true) start = Time.now.utc @logger.reset @logger.phase_heading("Initializing task") validate_configuration(task_template, args) pod = build_pod(task_template, entrypoint, args, env_vars, verify_result) validate_pod(pod) @logger.phase_heading("Running pod") create_pod(pod) if verify_result @logger.phase_heading("Streaming logs") watch_pod(pod) else record_status_once(pod) end StatsD.distribution('task_runner.duration', StatsD.duration(start), tags: ('success')) @logger.print_summary(:success) rescue DeploymentTimeoutError StatsD.distribution('task_runner.duration', StatsD.duration(start), tags: ('timeout')) @logger.print_summary(:timed_out) raise rescue FatalDeploymentError StatsD.distribution('task_runner.duration', StatsD.duration(start), tags: ('failure')) @logger.print_summary(:failure) raise end |