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 Attribute Summary collapse
-
#task_config ⇒ Object
readonly
Returns the value of attribute task_config.
Instance Method Summary collapse
-
#initialize(context:, global_timeout: nil, selector: nil, selector_as_filter: false, filenames: [], logger: nil, kubeconfig: 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
Constructor Details
#initialize(context:, global_timeout: nil, selector: nil, selector_as_filter: false, filenames: [], logger: nil, kubeconfig: nil) ⇒ GlobalDeployTask
Initializes the deploy task
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/krane/global_deploy_task.rb', line 38 def initialize(context:, global_timeout: nil, selector: nil, selector_as_filter: false, filenames: [], logger: nil, kubeconfig: nil) template_paths = filenames.map { |path| File.(path) } @task_config = TaskConfig.new(context, nil, logger, kubeconfig) @template_sets = TemplateSets.from_dirs_and_files(paths: template_paths, logger: @task_config.logger, render_erb: false) @global_timeout = global_timeout @selector = selector @selector_as_filter = selector_as_filter end |
Instance Attribute Details
#task_config ⇒ Object (readonly)
Returns the value of attribute task_config.
29 30 31 |
# File 'lib/krane/global_deploy_task.rb', line 29 def task_config @task_config end |
Instance Method Details
#run(**args) ⇒ Boolean
Runs the task, returning a boolean representing success or failure
53 54 55 56 57 58 |
# File 'lib/krane/global_deploy_task.rb', line 53 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
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 102 103 104 105 |
# File 'lib/krane/global_deploy_task.rb', line 67 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 |