Skip to content

Commit f1c83a7

Browse files
committed
More fixup
1 parent 6c00d18 commit f1c83a7

7 files changed

Lines changed: 17 additions & 11 deletions

File tree

lib/krane/kubernetes_resource/daemon_set.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Krane
44
class DaemonSet < PodSetBase
55
TIMEOUT = 5.minutes
6-
SYNC_DEPENDENCIES = %w(Pod)
6+
SYNC_DEPENDENCIES = %w(Pod.apps)
77
attr_reader :pods
88

99
def sync(cache)

lib/krane/kubernetes_resource/deployment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
module Krane
55
class Deployment < KubernetesResource
66
TIMEOUT = 7.minutes
7-
SYNC_DEPENDENCIES = %w(Pod ReplicaSet)
7+
SYNC_DEPENDENCIES = %w(Pod.apps ReplicaSet.apps)
88
REQUIRED_ROLLOUT_ANNOTATION = "required-rollout"
99
REQUIRED_ROLLOUT_TYPES = %w(maxUnavailable full none).freeze
1010
DEFAULT_REQUIRED_ROLLOUT = 'full'

lib/krane/kubernetes_resource/replica_set.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
module Krane
55
class ReplicaSet < PodSetBase
66
TIMEOUT = 5.minutes
7-
SYNC_DEPENDENCIES = %w(Pod)
7+
SYNC_DEPENDENCIES = %w(Pod.apps)
88
attr_reader :pods
99

1010
def initialize(namespace:, context:, definition:, logger:, statsd_tags: nil,

lib/krane/kubernetes_resource/service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
module Krane
55
class Service < KubernetesResource
66
TIMEOUT = 7.minutes
7-
SYNC_DEPENDENCIES = %w(Pod Deployment StatefulSet)
7+
SYNC_DEPENDENCIES = %w(Pod.apps Deployment.apps StatefulSet.apps)
88

99
def sync(cache)
1010
super

lib/krane/kubernetes_resource/stateful_set.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Krane
44
class StatefulSet < PodSetBase
55
TIMEOUT = 10.minutes
66
ONDELETE = 'OnDelete'
7-
SYNC_DEPENDENCIES = %w(Pod)
7+
SYNC_DEPENDENCIES = %w(Pod.apps)
88
attr_reader :pods
99

1010
def sync(cache)

lib/krane/resource_cache.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ def get_all(kind, selector = nil)
3636
[]
3737
end
3838

39-
# TODO: I've broken sync_dependencies
4039
def prewarm(resources)
4140
sync_dependencies = resources.flat_map { |r| r.class.const_get(:SYNC_DEPENDENCIES) }
42-
kinds = resources.map(&:sync_group_kind).uniq # sync_dependencies).uniq
41+
kinds = (resources.map(&:sync_group_kind) + sync_dependencies).uniq
4342
Krane::Concurrency.split_across_threads(kinds, max_threads: kinds.count) { |kind| get_all(kind) }
4443
end
4544

@@ -57,9 +56,12 @@ def use_or_populate_cache(kind)
5756
end
5857

5958
def fetch_by_kind(kind)
60-
kind_only = kind.split(".").first.downcase # Busted for non unique kinds...
59+
kind_only, group = kind.downcase.split(".", 2)
60+
global_kind = @task_config.global_resources.any? do |resource|
61+
resource['kind'].downcase == kind_only && resource['apigroup'].downcase == group
62+
end
63+
6164
resource_class = KubernetesResource.class_for_kind(kind_only)
62-
global_kind = @task_config.global_kinds.map(&:downcase).include?(kind_only)
6365
output_is_sensitive = resource_class.nil? ? false : resource_class::SENSITIVE_TEMPLATE_CONTENT
6466
raw_json, _, st = @kubectl.run("get", kind, "--chunk-size=0", attempts: 5, output: "json",
6567
output_is_sensitive: output_is_sensitive, use_namespace: !global_kind)

lib/krane/task_config.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ def initialize(context, namespace, logger = nil, kubeconfig = nil)
1414
end
1515

1616
def global_kinds
17-
@global_kinds ||= begin
17+
global_resources.map { |g| g["kind"] }
18+
end
19+
20+
def global_resources
21+
@global_resources ||= begin
1822
cluster_resource_discoverer = ClusterResourceDiscovery.new(task_config: self)
19-
cluster_resource_discoverer.fetch_resources(namespaced: false).map { |g| g["kind"] }
23+
cluster_resource_discoverer.fetch_resources(namespaced: false)
2024
end
2125
end
2226

0 commit comments

Comments
 (0)