configgin 0.15.0 → 0.15.1

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: c2a9f4d7934d6daf2749f6a8b3655fbe40bf5029
4
- data.tar.gz: dd2fc1734da0c2c1cb9e5421c63cc97649bce6b0
3
+ metadata.gz: e1b9aa710c1bec620b568e23d36f99c8a50338f1
4
+ data.tar.gz: 60b40c88b23d1488657e3c4f56b245fe9a111095
5
5
  SHA512:
6
- metadata.gz: '009e5dd0ca2b3a3e54317fba19f05c8ba64727dd73ce5f039d734236c55c6415258f6fd5107e80a9c7be060815dc779e8c333f1baf0794610c7de6206e7efb1d'
7
- data.tar.gz: 7e6670ce466bba34c1d7284ad0788f7d7e0cbd8cf066afbcc98278f7f227cc45993a7a419c21cc776287ce2a53df850a4a4462676aca2f113409b7fa6130f4be
6
+ metadata.gz: 0a0464ad7102b30f48f93ecd8ca5741c3c3c0104d452cf3f4e1c0bef4bd97236ce55fd7be8c0b3a7d4a8877ce2ca76d3cd481d045466d300c937ef217078b315
7
+ data.tar.gz: 3365be3c6f141f429a3fb44a6aaae7fdaf6562720d075a1e975ba5d86076435c56ca8ece5c4ee99925ebab2cb4ba20cbb5ffd705f7bcf45beebed9aafd091780
data/bin/configgin CHANGED
@@ -65,12 +65,13 @@ job_configs.each do |job, job_config|
65
65
  jobs[job] = Job.new(bosh_spec, kube_namespace, kube_client, kube_client_stateful_set)
66
66
  end
67
67
 
68
- exported_properties = Hash[jobs.map { |name, job| [name, job.exported_properties] }]
69
- kube_client.patch_pod(
70
- ENV['HOSTNAME'],
71
- { metadata: { annotations: { :'skiff-exported-properties' => exported_properties.to_json } } },
72
- kube_namespace
73
- )
68
+ jobs.each do |name, job|
69
+ kube_client.patch_pod(
70
+ ENV['HOSTNAME'],
71
+ { metadata: { annotations: { :"skiff-exported-properties-#{name}" => job.exported_properties.to_json } } },
72
+ kube_namespace
73
+ )
74
+ end
74
75
 
75
76
  jobs.each do |job_name, job|
76
77
  dns_encoder = KubeDNSEncoder.new(job.spec['links'])
@@ -1,3 +1,3 @@
1
1
  module Configgin
2
- VERSION = '0.15.0'.freeze
2
+ VERSION = '0.15.1'.freeze
3
3
  end
data/lib/job.rb CHANGED
@@ -58,7 +58,7 @@ class Job
58
58
  # Read the erb template
59
59
  begin
60
60
  perms = File.stat(input_file_path).mode
61
- erb_template = ERB.new(File.read(input_file_path))
61
+ erb_template = ERB.new(File.read(input_file_path), nil, '-')
62
62
  erb_template.filename = input_file_path
63
63
  rescue Errno::ENOENT
64
64
  raise "failed to read template file #{input_file_path}"
@@ -37,7 +37,7 @@ class KubeLinkSpecs
37
37
  @client.get_pods(namespace: @namespace, label_selector: "skiff-role-name=#{role_name}")
38
38
  end
39
39
 
40
- def get_pods_for_role(role_name, wait_for_ip)
40
+ def get_pods_for_role(role_name, wait_for_ip, job)
41
41
  loop do
42
42
  # The 30.times loop exists to print out status messages
43
43
  30.times do
@@ -46,30 +46,34 @@ class KubeLinkSpecs
46
46
  if wait_for_ip
47
47
  # Wait until all pods have IP addresses and properties
48
48
  break unless pods.all? { |pod| pod.status.podIP }
49
- break unless pods.all? { |pod| pod.metadata.annotations['skiff-exported-properties'] }
49
+ break unless pods.all? { |pod| pod.metadata.annotations["skiff-exported-properties-#{job}"] }
50
50
  else
51
51
  # We just need one pod with exported properties
52
52
  pods.select! { |pod| pod.status.podIP }
53
- pods.select! { |pod| pod.metadata.annotations['skiff-exported-properties'] }
53
+ pods.select! { |pod| pod.metadata.annotations["skiff-exported-properties-#{job}"] }
54
54
  end
55
55
  return pods unless pods.empty?
56
56
  end
57
57
  sleep 1
58
58
  end
59
- $stdout.puts "Waiting for pods for role #{role_name} (at #{Time.now})..."
59
+ $stdout.puts "Waiting for pods for role #{role_name} and provider job #{job} (at #{Time.now})..."
60
60
  end
61
61
  end
62
62
 
63
+ def get_exported_properties(pod, job)
64
+ exported_properties = pod.metadata.annotations["skiff-exported-properties-#{job}"]
65
+ exported_properties.nil? ? {} : JSON.parse(exported_properties)
66
+ end
67
+
63
68
  def get_pod_instance_info(pod, job, pods_per_image)
64
69
  index = pod_index(pod.metadata.name)
65
- properties = JSON.parse(pod.metadata.annotations['skiff-exported-properties'])
66
70
  {
67
71
  'name' => pod.metadata.name,
68
72
  'index' => index,
69
73
  'id' => pod.metadata.name,
70
74
  'az' => pod.metadata.annotations['failure-domain.beta.kubernetes.io/zone'] || 'az0',
71
75
  'address' => pod.status.podIP,
72
- 'properties' => properties.fetch(job, {}),
76
+ 'properties' => get_exported_properties(pod, job),
73
77
  'bootstrap' => pods_per_image[pod.metadata.uid] < 2
74
78
  }
75
79
  end
@@ -92,23 +96,21 @@ class KubeLinkSpecs
92
96
 
93
97
  def get_svc_instance_info(role_name, job)
94
98
  svc = @client.get_service(role_name, @namespace)
95
- pod = get_pods_for_role(role_name, false).first
96
- properties = JSON.parse(pod.metadata.annotations['skiff-exported-properties'])
99
+ pod = get_pods_for_role(role_name, false, job).first
97
100
  {
98
101
  'name' => svc.metadata.name,
99
102
  'index' => 0, # Completely made up index; there is only ever one service
100
103
  'id' => svc.metadata.name,
101
104
  'az' => pod.metadata.annotations['failure-domain.beta.kubernetes.io/zone'] || 'az0',
102
105
  'address' => svc.spec.clusterIP,
103
- 'properties' => properties.fetch(job, {}),
106
+ 'properties' => get_exported_properties(pod, job),
104
107
  'bootstrap' => true
105
108
  }
106
109
  end
107
110
 
108
111
  def get_statefulset_instance_info(role_name, job)
109
112
  ss = @client_stateful_set.get_stateful_set(role_name, @namespace)
110
- pod = get_pods_for_role(role_name, false).first
111
- properties = JSON.parse(pod.metadata.annotations['skiff-exported-properties'])
113
+ pod = get_pods_for_role(role_name, false, job).first
112
114
 
113
115
  Array.new(ss.spec.replicas) do |i|
114
116
  {
@@ -117,7 +119,7 @@ class KubeLinkSpecs
117
119
  'id' => ss.metadata.name,
118
120
  'az' => pod.metadata.annotations['failure-domain.beta.kubernetes.io/zone'] || 'az0',
119
121
  'address' => "#{ss.metadata.name}-#{i}.#{ss.spec.serviceName}",
120
- 'properties' => properties.fetch(job, {}),
122
+ 'properties' => get_exported_properties(pod, job),
121
123
  'bootstrap' => i.zero?
122
124
  }
123
125
  end
@@ -142,7 +144,7 @@ class KubeLinkSpecs
142
144
 
143
145
  if provider['role'] == this_name
144
146
  $stderr.puts "Resolving link #{key} via self provider #{provider}"
145
- pods = get_pods_for_role(provider['role'], true)
147
+ pods = get_pods_for_role(provider['role'], true, provider['job'])
146
148
  pods_per_image = get_pods_per_image(pods)
147
149
  instances = pods.map { |p| get_pod_instance_info(p, provider['job'], pods_per_image) }
148
150
  elsif service? provider['role']
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.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SUSE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-10 00:00:00.000000000 Z
11
+ date: 2018-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  requirements: []
179
179
  rubyforge_project:
180
- rubygems_version: 2.6.13
180
+ rubygems_version: 2.6.10
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: A simple cli app in Ruby to generate configurations using BOSH ERB templates