-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 20 additions & 9 deletions
29
lib/kubernetes-deploy/kubernetes_resource/horizontal_pod_autoscaler.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
# frozen_string_literal: true | ||
module KubernetesDeploy | ||
class HorizontalPodAutoscaler < KubernetesResource | ||
PRUNABLE = true | ||
TIMEOUT = 30.seconds | ||
|
||
def deploy_succeeded? | ||
conditions = @instance_data.dig("status", "conditions") || [] | ||
able_to_scale = conditions.detect { |c| c["type"] == "AbleToScale" } || {} | ||
able_to_scale["status"] == "True" | ||
able_to_scale_condition["status"] == "True" | ||
end | ||
|
||
def deploy_failed? | ||
!exists? | ||
end | ||
|
||
def timeout_message | ||
UNUSUAL_FAILURE_MESSAGE | ||
return false unless exists? | ||
able_to_scale_condition["status"] == "False" | ||
end | ||
|
||
def type | ||
'hpa.v2beta1.autoscaling' | ||
end | ||
|
||
def status | ||
if !exists? | ||
super | ||
elsif deploy_succeeded? | ||
"Succeeded" | ||
else | ||
able_to_scale_condition["reason"] | ||
end | ||
end | ||
|
||
private | ||
|
||
def able_to_scale_condition | ||
conditions = @instance_data.dig("status", "conditions") || [] | ||
conditions.detect { |c| c["type"] == "AbleToScale" } || {} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters