Class: KubernetesDeploy::CustomResourceDefinition
Constant Summary
collapse
- TIMEOUT =
2.minutes
- ROLLOUT_CONDITIONS_ANNOTATION =
"kubernetes-deploy.shopify.io/instance-rollout-conditions"
- TIMEOUT_FOR_INSTANCE_ANNOTATION =
"kubernetes-deploy.shopify.io/instance-timeout"
- GLOBAL =
true
KubernetesResource::DEBUG_RESOURCE_NOT_FOUND_MESSAGE, KubernetesResource::DISABLED_EVENT_INFO_MESSAGE, KubernetesResource::DISABLED_LOG_INFO_MESSAGE, KubernetesResource::DISABLE_FETCHING_EVENT_INFO, KubernetesResource::DISABLE_FETCHING_LOG_INFO, KubernetesResource::LAST_APPLIED_ANNOTATION, KubernetesResource::LOG_LINE_COUNT, KubernetesResource::SENSITIVE_TEMPLATE_CONTENT, KubernetesResource::STANDARD_TIMEOUT_MESSAGE, KubernetesResource::TIMEOUT_OVERRIDE_ANNOTATION, KubernetesResource::UNUSUAL_FAILURE_MESSAGE
Instance Attribute Summary
#context, #deploy_started_at, #namespace, #type
Instance Method Summary
collapse
#<=>, #after_sync, build, class_for_kind, #current_generation, #debug_message, #deploy_method, #deploy_started?, #deploy_timed_out?, #disappeared?, #exists?, #failure_message, #fetch_events, #file_path, #global?, #id, #initialize, kind, #kubectl_resource_type, #observed_generation, #pretty_status, #pretty_timeout_type, #report_status_to_statsd, #sensitive_template_content?, #sync, #sync_debug_info, #terminating?, timeout, #timeout, #timeout_override, #to_kubeclient_resource, #validation_error_msg, #validation_failed?
Instance Method Details
#deploy_failed? ⇒ Boolean
15
16
17
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 15
def deploy_failed?
names_accepted_status == "False"
end
|
#deploy_succeeded? ⇒ Boolean
11
12
13
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 11
def deploy_succeeded?
names_accepted_status == "True"
end
|
#group_version_kind ⇒ Object
40
41
42
43
44
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 40
def group_version_kind
group = @definition.dig("spec", "group")
version = @definition.dig("spec", "version")
"#{group}/#{version}/#{kind}"
end
|
#kind ⇒ Object
46
47
48
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 46
def kind
@definition.dig("spec", "names", "kind")
end
|
#name ⇒ Object
50
51
52
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 50
def name
@definition.dig("metadata", "name")
end
|
#prunable? ⇒ Boolean
54
55
56
57
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 54
def prunable?
prunable = @definition.dig("metadata", "annotations", "kubernetes-deploy.shopify.io/prunable")
prunable == "true"
end
|
#rollout_conditions ⇒ Object
59
60
61
62
63
64
65
66
67
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 59
def rollout_conditions
return @rollout_conditions if defined?(@rollout_conditions)
@rollout_conditions = if rollout_conditions_annotation
RolloutConditions.from_annotation(rollout_conditions_annotation)
end
rescue RolloutConditionsError
@rollout_conditions = nil
end
|
#status ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 30
def status
if !exists?
super
elsif deploy_succeeded?
"Names accepted"
else
"#{names_accepted_condition['reason']} (#{names_accepted_condition['message']})"
end
end
|
#timeout_for_instance ⇒ Object
#timeout_message ⇒ Object
19
20
21
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 19
def timeout_message
"The names this CRD is attempting to register were neither accepted nor rejected in time"
end
|
#validate_definition ⇒ Object
69
70
71
72
73
74
75
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 69
def validate_definition(*)
super
validate_rollout_conditions
rescue RolloutConditionsError => e
@validation_errors << "Annotation #{ROLLOUT_CONDITIONS_ANNOTATION} on #{name} is invalid: #{e}"
end
|
#validate_rollout_conditions ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'lib/kubernetes-deploy/kubernetes_resource/custom_resource_definition.rb', line 77
def validate_rollout_conditions
if rollout_conditions_annotation && @rollout_conditions_validated.nil?
conditions = RolloutConditions.from_annotation(rollout_conditions_annotation)
conditions.validate!
end
@rollout_conditions_validated = true
end
|