lib/krane/kubernetes_resource/replica_set.rb in krane-1.0.0 vs lib/krane/kubernetes_resource/replica_set.rb in krane-1.1.0
- old
+ new
@@ -2,10 +2,11 @@
require 'krane/kubernetes_resource/pod_set_base'
module Krane
class ReplicaSet < PodSetBase
TIMEOUT = 5.minutes
+ SYNC_DEPENDENCIES = %w(Pod)
attr_reader :pods
def initialize(namespace:, context:, definition:, logger:, statsd_tags: nil,
parent: nil, deploy_started_at: nil)
@parent = parent
@@ -15,11 +16,11 @@
logger: logger, statsd_tags: statsd_tags)
end
def sync(cache)
super
- @pods = fetch_pods_if_needed(cache) || []
+ @pods = exists? ? find_pods(cache) : []
end
def status
return super unless rollout_data.present?
rollout_data.map { |state_replicas, num| "#{num} #{state_replicas.chop.pluralize(num)}" }.join(", ")
@@ -54,24 +55,9 @@
private
def stale_status?
observed_generation != current_generation
- end
-
- def fetch_pods_if_needed(cache)
- # If the ReplicaSet doesn't exist, its pods won't either
- return unless exists?
- # If the status hasn't been updated yet, we're not going to make a determination anyway
- return if stale_status?
- # If we don't want any pods at all, we don't need to look for them
- return if desired_replicas == 0
- # We only need to fetch pods so that deploy_failed? can check that they aren't ALL bad.
- # If we can already tell some pods are ok from the RS data, don't bother fetching them (which can be expensive)
- # Lower numbers here make us more susceptible to being fooled by replicas without probes briefly appearing ready
- return if ready_replicas > 1
-
- find_pods(cache)
end
def rollout_data
return { "replicas" => 0 } unless exists?
{ "replicas" => 0 }.merge(