class Krane::HorizontalPodAutoscaler

Constants

RECOVERABLE_CONDITION_PREFIX
TIMEOUT

Public Instance Methods

deploy_failed?() click to toggle source
# File lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb, line 11
def deploy_failed?
  return false unless exists?
  return false if scaling_disabled?
  scaling_active_condition["status"] == "False" &&
  !scaling_active_condition.fetch("reason", "").start_with?(RECOVERABLE_CONDITION_PREFIX)
end
deploy_succeeded?() click to toggle source
# File lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb, line 7
def deploy_succeeded?
  scaling_active_condition["status"] == "True" || scaling_disabled?
end
failure_message() click to toggle source
# File lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb, line 37
def failure_message
  condition = scaling_active_condition.presence || able_to_scale_condition.presence || {}
  condition['message']
end
kubectl_resource_type() click to toggle source
# File lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb, line 18
def kubectl_resource_type
  'hpa.v2beta1.autoscaling'
end
status() click to toggle source
Calls superclass method Krane::KubernetesResource#status
# File lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb, line 22
def status
  if !exists?
    super
  elsif scaling_disabled?
    "ScalingDisabled"
  elsif deploy_succeeded?
    "Configured"
  elsif scaling_active_condition.present? || able_to_scale_condition.present?
    condition = scaling_active_condition.presence || able_to_scale_condition
    condition['reason']
  else
    "Unknown"
  end
end
timeout_message() click to toggle source
# File lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb, line 42
def timeout_message
  failure_message.presence || super
end

Private Instance Methods

able_to_scale_condition() click to toggle source
# File lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb, line 57
def able_to_scale_condition
  conditions.detect { |c| c["type"] == "AbleToScale" } || {}
end
conditions() click to toggle source
# File lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb, line 53
def conditions
  @instance_data.dig("status", "conditions") || []
end
scaling_active_condition() click to toggle source
# File lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb, line 61
def scaling_active_condition
  conditions.detect { |c| c["type"] == "ScalingActive" } || {}
end
scaling_disabled?() click to toggle source
# File lib/krane/kubernetes_resource/horizontal_pod_autoscaler.rb, line 48
def scaling_disabled?
  scaling_active_condition["status"] == "False" &&
  scaling_active_condition["reason"] == "ScalingDisabled"
end