Class: Krane::GlobalDeployTask
- Inherits:
-
Object
- Object
- Krane::GlobalDeployTask
- Extended by:
- StatsD::MeasureMethods
- Includes:
- TemplateReporting
- Defined in:
- lib/krane/global_deploy_task.rb
Overview
Ship global resources to a context
Instance Method Summary collapse
-
#initialize(context:, global_timeout: nil, selector: nil, filenames: [], logger: nil) ⇒ GlobalDeployTask
constructor
Initializes the deploy task.
-
#run(*args) ⇒ Boolean
Runs the task, returning a boolean representing success or failure.
-
#run!(verify_result: true, prune: true) ⇒ nil
Runs the task, raising exceptions in case of issues.
Methods included from StatsD::MeasureMethods
Methods included from TemplateReporting
#add_para_from_list, #record_invalid_template, #record_warnings
Constructor Details
#initialize(context:, global_timeout: nil, selector: nil, filenames: [], logger: nil) ⇒ GlobalDeployTask
Initializes the deploy task
36 37 38 39 40 41 42 43 44 |
# File 'lib/krane/global_deploy_task.rb', line 36 def initialize(context:, global_timeout: nil, selector: nil, filenames: [], logger: nil) template_paths = filenames.map { |path| File.(path) } @task_config = TaskConfig.new(context, nil, logger) @template_sets = TemplateSets.from_dirs_and_files(paths: template_paths, logger: @task_config.logger, render_erb: false) @global_timeout = global_timeout @selector = selector end |
Instance Method Details
#run(*args) ⇒ Boolean
Runs the task, returning a boolean representing success or failure
49 50 51 52 53 54 |
# File 'lib/krane/global_deploy_task.rb', line 49 def run(*args) run!(*args) true rescue FatalDeploymentError false end |
#run!(verify_result: true, prune: true) ⇒ nil
Runs the task, raising exceptions in case of issues
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/krane/global_deploy_task.rb', line 63 def run!(verify_result: true, prune: true) start = Time.now.utc logger.reset logger.phase_heading("Initializing deploy") validate_configuration resources = discover_resources validate_resources(resources) logger.phase_heading("Checking initial resource statuses") check_initial_status(resources) logger.phase_heading("Deploying all resources") deploy!(resources, verify_result, prune) StatsD.client.event("Deployment succeeded", "Successfully deployed all resources to #{context}", alert_type: "success", tags: + %w(status:success)) StatsD.client.distribution('all_resources.duration', StatsD.duration(start), tags: << "status:success") logger.print_summary(:success) rescue Krane::DeploymentTimeoutError logger.print_summary(:timed_out) StatsD.client.event("Deployment timed out", "One or more resources failed to deploy to #{context} in time", alert_type: "error", tags: + %w(status:timeout)) StatsD.client.distribution('all_resources.duration', StatsD.duration(start), tags: << "status:timeout") raise rescue Krane::FatalDeploymentError => error logger.summary.add_action(error.) if error. != error.class.to_s logger.print_summary(:failure) StatsD.client.event("Deployment failed", "One or more resources failed to deploy to #{context}", alert_type: "error", tags: + %w(status:failed)) StatsD.client.distribution('all_resources.duration', StatsD.duration(start), tags: << "status:failed") raise end |