Skip to content

Commit

Permalink
Track in and out
Browse files Browse the repository at this point in the history
  • Loading branch information
dturn committed Dec 16, 2020
1 parent b71565a commit 5df3f82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lib/krane/deploy_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DeployTask
)

def predeploy_sequence
default_group = { skip_groups: [] }
default_group = { groups: [], skip_groups: [] }
before_crs = %w(
ResourceQuota
NetworkPolicy
Expand All @@ -71,10 +71,14 @@ def predeploy_sequence

after_crs = %w(
Pod
).map { |r| [r, default_group] }
)

predeploy_hash = Hash[before_crs]
cluster_resource_discoverer.crds.select(&:predeployed?).each do |cr|
predeploy_hash[cr.kind] ||= { groups: [cr.group], skip_groups: [] }
end

crs = cluster_resource_discoverer.crds.select(&:predeployed?).map { |cr| [cr.kind, default_group] }
predeploy_hash = Hash[before_crs + crs + after_crs]
after_crs.each { |cr| predeploy_hash[cr] = default_group }

cluster_resource_discoverer.crds.reject(&:predeployed?).each do |cr|
predeploy_hash[cr.kind][:skip_groups] << cr.group if predeploy_hash[cr.kind]
Expand Down Expand Up @@ -222,7 +226,7 @@ def ejson_provisioners
def deploy_has_priority_resources?(resources)
resources.any? do |r|
next unless (pr = predeploy_sequence[r.type])
!pr[:skip_groups].include?(r.group)
(pr[:groups].empty? || pr[:groups].include?(r.group)) && !pr[:skip_groups].include?(r.group)
end
end

Expand Down
4 changes: 3 additions & 1 deletion lib/krane/resource_deployer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def predeploy_priority_resources(resource_list, predeploy_sequence)

predeploy_sequence.each do |resource_type, attributes|
matching_resources = resource_list.select do |r|
r.type == resource_type && !attributes[:skip_groups].include?(r.group)
r.type == resource_type &&
((attributes[:groups].empty? || attributes[:groups].include?(r.group))
&& !attributes[:skip_groups].include?(r.group))
end
StatsD.client.gauge('priority_resources.count', matching_resources.size, tags: statsd_tags)

Expand Down

0 comments on commit 5df3f82

Please sign in to comment.