barbeque 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e23cea0a69664e6f2351d1651daaf0b42355a71f
|
4
|
+
data.tar.gz: 4c76a4e57cbb43baa302841f7eb565a1f3602fb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1021988ef2880d1bb8009d5c2fb397803a0e9a02577ff66cd961638f415dd877012340bb86564b6855efa1c65d44751b1bffc16aea1bce98697465f3c4a1b940
|
7
|
+
data.tar.gz: 0e48ddda04e6ebb25e5cff2bcc7c21f440848b2a5588286eb9e89289d70d5b6863bdb00ebe9c7d6dc70424bba37bbc143795e7cc055fcc089518a57a3375f8c7
|
@@ -7,21 +7,25 @@ module Barbeque
|
|
7
7
|
DEFAULT_S3_BUCKET_NAME = 'barbeque'
|
8
8
|
|
9
9
|
class << self
|
10
|
-
delegate :
|
10
|
+
delegate :save_message, :save_stdout_and_stderr, :load, to: :new
|
11
11
|
|
12
12
|
def s3_client
|
13
13
|
@s3_client ||= Aws::S3::Client.new
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
# @param [Barbeque::JobExecution] execution
|
18
|
+
# @param [Barbeque::Message::JobExecution] message
|
19
|
+
def save_message(execution, message)
|
20
|
+
put(execution, 'message.json', message.body.to_json)
|
21
|
+
end
|
22
|
+
|
17
23
|
# @param [Barbeque::JobExecution,Barbeque::JobRetry] execution
|
18
|
-
# @param [
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
body: log.to_json,
|
24
|
-
)
|
24
|
+
# @param [String] stdout
|
25
|
+
# @param [String] stderr
|
26
|
+
def save_stdout_and_stderr(execution, stdout, stderr)
|
27
|
+
put(execution, 'stdout.txt', stdout)
|
28
|
+
put(execution, 'stderr.txt', stderr)
|
25
29
|
end
|
26
30
|
|
27
31
|
# @param [Barbeque::JobExecution,Barbeque::JobRetry] execution
|
@@ -29,13 +33,27 @@ module Barbeque
|
|
29
33
|
def load(execution:)
|
30
34
|
return {} if execution.pending?
|
31
35
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
message = get(execution, 'message.json')
|
37
|
+
stdout = get(execution, 'stdout.txt')
|
38
|
+
stderr = get(execution, 'stderr.txt')
|
39
|
+
if message || stdout || stderr
|
40
|
+
{
|
41
|
+
'message' => message,
|
42
|
+
'stdout' => stdout,
|
43
|
+
'stderr' => stderr,
|
44
|
+
}
|
45
|
+
else
|
46
|
+
# Try to load legacy format
|
47
|
+
begin
|
48
|
+
s3_object = ExecutionLog.s3_client.get_object(
|
49
|
+
bucket: s3_bucket_name,
|
50
|
+
key: legacy_s3_key_for(execution),
|
51
|
+
)
|
52
|
+
JSON.parse(s3_object.body.read)
|
53
|
+
rescue Aws::S3::Errors::NoSuchKey
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
39
57
|
end
|
40
58
|
|
41
59
|
private
|
@@ -45,9 +63,38 @@ module Barbeque
|
|
45
63
|
end
|
46
64
|
|
47
65
|
# @param [Barbeque::JobExecution,Barbeque::JobRetry] execution
|
48
|
-
# @param [String]
|
49
|
-
def s3_key_for(execution
|
50
|
-
|
66
|
+
# @param [String] filename
|
67
|
+
def s3_key_for(execution, filename)
|
68
|
+
"#{execution.app.name}/#{execution.job_definition.job}/#{execution.message_id}/#{filename}"
|
69
|
+
end
|
70
|
+
|
71
|
+
# @param [Barbeque::JobExecution,Barbeque::JobRetry] execution
|
72
|
+
def legacy_s3_key_for(execution)
|
73
|
+
"#{execution.app.name}/#{execution.job_definition.job}/#{execution.message_id}"
|
74
|
+
end
|
75
|
+
|
76
|
+
# @param [Barbeque::JobExecution,Barbeque::JobRetry] execution
|
77
|
+
# @param [String] filename
|
78
|
+
# @return [String]
|
79
|
+
def get(execution, filename)
|
80
|
+
s3_object = ExecutionLog.s3_client.get_object(
|
81
|
+
bucket: s3_bucket_name,
|
82
|
+
key: s3_key_for(execution, filename),
|
83
|
+
)
|
84
|
+
s3_object.body.read
|
85
|
+
rescue Aws::S3::Errors::NoSuchKey
|
86
|
+
nil
|
87
|
+
end
|
88
|
+
|
89
|
+
# @param [Barbeque::JobExecution,Barbeque::JobRetry] execution
|
90
|
+
# @param [String] filename
|
91
|
+
# @param [String] content
|
92
|
+
def put(execution, filename, content)
|
93
|
+
ExecutionLog.s3_client.put_object(
|
94
|
+
bucket: s3_bucket_name,
|
95
|
+
key: s3_key_for(execution, filename),
|
96
|
+
body: content,
|
97
|
+
)
|
51
98
|
end
|
52
99
|
end
|
53
100
|
end
|
@@ -38,8 +38,8 @@ module Barbeque
|
|
38
38
|
private
|
39
39
|
|
40
40
|
def log_result(execution, stdout, stderr)
|
41
|
-
|
42
|
-
Barbeque::ExecutionLog.
|
41
|
+
Barbeque::ExecutionLog.save_message(execution, @message) # TODO: Should be saved earlier
|
42
|
+
Barbeque::ExecutionLog.save_stdout_and_stderr(execution, stdout, stderr)
|
43
43
|
end
|
44
44
|
|
45
45
|
def notify_slack(job_execution)
|
@@ -44,8 +44,7 @@ module Barbeque
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def log_result(job_retry, stdout, stderr)
|
47
|
-
|
48
|
-
Barbeque::ExecutionLog.save(execution: job_retry, log: log)
|
47
|
+
Barbeque::ExecutionLog.save_stdout_and_stderr(job_retry, stdout, stderr)
|
49
48
|
end
|
50
49
|
|
51
50
|
# @param [Barbeque::JobRetry] job_retry
|
data/lib/barbeque/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barbeque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: adminlte2-rails
|