configgin 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d5e487bb265d0c63dbbb33253b00c6f5def25b4
4
- data.tar.gz: 69b56e76b7779dd0b289b10c7d9943fd7ea5b17b
3
+ metadata.gz: 593236064eaa183069525e4725950e8bc4f39c0f
4
+ data.tar.gz: 8b4a9485d62dcd0a64170772b85285679ce25362
5
5
  SHA512:
6
- metadata.gz: e001f475d66938235aa00c71e1b6aa1b512329abdecc8dadd577a178595d3d31fd45c50c975c0ab81e6a184c1bc613cf7d188ac1155cb95974242d2006b06f80
7
- data.tar.gz: cbb37d82c2cb9bfe6ec9742ade58af0aabb31c2e357ea36ce6c85d8216504b01ed7f3fb3be129831e53bf7f8cca9c9e8ca8d0a95376e3810e804c829ef22a90d
6
+ metadata.gz: 2cb081da7e7eb7468c7d2eb6c109ae430270d37a65d5a0f9ac2de41fc2bc32d6fe9a3f47ca999be61bac1d93dd5f37dbec5bc7bd9fdab1416a7fc3d1c20d0e98
7
+ data.tar.gz: 5005cc57cc29062bfa89e209b23c56dc870629e0be1b45af05bc950f7b68d55c56526dba3b6cce814e255968e9978aa54337744c3e32386f5f21ac62849c823d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- configgin (0.13.0)
4
+ configgin (0.14.0)
5
5
  bosh-template (~> 2.0)
6
6
  deep_merge (~> 1.1)
7
7
  kubeclient (~> 2.0)
@@ -41,7 +41,7 @@ GEM
41
41
  parser (2.4.0.0)
42
42
  ast (~> 2.2)
43
43
  powerpack (0.1.1)
44
- public_suffix (3.0.0)
44
+ public_suffix (3.0.1)
45
45
  rainbow (2.1.0)
46
46
  rake (10.4.2)
47
47
  recursive-open-struct (1.0.0)
@@ -1,3 +1,3 @@
1
1
  module Configgin
2
- VERSION = '0.13.0'.freeze
2
+ VERSION = '0.14.0'.freeze
3
3
  end
@@ -32,12 +32,16 @@ class KubeLinkSpecs
32
32
  index.chars.map { |c| chars.index(c) }.reduce(0) { |v, c| v * chars.length + c }
33
33
  end
34
34
 
35
+ def _get_pods_for_role(role_name)
36
+ @client.get_pods(namespace: @namespace, label_selector: "skiff-role-name=#{role_name}")
37
+ end
38
+
35
39
  def get_pods_for_role(role_name, wait_for_ip)
36
40
  loop do
37
41
  # The 30.times loop exists to print out status messages
38
42
  30.times do
39
43
  1.times do
40
- pods = @client.get_pods(namespace: @namespace, label_selector: "skiff-role-name=#{role_name}")
44
+ pods = _get_pods_for_role(role_name)
41
45
  if wait_for_ip
42
46
  # Wait until all pods have IP addresses and properties
43
47
  break unless pods.all? { |pod| pod.status.podIP }
@@ -55,7 +59,7 @@ class KubeLinkSpecs
55
59
  end
56
60
  end
57
61
 
58
- def get_pod_instance_info(pod, job)
62
+ def get_pod_instance_info(pod, job, pods_per_image)
59
63
  index = pod_index(pod.metadata.name)
60
64
  properties = JSON.parse(pod.metadata.annotations['skiff-exported-properties'])
61
65
  {
@@ -65,10 +69,26 @@ class KubeLinkSpecs
65
69
  'az' => pod.metadata.annotations['failure-domain.beta.kubernetes.io/zone'] || 'az0',
66
70
  'address' => pod.status.podIP,
67
71
  'properties' => properties.fetch(job, {}),
68
- 'bootstrap' => index.zero?
72
+ 'bootstrap' => pods_per_image[pod.metadata.uid] < 2
69
73
  }
70
74
  end
71
75
 
76
+ # Return the number of pods for each image
77
+ def get_pods_per_image(pods)
78
+ result = {}
79
+ sets = Hash.new(0)
80
+ keys = {}
81
+ pods.each do |pod|
82
+ key = pod.status.containerStatuses.map(&:imageID).sort.join("\n")
83
+ sets[key] += 1
84
+ keys[pod.metadata.uid] = key
85
+ end
86
+ pods.each do |pod|
87
+ result[pod.metadata.uid] = sets[keys[pod.metadata.uid]]
88
+ end
89
+ result
90
+ end
91
+
72
92
  def get_svc_instance_info(role_name, job)
73
93
  svc = @client.get_service(role_name, @namespace)
74
94
  pod = get_pods_for_role(role_name, false).first
@@ -98,7 +118,8 @@ class KubeLinkSpecs
98
118
  if provider['role'] == this_name
99
119
  $stderr.puts "Resolving link #{key} via self provider #{provider}"
100
120
  pods = get_pods_for_role(provider['role'], true)
101
- instances = pods.map { |p| get_pod_instance_info(p, provider['job']) }
121
+ pods_per_image = get_pods_per_image(pods)
122
+ instances = pods.map { |p| get_pod_instance_info(p, provider['job'], pods_per_image) }
102
123
  else
103
124
  # Getting pods for a different service; since we have kube services, we don't handle it in configgin
104
125
  $stderr.puts "Resolving link #{key} via service #{provider}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configgin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SUSE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2017-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler