flydata 0.5.9 → 0.5.10
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 +4 -4
- data/VERSION +1 -1
- data/flydata.gemspec +5 -3
- data/lib/flydata/command/helper.rb +10 -3
- data/lib/flydata/command/setup.rb +5 -0
- data/lib/flydata/helper/action/agent_action.rb +1 -1
- data/lib/flydata/helper/action/check_abnormal_shutdown.rb +29 -0
- data/lib/flydata/helper/action_ownership.rb +1 -0
- data/lib/flydata/helper/config_parser.rb +3 -0
- data/spec/flydata/command/helper_spec.rb +17 -3
- data/spec/flydata/helper/action/check_abnormal_shutdown_spec.rb +12 -0
- data/spec/flydata/helper/action_ownership_spec.rb +2 -1
- data/spec/flydata/helper/config_parser_spec.rb +11 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ae9067dda053aa56404eb3260e3518679d787cd
|
4
|
+
data.tar.gz: f4af787def23a4860a8bbe5ed4619e61bb8abb7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6160a696088969741b7fb49cc44c1a7e28cf8af0d839a8fec431b8549ec9ebfc5e54cb4845bfb3ccb789585e5fd9953e75d0fc16136d443c0b251f269aa7af4
|
7
|
+
data.tar.gz: 6df8c0c9a3bd151d157ba2ac01e1c74757abfb1abc86cc23774b33ddebcc06331f4f7af798a49432af9a6cf0bf750363dc039d8f40f119494cdc0da102eb17ac
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.10
|
data/flydata.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: flydata 0.5.
|
5
|
+
# stub: flydata 0.5.10 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "flydata"
|
9
|
-
s.version = "0.5.
|
9
|
+
s.version = "0.5.10"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Koichi Fujikawa", "Masashi Miyazaki", "Matthew Luu", "Mak Inada", "Sriram NS"]
|
14
|
-
s.date = "2015-10-
|
14
|
+
s.date = "2015-10-04"
|
15
15
|
s.description = "FlyData Agent"
|
16
16
|
s.email = "sysadmin@flydata.com"
|
17
17
|
s.executables = ["fdmysqldump", "flydata", "serverinfo"]
|
@@ -146,6 +146,7 @@ Gem::Specification.new do |s|
|
|
146
146
|
"lib/flydata/fluent-plugins/preference.rb",
|
147
147
|
"lib/flydata/flydata_crontab.sh",
|
148
148
|
"lib/flydata/helper/action/agent_action.rb",
|
149
|
+
"lib/flydata/helper/action/check_abnormal_shutdown.rb",
|
149
150
|
"lib/flydata/helper/action/check_remote_actions.rb",
|
150
151
|
"lib/flydata/helper/action/restart_agent.rb",
|
151
152
|
"lib/flydata/helper/action/send_logs.rb",
|
@@ -207,6 +208,7 @@ Gem::Specification.new do |s|
|
|
207
208
|
"spec/flydata/fluent-plugins/mysql/shared_query_handler_context.rb",
|
208
209
|
"spec/flydata/fluent-plugins/mysql/table_meta_spec.rb",
|
209
210
|
"spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb",
|
211
|
+
"spec/flydata/helper/action/check_abnormal_shutdown_spec.rb",
|
210
212
|
"spec/flydata/helper/action/check_remote_actions_spec.rb",
|
211
213
|
"spec/flydata/helper/action/restart_agent_spec.rb",
|
212
214
|
"spec/flydata/helper/action/send_logs_spec.rb",
|
@@ -66,12 +66,19 @@ module Flydata
|
|
66
66
|
def restart(options = {})
|
67
67
|
if running?
|
68
68
|
log_info_stdout("Restarting Helper.", {}, options)
|
69
|
-
run_command(
|
70
|
-
else
|
71
|
-
raw_start
|
69
|
+
run_command(stop_cmd)
|
72
70
|
end
|
71
|
+
raw_start
|
73
72
|
end
|
74
73
|
|
74
|
+
def reload(options = {})
|
75
|
+
if running?
|
76
|
+
log_info_stdout("Reloading Helper.", {}, options)
|
77
|
+
run_command(kill_hup_cmd)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
|
75
82
|
private
|
76
83
|
|
77
84
|
def create_config_with_args
|
@@ -2,6 +2,7 @@ require 'flydata/command/base'
|
|
2
2
|
require 'flydata/command/conf'
|
3
3
|
require 'flydata/command/login'
|
4
4
|
require 'flydata/command/sender'
|
5
|
+
require 'flydata/command/helper'
|
5
6
|
require 'flydata/helpers'
|
6
7
|
require 'flydata/sync_file_manager'
|
7
8
|
|
@@ -89,6 +90,10 @@ What's next?
|
|
89
90
|
redshift_console_url = "#{flydata.flydata_api_host}/redshift_clusters/query/new"
|
90
91
|
last_message = ALL_DONE_MESSAGE_TEMPLATE % [redshift_console_url, dashboard_url]
|
91
92
|
|
93
|
+
# Surprisingly, Helper's start method kills the process after starting
|
94
|
+
# the helper thanks to ServerEngine. So the command needs to run in a
|
95
|
+
# separate process.
|
96
|
+
fork { Flydata::Command::Helper.new.restart(quiet: true) }
|
92
97
|
run(quiet: true) do
|
93
98
|
Flydata::Command::Conf.new.copy_templates
|
94
99
|
puts
|
@@ -12,7 +12,7 @@ module Flydata
|
|
12
12
|
log_debug("Executing #{cmd}")
|
13
13
|
o, e, s = Util::Shell.run_cmd(cmd)
|
14
14
|
log_error(e) if not e.to_s.empty?
|
15
|
-
|
15
|
+
log_error("Could not execute #{cmd}. Response status : #{s}") unless (s.to_i == 0)
|
16
16
|
end
|
17
17
|
|
18
18
|
# Override this. Needs to be implemented by the subclass
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'flydata'
|
2
|
+
require 'flydata/helper/base_action'
|
3
|
+
|
4
|
+
module Flydata
|
5
|
+
module Helper
|
6
|
+
module Action
|
7
|
+
class CheckAbnormalShutdown < BaseAction
|
8
|
+
def execute(opts = {})
|
9
|
+
if abnormal_shutdown_occurred?
|
10
|
+
log_info "Abnormal shutdown occurred. Restart the agent."
|
11
|
+
yield :restart_agent, nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def abnormal_shutdown_occurred?
|
17
|
+
File.exists?(FLYDATA_LOCK) && !process_exists?(File.open(FLYDATA_LOCK){|f| f.read})
|
18
|
+
end
|
19
|
+
|
20
|
+
def process_exists?(pid)
|
21
|
+
Process.getpgid(pid.to_i)
|
22
|
+
true
|
23
|
+
rescue Errno::ESRCH
|
24
|
+
false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -43,6 +43,7 @@ module Flydata
|
|
43
43
|
def self.action_ownership_map
|
44
44
|
[
|
45
45
|
self.new(:check_remote_actions, false, Action::CheckRemoteActions),
|
46
|
+
self.new(:check_abnormal_shutdown, false, Action::CheckAbnormalShutdown),
|
46
47
|
self.new(:send_logs, false, Action::SendLogs),
|
47
48
|
self.new(:stop_agent, true, Action::StopAgent),
|
48
49
|
self.new(:restart_agent, true, Action::RestartAgent)
|
@@ -10,7 +10,7 @@ module Flydata
|
|
10
10
|
|
11
11
|
PROCESS_REGEX = /^\[ -f .*helper.pid \] \&\& pgrep -P `cat .*helper.pid`$/
|
12
12
|
STOP_REGEX = /kill `cat .*helper.pid`\n/
|
13
|
-
|
13
|
+
RELOAD_REGEX = /kill -HUP `cat .*helper.pid`/
|
14
14
|
|
15
15
|
shared_examples "test start command" do
|
16
16
|
context "when the Helper process is not running" do
|
@@ -82,11 +82,12 @@ module Flydata
|
|
82
82
|
describe "#restart" do
|
83
83
|
subject { helper.restart }
|
84
84
|
context "when the Helper process is running" do
|
85
|
-
it "
|
85
|
+
it "stops and starts the process" do
|
86
86
|
expect(helper).to receive(:'`').with(PROCESS_REGEX).and_return("1")
|
87
87
|
expect(Open3).to receive(:capture3) do |env, cmd|
|
88
|
-
expect(cmd).to match(
|
88
|
+
expect(cmd).to match(STOP_REGEX)
|
89
89
|
end
|
90
|
+
expect(Flydata::Helper::Server).to receive(:run)
|
90
91
|
subject
|
91
92
|
end
|
92
93
|
end
|
@@ -99,6 +100,19 @@ module Flydata
|
|
99
100
|
end
|
100
101
|
end
|
101
102
|
|
103
|
+
describe '#reload' do
|
104
|
+
subject { helper.reload }
|
105
|
+
context "when the Helper process is running" do
|
106
|
+
it "sends the KILL -HUP to the process to reload config" do
|
107
|
+
expect(helper).to receive(:'`').with(PROCESS_REGEX).and_return("1")
|
108
|
+
expect(Open3).to receive(:capture3) do |env, cmd|
|
109
|
+
expect(cmd).to match(RELOAD_REGEX)
|
110
|
+
end
|
111
|
+
subject
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
102
116
|
describe "#status" do
|
103
117
|
subject { helper.status }
|
104
118
|
context "when the Helper process is running" do
|
@@ -36,8 +36,9 @@ module Flydata
|
|
36
36
|
describe '.action_ownership_map' do
|
37
37
|
subject { described_class.action_ownership_map }
|
38
38
|
it do
|
39
|
-
expect(subject.size).to eq(
|
39
|
+
expect(subject.size).to eq(5)
|
40
40
|
expect(subject.include?(:check_remote_actions)).to be(true)
|
41
|
+
expect(subject.include?(:check_abnormal_shutdown)).to be(true)
|
41
42
|
expect(subject.include?(:send_logs)).to be(true)
|
42
43
|
expect(subject.include?(:stop_agent)).to be(true)
|
43
44
|
expect(subject.include?(:restart_agent)).to be(true)
|
@@ -33,6 +33,11 @@ module Flydata
|
|
33
33
|
{
|
34
34
|
check_interval: 30,
|
35
35
|
name: :check_remote_actions
|
36
|
+
},
|
37
|
+
check_abnormal_shutdown:
|
38
|
+
{
|
39
|
+
check_interval: 60,
|
40
|
+
name: :check_abnormal_shutdown
|
36
41
|
}
|
37
42
|
})
|
38
43
|
end
|
@@ -65,6 +70,9 @@ module Flydata
|
|
65
70
|
scheduled_actions: {
|
66
71
|
check_remote_actions: {
|
67
72
|
check_interval: '30s'
|
73
|
+
},
|
74
|
+
check_abnormal_shutdown: {
|
75
|
+
check_interval: '60s'
|
68
76
|
}
|
69
77
|
}
|
70
78
|
}
|
@@ -87,6 +95,9 @@ EOT
|
|
87
95
|
scheduled_actions: {
|
88
96
|
check_remote_actions: {
|
89
97
|
check_interval: '1m'
|
98
|
+
},
|
99
|
+
check_abnormal_shutdown: {
|
100
|
+
check_interval: '60s'
|
90
101
|
}
|
91
102
|
}
|
92
103
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flydata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Fujikawa
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-10-
|
15
|
+
date: 2015-10-04 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rest-client
|
@@ -583,6 +583,7 @@ files:
|
|
583
583
|
- lib/flydata/fluent-plugins/preference.rb
|
584
584
|
- lib/flydata/flydata_crontab.sh
|
585
585
|
- lib/flydata/helper/action/agent_action.rb
|
586
|
+
- lib/flydata/helper/action/check_abnormal_shutdown.rb
|
586
587
|
- lib/flydata/helper/action/check_remote_actions.rb
|
587
588
|
- lib/flydata/helper/action/restart_agent.rb
|
588
589
|
- lib/flydata/helper/action/send_logs.rb
|
@@ -644,6 +645,7 @@ files:
|
|
644
645
|
- spec/flydata/fluent-plugins/mysql/shared_query_handler_context.rb
|
645
646
|
- spec/flydata/fluent-plugins/mysql/table_meta_spec.rb
|
646
647
|
- spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb
|
648
|
+
- spec/flydata/helper/action/check_abnormal_shutdown_spec.rb
|
647
649
|
- spec/flydata/helper/action/check_remote_actions_spec.rb
|
648
650
|
- spec/flydata/helper/action/restart_agent_spec.rb
|
649
651
|
- spec/flydata/helper/action/send_logs_spec.rb
|