dapp 0.13.17 → 0.13.18

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: f9e04341cb2d60b3950b60e7a0347ce4ba3aefc8
4
- data.tar.gz: 746bcfa431003b5aaac9d97c7f09aa7a8a895c8d
3
+ metadata.gz: d6b08668d5e7085683b983ee2459556137efd222
4
+ data.tar.gz: c4897d4a33e753fde1569993557c1524627eb2c5
5
5
  SHA512:
6
- metadata.gz: 93a186ff50fa4fdceec4a973bc011d21bc60e747cebe7b0f4be3f6bcd905ef5ae578f95732afdf757b4de291f595422c89a088e4c5395d6bfa80f42fe031fe9c
7
- data.tar.gz: 09f10ab1ae0e559576882fdca1cb64b6c31b89987497ccb7b371625bf9a33d99243ee0f4baf03bc610c73f4824755631b88d5e4d5b22a763547e01dbd9e5316c
6
+ metadata.gz: fa7a617befda0df14a3270ae9666fc4a40f5d5ac283438b8895d870e8d85aaec07467b4e300f31423bafa28046841186edc96070d410e201e063713fc59ad141
7
+ data.tar.gz: 4a7170e9053054c72ac25a8671debfcfdc7895edc180b71733d52a93a863242b4b9a425e584fc4cd8804336365c2a70a72ea1d966d627bea8346e5fd7c9285f2
@@ -82,18 +82,31 @@ module Dapp
82
82
  def validate_artifact_format(artifacts)
83
83
  artifacts.map do |a|
84
84
  path_format = proc { |path| File.expand_path(File.join('/', path, '/'))[1..-1] }
85
-
86
85
  path_format.call(a._to) =~ %r{^([^\/]*)\/?(.*)$}
86
+
87
87
  to = Regexp.last_match(1)
88
- include_paths = a._include_paths.dup
89
- include_paths << Regexp.last_match(2) unless Regexp.last_match(2).empty?
90
- exclude_paths = a._exclude_paths.dup
88
+ include_exclude_path_format = proc do |path|
89
+ paths = [].tap do |arr|
90
+ arr << Regexp.last_match(2) unless Regexp.last_match(2).empty?
91
+ arr << path
92
+ end
93
+ path_format.call(File.join(*paths))
94
+ end
95
+
96
+ include_paths = [].tap do |arr|
97
+ if a._include_paths.empty? && !Regexp.last_match(2).empty?
98
+ arr << Regexp.last_match(2)
99
+ else
100
+ arr.concat(a._include_paths.dup.map(&include_exclude_path_format))
101
+ end
102
+ end
103
+ exclude_paths = a._exclude_paths.dup.map(&include_exclude_path_format)
91
104
 
92
105
  {
93
106
  index: artifacts.index(a),
94
107
  to: to,
95
- include_paths: include_paths.map(&path_format),
96
- exclude_paths: exclude_paths.map(&path_format)
108
+ include_paths: include_paths,
109
+ exclude_paths: exclude_paths
97
110
  }
98
111
  end
99
112
  end
@@ -105,6 +105,14 @@ module Dapp
105
105
  **{ follow: follow }.merge(query_parameters))
106
106
  rescue Excon::Error::Timeout
107
107
  raise Error::Timeout
108
+ rescue Error::Base => err
109
+ if err.net_status[:code] == :bad_request and
110
+ err.net_status[:data][:response_body] and
111
+ err.net_status[:data][:response_body]['message'].end_with? 'ContainerCreating'
112
+ raise Error::Pod::ContainerCreating, data: err.net_status[:data]
113
+ else
114
+ raise
115
+ end
108
116
  end
109
117
 
110
118
  def event_list(**query_parameters)
@@ -152,7 +160,7 @@ module Dapp
152
160
  else
153
161
  raise Error::NotFound, data: err_data
154
162
  end
155
- else not response.status.to_s.start_with? '2'
163
+ elsif not response.status.to_s.start_with? '2'
156
164
  raise Error::Base, code: :bad_request, data: err_data
157
165
  end
158
166
  end
@@ -19,6 +19,11 @@ module Dapp
19
19
 
20
20
  module Pod
21
21
  class NotFound < Kubernetes::Client::Error::NotFound ; end
22
+ class ContainerCreating < Kubernetes::Client::Error::Base
23
+ def initialize(**net_status)
24
+ super({code: :container_creating}.merge(net_status))
25
+ end
26
+ end
22
27
  end # Pod
23
28
  end # Kubernetes::Client::Error
24
29
  end # Kube
@@ -13,22 +13,12 @@ module Dapp
13
13
  @processed_log_timestamps = Set.new
14
14
  end
15
15
 
16
- def wait_till_created!
17
- pod_manager.wait_till_running!
18
-
19
- loop do
20
- pod = Kubernetes::Client::Resource::Pod.new(dapp.kubernetes.pod(pod_manager.name))
21
- break unless pod.container_state(name).first == 'waiting'
22
- sleep 0.1
23
- end
24
- end
25
-
26
16
  def watch_till_terminated!
27
17
  pod = Kubernetes::Client::Resource::Pod.new(dapp.kubernetes.pod(pod_manager.name))
28
18
  _, container_state_data = pod.container_state(name)
29
19
  return if @processed_containers_ids.include? container_state_data['containerID']
30
20
 
31
- wait_till_created!
21
+ pod_manager.wait_till_running!
32
22
 
33
23
  pod = Kubernetes::Client::Resource::Pod.new(dapp.kubernetes.pod(pod_manager.name))
34
24
  container_state, container_state_data = pod.container_state(name)
@@ -38,14 +28,20 @@ module Dapp
38
28
  pod = Kubernetes::Client::Resource::Pod.new(dapp.kubernetes.pod(pod_manager.name))
39
29
  container_state, container_state_data = pod.container_state(name)
40
30
 
41
- chunk_lines_by_time = dapp.kubernetes.pod_log(pod_manager.name, container: name, timestamps: true, sinceTime: @processed_log_till_time)
42
- .lines
43
- .map(&:strip)
44
- .map do |line|
45
- timestamp, _, data = line.partition(' ')
46
- [timestamp, data]
47
- end
48
- .reject {|timestamp, _| @processed_log_timestamps.include? timestamp}
31
+ chunk_lines_by_time = {}
32
+ begin
33
+ chunk_lines_by_time = dapp.kubernetes.pod_log(pod_manager.name, container: name, timestamps: true, sinceTime: @processed_log_till_time)
34
+ .lines
35
+ .map(&:strip)
36
+ .map do |line|
37
+ timestamp, _, data = line.partition(' ')
38
+ [timestamp, data]
39
+ end
40
+ .reject {|timestamp, _| @processed_log_timestamps.include? timestamp}
41
+ rescue Kubernetes::Client::Error::Pod::ContainerCreating
42
+ sleep 0.1
43
+ next
44
+ end
49
45
 
50
46
  chunk_lines_by_time.each do |timestamp, data|
51
47
  dapp.log("[#{timestamp}] #{data}")
@@ -112,23 +112,26 @@ module Dapp
112
112
 
113
113
  dapp.with_log_indent do
114
114
  pod.containers_names.each do |container_name|
115
- next if pod.container_state(name).first == 'waiting'
116
-
117
115
  known_log_timestamps_by_pod_and_container[pod.name] ||= {}
118
116
  known_log_timestamps_by_pod_and_container[pod.name][container_name] ||= Set.new
119
117
 
120
118
  since_time = nil
121
119
  since_time = @deployed_at.utc.iso8601(9) if @deployed_at
122
120
 
123
- log_lines_by_time = dapp.kubernetes.pod_log(pod.name, container: container_name, timestamps: true, sinceTime: since_time)
124
- .lines.map(&:strip)
125
- .map {|line|
126
- timestamp, _, data = line.partition(' ')
127
- unless known_log_timestamps_by_pod_and_container[pod.name][container_name].include? timestamp
128
- known_log_timestamps_by_pod_and_container[pod.name][container_name].add timestamp
129
- [timestamp, data]
130
- end
131
- }.compact
121
+ log_lines_by_time = []
122
+ begin
123
+ log_lines_by_time = dapp.kubernetes.pod_log(pod.name, container: container_name, timestamps: true, sinceTime: since_time)
124
+ .lines.map(&:strip)
125
+ .map {|line|
126
+ timestamp, _, data = line.partition(' ')
127
+ unless known_log_timestamps_by_pod_and_container[pod.name][container_name].include? timestamp
128
+ known_log_timestamps_by_pod_and_container[pod.name][container_name].add timestamp
129
+ [timestamp, data]
130
+ end
131
+ }.compact
132
+ rescue Kubernetes::Client::Error::Pod::ContainerCreating
133
+ next
134
+ end
132
135
 
133
136
  if log_lines_by_time.any?
134
137
  dapp.log_step("Last container '#{container_name}' log:")
@@ -40,7 +40,7 @@ module Dapp
40
40
  if job.succeeded?
41
41
  break
42
42
  elsif job.failed?
43
- warn "Job '#{name}' has been failed: #{job.spec['status']}"
43
+ dapp.log_warning "Job '#{name}' has been failed: #{job.spec['status']}"
44
44
  break
45
45
  end
46
46
 
@@ -53,7 +53,7 @@ module Dapp
53
53
  begin
54
54
  pod_manager.watch_till_done!
55
55
  rescue Kubernetes::Client::Error::Pod::NotFound => err
56
- warn "Pod '#{err.net_status.fetch(:response_body, {}).fetch('details', {})['name']}' has been deleted"
56
+ dapp.log_warning "Pod '#{pod_manager.name}' has been deleted"
57
57
  ensure
58
58
  @processed_pods_names << process_pod.name
59
59
  end
data/lib/dapp/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = '0.13.17'.freeze
2
+ VERSION = '0.13.18'.freeze
3
3
  BUILD_CACHE_VERSION = 15
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.17
4
+ version: 0.13.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Stolyarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-03 00:00:00.000000000 Z
11
+ date: 2017-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout