fluentd-ui 0.3.7 → 0.3.8

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.

Potentially problematic release.


This version of fluentd-ui might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2210220da165c45be2831a62cc96474a80a9a795
4
- data.tar.gz: 6261e50fe33359ce5938a6379e5d686972c89858
3
+ metadata.gz: e8a878149540a61f5a1c3332f91c788ba07658a0
4
+ data.tar.gz: b3ffe587af20b8d6feeb79ea48b2ab684a851fe2
5
5
  SHA512:
6
- metadata.gz: af189cc9da3708a2d1aa7870a0fbd9ed6e9af0b2eaf27a764f6a325b8c786a951fb83648b5432168d7024f0c1c56fa0528ac5f2009149416ce27fc0f38e3802e
7
- data.tar.gz: ea8050d54e079e2963348aba49bb1d48606a348efa5b34f546fea42489e98e93543cf0500ef9626375e74bdf2e16993f9215b061ad2591926a7d8e448356d001
6
+ metadata.gz: 9e467bd3ae13cb3c600a63c9a5bd7e76d2d1be168ddfc1bd39a9fb3e529b04f9650a140f535ced690630363745f6f7543c559e87acbc7fa58d528ff24e8bfa73
7
+ data.tar.gz: 77f4eb293166a4511e38076e46047326040c08537668a37c6f13ce137ffa9a631452beeaff001026f5f474d8260412064977ce044a124b72a17964d845efab65
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ Release 0.3.8 - 2014/11/19
2
+
3
+ * [improve] Recommended plugins are updated.
4
+ * [fixed] Plugin installation on td-agent-ui.
5
+
6
+
1
7
  Release 0.3.7 - 2014/11/13
2
8
 
3
9
  * [maintenance] Change httpclient gem as stable version.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluentd-ui (0.3.7)
4
+ fluentd-ui (0.3.8)
5
5
  addressable
6
6
  bundler
7
7
  draper (~> 1.3)
@@ -0,0 +1,66 @@
1
+ module FluentGem
2
+ class GemError < StandardError; end
3
+
4
+ class << self
5
+ LIST_CACHE_KEY = "gem_list".freeze
6
+
7
+ def install(*args)
8
+ run("install", *args)
9
+ end
10
+
11
+ def uninstall(*args)
12
+ run("uninstall", *args)
13
+ end
14
+
15
+ def list
16
+ # NOTE: gem list is heavyly used from anywhere in 1 request, if not caching, user experience to be bad
17
+ # but long living caching causes mismatch with actual status e.g. user install plugin from console (without fluentd-ui)
18
+ # So our decision is that cache `gem list` in 3 seconds
19
+ Rails.cache.fetch(LIST_CACHE_KEY, expires_in: 3.seconds) do
20
+ output = `#{gem} list`
21
+ unless $?.exitstatus.zero?
22
+ raise GemError, "failed command: `#{gem} list`"
23
+ end
24
+ output.lines
25
+ end
26
+ end
27
+
28
+ def run(*args)
29
+ # NOTE: use `fluent-gem` instead of `gem`
30
+ Bundler.with_clean_env do
31
+ # NOTE: this app is under the Bundler, so call `system` in with_clean_env is Bundler jail breaking
32
+ cmd = [gem, *args].compact
33
+ unless system(*cmd)
34
+ raise GemError, "failed command: `#{cmd.join(" ")}`"
35
+ end
36
+ Rails.cache.delete(LIST_CACHE_KEY)
37
+ end
38
+ true
39
+ end
40
+
41
+ def gem
42
+ # Not yet setup any fluentd/td-agent
43
+ return "fluent-gem" unless Fluentd.instance
44
+
45
+ # On installed both td-agent and fluentd system, decide which fluent-gem command should be used depend on setup(Fluentd.instance)
46
+ if Fluentd.instance && Fluentd.instance.fluentd?
47
+ "fluent-gem" # maybe `fluent-gem` command is in the $PATH
48
+ else
49
+ detect_td_agent_gem
50
+ end
51
+ end
52
+
53
+ def detect_td_agent_gem
54
+ # NOTE: td-agent has a command under the /usr/lib{,64}, td-agent2 has under /opt/td-agent
55
+ %W(
56
+ /usr/sbin/td-agent-gem
57
+ /opt/td-agent/embedded/bin/fluent-gem
58
+ /usr/lib/fluent/ruby/bin/fluent-gem
59
+ /usr/lib64/fluent/ruby/bin/fluent-gem
60
+ fluent-gem
61
+ ).find do |path|
62
+ system("which #{path}", out: File::NULL, err: File::NULL)
63
+ end
64
+ end
65
+ end
66
+ end
data/app/models/plugin.rb CHANGED
@@ -87,17 +87,12 @@ class Plugin
87
87
  end
88
88
 
89
89
  def self.installed
90
- Rails.cache.fetch("installed_gems", expires_in: 3.seconds) do
91
- Bundler.with_clean_env do
92
- fluent_gem = fluent_gem_path
93
- return [] unless fluent_gem
94
- gems = `#{fluent_gem} list`.try(:lines)
95
- return [] unless gems
96
- gems.grep(/fluent-plugin/).map do |gem|
97
- name, versions_str = gem.strip.split(" ")
98
- version = versions_str[/[^(), ]+/]
99
- new(gem_name: name, version: version)
100
- end
90
+ Bundler.with_clean_env do
91
+ gems = FluentGem.list
92
+ gems.grep(/fluent-plugin/).map do |gem|
93
+ name, versions_str = gem.strip.split(" ")
94
+ version = versions_str[/[^(), ]+/]
95
+ new(gem_name: name, version: version)
101
96
  end
102
97
  end
103
98
  end
@@ -141,23 +136,6 @@ class Plugin
141
136
  "https://rubygems.org/api/v1/versions/#{gem_name}.json"
142
137
  end
143
138
 
144
- def self.fluent_gem_path
145
- # On installed both td-agent and fluentd system, decide which fluent-gem command should be used depend on setup(Fluentd.instance)
146
- if Fluentd.instance && Fluentd.instance.fluentd?
147
- return "fluent-gem" # maybe `fluent-gem` command is in the $PATH
148
- end
149
-
150
- # NOTE: td-agent has a command under the /usr/lib{,64}, td-agent2 has under /opt/td-agent
151
- %W(
152
- /opt/td-agent/embedded/bin/fluent-gem
153
- /usr/lib/fluent/ruby/bin/fluent-gem
154
- /usr/lib64/fluent/ruby/bin/fluent-gem
155
- fluent-gem
156
- ).find do |path|
157
- system("which #{path}", out: File::NULL, err: File::NULL)
158
- end
159
- end
160
-
161
139
  private
162
140
 
163
141
  def gem_install
@@ -165,7 +143,7 @@ class Plugin
165
143
  return if processing?
166
144
  return if installed?
167
145
  WORKING.push(data)
168
- fluent_gem("install", gem_name, "--no-document", "-v", version)
146
+ FluentGem.install(gem_name, "--no-ri", "--no-rdoc", "-v", version)
169
147
  ensure
170
148
  WORKING.delete(data)
171
149
  end
@@ -175,23 +153,8 @@ class Plugin
175
153
  return if processing?
176
154
  return unless installed?
177
155
  WORKING.push(data)
178
- fluent_gem("uninstall", gem_name, "-x", "-a")
156
+ FluentGem.uninstall(gem_name, "-x", "-a")
179
157
  ensure
180
158
  WORKING.delete(data)
181
159
  end
182
-
183
- def fluent_gem(*commands)
184
- # NOTE: use `fluent-gem` instead of `gem`
185
- Bundler.with_clean_env do
186
- # NOTE: this app is under the Bundler, so call `system` in with_clean_env is Bundler jail breaking
187
- unless system(* [fluent_gem_path, *commands])
188
- raise GemError, "failed command #{commands.join(" ")}"
189
- end
190
- end
191
- true
192
- end
193
-
194
- def fluent_gem_path
195
- self.class.fluent_gem_path
196
- end
197
160
  end
@@ -34,8 +34,6 @@ defaults: &defaults
34
34
  name: "numeric-counter"
35
35
  - category: storage
36
36
  name: "webhdfs"
37
- - category: data_source
38
- name: "tail-multiline"
39
37
  - category: filter
40
38
  name: "parser"
41
39
  - category: storage
@@ -44,14 +42,18 @@ defaults: &defaults
44
42
  name: "dstat"
45
43
  - category: filter
46
44
  name: "record-reformer"
47
- - category: data_source
48
- name: "tail-ex"
49
45
  - category: storage
50
46
  name: "zabbix-simple-bufferd"
51
47
  - category: processing
52
48
  name: "numeric-monitor"
53
49
  - category: notification
54
50
  name: "ping-message"
51
+ - category: processing
52
+ name: "extract_query_params"
53
+ - category: processing
54
+ name: "norikra"
55
+ - category: notification
56
+ name: "cloudwatch"
55
57
  - category: storage
56
58
  name: "pghstore"
57
59
  - category: filter
@@ -62,44 +64,30 @@ defaults: &defaults
62
64
  name: "grep"
63
65
  - category: processing
64
66
  name: "grepcounter"
65
- - category: data_source
66
- name: "mysqlslowquery"
67
+ - category: processing
68
+ name: "groupcounter"
67
69
  - category: routing
68
70
  name: "keep-forward"
69
71
  - category: notification
70
72
  name: "mail"
71
73
  - category: filter
72
74
  name: "record-modifier"
73
- - category: storage
74
- name: "mysql"
75
75
  - category: notification
76
76
  name: "sns"
77
77
  - category: data_source
78
78
  name: "munin"
79
- - category: routing
80
- name: "flume"
81
- - category: data_source
82
- name: "tail-asis"
83
79
  - category: monitoring
84
80
  name: "metricsense"
85
81
  - category: storage
86
82
  name: "sqs"
87
83
  - category: processing
88
84
  name: "datacalculator"
89
- - category: search
90
- name: "splunkapi"
91
85
  - category: filter
92
86
  name: "amplifier-filter"
93
87
  - category: filter
94
88
  name: "sampling-filter"
95
- - category: notification
96
- name: "growl"
97
- - category: storage
98
- name: "dynamodb"
99
89
  - category: processing
100
90
  name: "flatten"
101
- - category: storage
102
- name: "hoop"
103
91
  - category: processing
104
92
  name: "anomalydetect"
105
93
  - category: notification
@@ -110,34 +98,28 @@ defaults: &defaults
110
98
  name: "redis-counter"
111
99
  - category: storage
112
100
  name: "kestrel"
113
- - category: routing
114
- name: "udp"
115
101
  - category: storage
116
102
  name: "forward-aws"
117
- - category: processing
118
- name: "extract_query_params"
119
- - category: processing
120
- name: "norikra"
121
- - category: notification
122
- name: "cloudwatch"
123
103
  - category: data_source
124
104
  name: "snmp"
125
- - category: data_source
126
- name: "http-enhanced"
127
105
  - category: processing
128
- name: "calc"
106
+ name: "stats"
107
+ - category: storage
108
+ name: "dynamodb"
109
+ - category: storage
110
+ name: "cassandra"
129
111
  - category: storage
130
112
  name: "cassandra-cql"
131
- - category: filter
132
- name: "hostname"
133
113
  - category: data_source
134
114
  name: "cloudstack"
115
+ - category: storage
116
+ name: "mysql"
135
117
  - category: data_source
136
118
  name: "mysql-query"
119
+ - category: data_source
120
+ name: "mysqlslowquery"
137
121
  - category: storage
138
122
  name: "redshift"
139
- - category: processing
140
- name: "groupcounter"
141
123
  - category: data_source
142
124
  name: "twitter"
143
125
  - category: data_source
@@ -148,8 +130,6 @@ defaults: &defaults
148
130
  name: "histogram"
149
131
  - category: routing
150
132
  name: "hash-forward"
151
- - category: notification
152
- name: "yohoushi"
153
133
  - category: storage
154
134
  name: "zmq"
155
135
  - category: monitoring
@@ -164,6 +144,8 @@ defaults: &defaults
164
144
  name: "suppress"
165
145
  - category: filter
166
146
  name: "filter"
147
+ - category: filter
148
+ name: "select"
167
149
  - category: storage
168
150
  name: "resque"
169
151
  - category: data_source
@@ -180,26 +162,24 @@ defaults: &defaults
180
162
  name: "reassemble"
181
163
  - category: data_source
182
164
  name: "jvmwatcher"
183
- - category: storage
184
- name: "redshift-kwarter"
185
165
  - category: data_source
186
166
  name: "http-status"
187
167
  - category: data_source
188
168
  name: "df"
189
169
  - category: processing
190
170
  name: "typecast"
191
- - category: filter
192
- name: "select"
193
171
  - category: data_source
194
172
  name: "rds-slowlog"
195
173
  - category: security
196
174
  name: "anonymizer"
197
175
  - category: search
198
176
  name: "splunk"
199
- - category: storage
200
- name: "cassandra"
177
+ - category: search
178
+ name: "splunkapi"
201
179
  - category: notification
202
180
  name: "boundio"
181
+ - category: notification
182
+ name: "growl"
203
183
 
204
184
  development:
205
185
  <<: *defaults
@@ -1,3 +1,3 @@
1
1
  module FluentdUI
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
data/lib/tasks/dep.rake CHANGED
@@ -2,6 +2,7 @@ namespace :dep do
2
2
  desc "list dependency gems order by less referenced"
3
3
  task :list do
4
4
  require "set"
5
+ require "fileutils"
5
6
  deps = Set.new
6
7
  context = false
7
8
  current_parent = false
@@ -9,9 +10,14 @@ namespace :dep do
9
10
  "bundler" => "1.7.4" # bundler version does not appear in Gemfile.lock
10
11
  }
11
12
  skip_gems = %w(fluentd)
13
+ ignore_gems_at_dump = %w(bundler rake json httpclient fluentd-ui) # these gems are installed by td-agent
12
14
  lock_file = "Gemfile.production.lock"
13
15
  unless ENV["SKIP_BUNDLE_INSTALL"]
14
- system("bundle install --gemfile Gemfile.production", out: STDERR) # ensure lock file is up to date
16
+ # ensure Gemfile.production.lock file is up to date
17
+ Bundler.with_clean_env do
18
+ FileUtils.cp "Gemfile.lock", "Gemfile.production.lock"
19
+ system("bundle install --no-deployment --gemfile Gemfile.production")
20
+ end
15
21
  end
16
22
 
17
23
  File.open(lock_file).each_line do |line|
@@ -53,6 +59,7 @@ namespace :dep do
53
59
  rank[parent] += 1
54
60
  end
55
61
  rank.to_a.sort_by {|(name, score)| score }.each do |(name, score)|
62
+ next if ignore_gems_at_dump.include?(name)
56
63
  puts %Q|download "#{name}", "#{versions[name]}"|
57
64
  end
58
65
  end
@@ -39,12 +39,12 @@ describe FileReverseReader do
39
39
 
40
40
  context "contain ascii only" do
41
41
  let(:content) { "ABCDE" }
42
- it { should be_false }
42
+ it { should == false }
43
43
  end
44
44
 
45
45
  context "contain non-ascii" do
46
46
  let(:content) { "\x89NG" }
47
- it { should be_true }
47
+ it { should == true }
48
48
  end
49
49
  end
50
50
 
@@ -0,0 +1,110 @@
1
+ require 'spec_helper'
2
+
3
+ describe FluentGem do
4
+ describe "#install" do
5
+ let(:gem) { FluentGem.gem }
6
+
7
+ context "no argument" do
8
+ after { FluentGem.install }
9
+ it { FluentGem.should_receive(:run).with("install") }
10
+ end
11
+
12
+ context "with arguments" do
13
+ after { FluentGem.install(*args) }
14
+
15
+ context "1" do
16
+ let(:args) { ["plugin-foo"] }
17
+ it { FluentGem.should_receive(:run).with("install", *args) }
18
+ end
19
+
20
+ context "2" do
21
+ let(:args) { ["plugin-foo", "--no-document"] }
22
+ it { FluentGem.should_receive(:run).with("install", *args) }
23
+ end
24
+ end
25
+ end
26
+
27
+ describe "#uninstall" do
28
+ let(:gem) { FluentGem.gem }
29
+
30
+ context "no argument" do
31
+ after { FluentGem.uninstall }
32
+ it { FluentGem.should_receive(:run).with("uninstall") }
33
+ end
34
+
35
+ context "with arguments" do
36
+ after { FluentGem.uninstall(*args) }
37
+
38
+ context "1" do
39
+ let(:args) { ["plugin-foo"] }
40
+ it { FluentGem.should_receive(:run).with("uninstall", *args) }
41
+ end
42
+
43
+ context "2" do
44
+ let(:args) { ["plugin-foo", "--no-document"] }
45
+ it { FluentGem.should_receive(:run).with("uninstall", *args) }
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "#list" do
51
+ before { FluentGem.stub(:`).and_return(gem_list) }
52
+ subject { FluentGem.list }
53
+
54
+ context "no list" do
55
+ let(:gem_list) { "" }
56
+ it { subject.to_a.should == [] }
57
+ end
58
+
59
+ context "some lines" do
60
+ let(:gem_list) { <<-GEM.strip_heredoc }
61
+ dummy (3.3.3)
62
+ fluent-plugin-foo (0.1.2)
63
+ more_dummy (0.0.1)
64
+ GEM
65
+ it { subject.to_a.should == gem_list.lines.to_a }
66
+ end
67
+
68
+ context "failed" do
69
+ let(:gem_list) { "" }
70
+ before { $?.stub(:exitstatus).and_return(128) }
71
+ it { expect{ subject }.to raise_error(FluentGem::GemError) }
72
+ end
73
+ end
74
+
75
+ describe "#run" do
76
+ before { FluentGem.stub(:system).and_return(ret) }
77
+ let(:args) { ["install", "foobar"] }
78
+
79
+ describe "success" do
80
+ let(:ret) { true }
81
+ after { FluentGem.run(*args) }
82
+ it { FluentGem.should_receive(:system) }
83
+ end
84
+
85
+ describe "failed" do
86
+ let(:ret) { false }
87
+ it { expect{ FluentGem.run(*args) }.to raise_error(FluentGem::GemError) }
88
+ end
89
+ end
90
+
91
+ describe "#gem" do
92
+ before { Fluentd.stub(:instance).and_return(instance) }
93
+ subject { FluentGem.gem }
94
+
95
+ context "any instance not setup yet" do
96
+ let(:instance) { nil }
97
+ it { should == "fluent-gem" }
98
+ end
99
+
100
+ context "fluentd setup" do
101
+ let(:instance) { Fluentd.new(id: nil, variant: "fluentd_gem", log_file: "dummy.log", pid_file: "dummy.pid", config_file: "dummy.conf") }
102
+ it { should == "fluent-gem" }
103
+ end
104
+
105
+ context "td-agent 2 setup" do
106
+ let(:instance) { Fluentd.new(id: nil, variant: "td_agent", log_file: "dummy.log", pid_file: "dummy.pid", config_file: "dummy.conf") }
107
+ it { should == FluentGem.detect_td_agent_gem }
108
+ end
109
+ end
110
+ end
@@ -4,7 +4,7 @@ describe Plugin do
4
4
  let(:plugin) { build(:plugin) }
5
5
 
6
6
  describe ".installed" do
7
- before { Plugin.stub(:"`").and_return(gem_list) }
7
+ before { FluentGem.stub(:"`").and_return(gem_list) }
8
8
 
9
9
  context "fluent-plugin-foo 0.1.2" do
10
10
  let(:target) { Plugin.new(gem_name: "fluent-plugin-foo", version: "0.1.2") }
@@ -73,12 +73,12 @@ describe Plugin do
73
73
 
74
74
  context "installed" do
75
75
  let(:installed) { true }
76
- it { plugin.should_not_receive(:fluent_gem) }
76
+ it { FluentGem.should_not_receive(:install) }
77
77
  end
78
78
 
79
79
  context "not installed" do
80
80
  let(:installed) { false }
81
- it { plugin.should_receive(:fluent_gem) }
81
+ it { FluentGem.should_receive(:install) }
82
82
  end
83
83
  end
84
84
 
@@ -87,22 +87,22 @@ describe Plugin do
87
87
 
88
88
  context "installed" do
89
89
  let(:installed) { true }
90
- it { plugin.should_not_receive(:fluent_gem) }
90
+ it { FluentGem.should_not_receive(:install) }
91
91
  end
92
92
 
93
93
  context "not installed" do
94
94
  let(:installed) { false }
95
- it { plugin.should_not_receive(:fluent_gem) }
95
+ it { FluentGem.should_not_receive(:installed) }
96
96
  end
97
97
  end
98
98
  end
99
99
 
100
100
  context "system command error" do
101
- before { plugin.should_receive(:system).at_least(1).and_return(false) }
101
+ before { FluentGem.should_receive(:system).at_least(1).and_return(false) }
102
102
  subject { expect { plugin.install! } }
103
103
 
104
104
  it "raise GemError" do
105
- subject.to raise_error(Plugin::GemError)
105
+ subject.to raise_error(FluentGem::GemError)
106
106
  end
107
107
 
108
108
  it "error message contains gem name" do
@@ -139,10 +139,10 @@ describe Plugin do
139
139
  before do
140
140
  # NOTE: not `plugin.stub` because upgrade! creates new Plugin instance internally
141
141
  installed_plugin.stub(:installed?).and_return(true)
142
- Plugin.any_instance.stub(:fluent_gem).and_return(true)
142
+ FluentGem.stub(:run).and_return(true)
143
143
 
144
144
  installed_plugin.should_receive(:uninstall!)
145
- Plugin.any_instance.should_receive(:install!)
145
+ FluentGem.should_receive(:install)
146
146
  end
147
147
 
148
148
  it { installed_plugin.upgrade!(target_version) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Nakagawa
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-13 00:00:00.000000000 Z
12
+ date: 2014-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -323,6 +323,7 @@ files:
323
323
  - app/mailers/.keep
324
324
  - app/models/.keep
325
325
  - app/models/concerns/.keep
326
+ - app/models/fluent_gem.rb
326
327
  - app/models/fluentd.rb
327
328
  - app/models/fluentd/agent.rb
328
329
  - app/models/fluentd/agent/common.rb
@@ -473,6 +474,7 @@ files:
473
474
  - spec/grok_converter_spec.rb
474
475
  - spec/lib/file_reverse_reader_spec.rb
475
476
  - spec/lib/fluentd-ui_spec.rb
477
+ - spec/models/fluent_gem_spec.rb
476
478
  - spec/models/fluentd/agent_spec.rb
477
479
  - spec/models/fluentd/setting/common_spec.rb
478
480
  - spec/models/fluentd/setting/in_syslog_spec.rb
@@ -638,6 +640,7 @@ test_files:
638
640
  - spec/grok_converter_spec.rb
639
641
  - spec/lib/file_reverse_reader_spec.rb
640
642
  - spec/lib/fluentd-ui_spec.rb
643
+ - spec/models/fluent_gem_spec.rb
641
644
  - spec/models/fluentd/agent_spec.rb
642
645
  - spec/models/fluentd/setting/common_spec.rb
643
646
  - spec/models/fluentd/setting/in_syslog_spec.rb