-
Notifications
You must be signed in to change notification settings - Fork 209
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
Added chef-server-ctl version functionality #1485
Conversation
|
||
# detect if running as a habitat service | ||
if File.exist?('/hab/svc/chef-server-ctl/PID') | ||
#code for populating version through /version endpoint |
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.
left over comment artifact perhaps?
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.
good catch
# detect if running as a habitat service | ||
if File.exist?('/hab/svc/chef-server-ctl/PID') | ||
#code for populating version through /version endpoint | ||
puts "running in hab" |
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.
nit: I don't really think this is necessary - seems like a left over debugging statement perhaps?
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.
good catch
if File.exist?('/hab/svc/chef-server-ctl/PID') | ||
#code for populating version through /version endpoint | ||
puts "running in hab" | ||
ident_file = File.read('../IDENT') |
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.
nit: I always like to use the File.expand_path('../../IDENT', __FILE__)
pattern to ensure a more deterministic file path, otherwise the relative path thing can bite sometimes depending on the situation.
end | ||
|
||
puts version | ||
|
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.
nit: perhaps put an error handler after line 29 to handle any Errno::ENOENT
?
rescue Errno::ENOENT => ex
puts "Error determining version! #{ex.message}"
The rescue
would line up with the add_command_under_category
and end
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.
adding error checking, I'm going to use e as the var and log instead of puts, to match how errors are handled in other parts of chef-server-ctl. For example rotate_credentials.rb
Having this simple yet important feature would be nice! |
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'm very much in favor of this. Minor fix suggestion above, but otherwise +1
ident_file = File.read('../IDENT') | ||
version = "chef-server #{ident_file.split('/')[2]}" | ||
else | ||
version = File.readlines('/opt/opscode/version-manifest.txt')[0] |
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 might do JSON.parse(File.read('/opt/opscode/version-manifest.json'))['build_version']
instead. I suspect the json file might be more future proof that relying on the first line of the txt file.
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 was on the fence as to which file to use, I'll switch over to the json.
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.
👍 Good addition.
puts version | ||
rescue Errno::ENOENT => e | ||
puts "Error determining version!" | ||
log(e.message, :error) |
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.
[minor note] I think this depends on the glob-order loading of ctl-commands to work. The log command in omnibus-ctl takes 1 argument; however that function is overwritten by the definitions in these two commands:
omnibus/files/private-chef-ctl-commands/backup.rb
omnibus/files/private-chef-ctl-commands/rotate_credentials.rb
However, I don't think we should block a useful command on cleaning that up.
Once you have all the changes, please squash/rebase and make sure you have signed off on the commit (git commit -s --amend) will fixup missing signoffs. |
fa44e11
to
53d2d3d
Compare
Signed-off-by: Thomas Cate <[email protected]>
53d2d3d
to
eb063c0
Compare
Matches the one in Chef Server[1] [1] chef/chef-server#1485 Signed-off-by: Robb Kidd <[email protected]>
Matches the one in Chef Server[1] [1] chef/chef-server#1485 Signed-off-by: Robb Kidd <[email protected]>
Matches the one in Chef Server[1] [1] chef/chef-server#1485 Signed-off-by: Robb Kidd <[email protected]>
Added basic functionality for chef-server-ctl to report the version from the version-manifest.txt file. If it detects it's running in Habitat it will derive the version from the IDENT file in the hab package.
Signed-off-by: Thomas Cate [email protected]