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 +4 -4
- data/lib/dapp/dimg/config/directive/dimg/validation.rb +19 -6
- data/lib/dapp/kube/kubernetes/client.rb +9 -1
- data/lib/dapp/kube/kubernetes/client/error.rb +5 -0
- data/lib/dapp/kube/kubernetes/manager/container.rb +15 -19
- data/lib/dapp/kube/kubernetes/manager/deployment.rb +14 -11
- data/lib/dapp/kube/kubernetes/manager/job.rb +2 -2
- data/lib/dapp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6b08668d5e7085683b983ee2459556137efd222
|
4
|
+
data.tar.gz: c4897d4a33e753fde1569993557c1524627eb2c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
89
|
-
|
90
|
-
|
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
|
96
|
-
exclude_paths: exclude_paths
|
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
|
-
|
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
|
-
|
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 =
|
42
|
-
|
43
|
-
.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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 =
|
124
|
-
|
125
|
-
.
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
[timestamp
|
130
|
-
|
131
|
-
|
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
|
-
|
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
|
-
|
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
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.
|
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-
|
11
|
+
date: 2017-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|