-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #13013 - Adds API to display pulp dir status #3
Conversation
@@ -2,5 +2,5 @@ source 'https://rubygems.org' | |||
gemspec | |||
|
|||
group :development do | |||
gem 'smart_proxy', :git => "https://github.com/theforeman/smart-proxy" | |||
gem 'smart_proxy', :git => 'https://github.com/theforeman/smart-proxy', :branch => 'develop' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, not. Since smart-proxy now have only develop branch (master was deleted), bundle
will fail when trying to run. So need to point it to develop branch (which also makes sense in development).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@witlessbird your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be the standard for group development.
see:
https://github.com/theforeman/smart_proxy_remote_execution_ssh/blob/master/Gemfile#L12
https://github.com/theforeman/smart_proxy_discovery/blob/develop/Gemfile#L8
https://github.com/theforeman/smart_proxy_openscap/blob/master/Gemfile#L7
https://github.com/theforeman/smart_proxy_dns_plugin_template/blob/master/Gemfile#L5
https://github.com/theforeman/smart_proxy_chef/blob/master/Gemfile#L7
to name a few
module PulpProxy | ||
class PulpDisk | ||
def initialize(path = PulpProxy::Plugin.settings.pulp_dir) | ||
@path = path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add the properties to the class? e.g.
attr_accessor :free, :total, :block_device, :path
@@ -0,0 +1,25 @@ | |||
module PulpProxy | |||
class DiskUsage | |||
attr_accessor :free, :total, :block_device, :path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe consider accepting a unit argument, so you can decide if its bytes, kilo, mb, gb or human
Changed a little bit. let me know what u think |
attr_reader :path, :stat, :size | ||
|
||
def initialize(path = PulpProxy::Plugin.settings.pulp_dir, size = SIZE[:megabyte]) | ||
@path = path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would pass opts = {} instead of hard coding the size as the second argument, e.g.
DiskUsage.new(:path => '..', :size_format ..)
@@ -25,6 +25,7 @@ Gem::Specification.new do |gem| | |||
gem.add_development_dependency('webmock', '~> 1') | |||
gem.add_development_dependency('rack-test', '~> 0') | |||
gem.add_development_dependency('rake', '~> 10') | |||
gem.add_dependency('sys-filesystem', '~> 1.1') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh are you sure? :-) You need to create packages for Red Hat and Debian... I was not insisting on this at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 df is simple enough instead of calling out to an external ffi gem.
granted it will not work on windows, but since the scope of pulp is only redhat family I think I'm fine with it.
#:pulp_dir: /var/lib/pulp | ||
#:pulp_content: /var/lib/pulp/content | ||
#:mongodb: /var/lib/mongodb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The values are incorrect, you have renamed them.
b46deb2
to
1a519eb
Compare
Ok it works but convert to numbers what should be a number...
|
1a519eb
to
83716f8
Compare
Converted numbers to what should be a number. |
There are test failures. |
83716f8
to
6fa37ef
Compare
I have no push rights, @witlessbird RTM:
|
stdout.read.split("\n") | ||
end | ||
raw.each do |line| | ||
logger.debug "[#{command_path}] #{line}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you can just dump raw instead of loop over it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks better on a loop, but I can switch to a raw dump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dumping raw
6fa37ef
to
0204f1c
Compare
|
||
get '/status/disk_usage' do | ||
size = (params[:size] && DiskUsage::SIZE.keys.include?(params[:size].to_sym)) ? params[:size].to_sym : :kilobyte | ||
monitor_dirs = ::PulpProxy::Plugin.settings.to_h.delete_if { |key, _| key == :pulp_url || key == :enabled } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not great, as this will have to change the moment an additional setting is added; Why not explicitly list settings you are interested in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to select, with the keys I want
[test] |
0204f1c
to
c29abe3
Compare
Changed according to your comments. |
|
||
def test_returns_pulp_disk_on_200 | ||
PulpProxy::Plugin.load_test_settings(:pulp_dir => ::Sinatra::Application.settings.root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to define 'pulp_content_dir' and 'mongodb_dir' too, as otherwise default values are going to be used (and test will fail on my machine, as I don't have those dirs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
c29abe3
to
fc1fe6e
Compare
def get_stat | ||
raw = Open3::popen3({"LC_ALL" => "C"}, *command) do |stdin, stdout, stderr, thread| | ||
unless stderr.read.empty? | ||
error_line = stderr.read.join(" ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an issue here: I'm getting "undefined method `join' for "":String": #read returns a single string, readlines returns an array.
fc1fe6e
to
69eab7b
Compare
merged at 7b4d074. Thanks, @shlomizadok! |
Add spool dir instructions for git users
No description provided.