Skip to content

get_osd_id: silence errors#107

Open
bmwiedemann wants to merge 1 commit into
crowbar:masterfrom
bmwiedemann:osdid
Open

get_osd_id: silence errors#107
bmwiedemann wants to merge 1 commit into
crowbar:masterfrom
bmwiedemann:osdid

Conversation

@bmwiedemann

Copy link
Copy Markdown
Member

https://bugzilla.suse.com/show_bug.cgi?id=1073237#c4 & 5

When creating OSDs, it waits for for get_osd_id to return a value
which caused ugly error messages in the logs:
cat: /var/lib/ceph/osd/ceph-7/var/lib/ceph/tmp/mnt.lAtztf/whoami: No such file or directory

https://bugzilla.suse.com/show_bug.cgi?id=1073237#c4 & 5

When creating OSDs, it waits for for get_osd_id to return a value
which caused ugly error messages in the logs:
cat: /var/lib/ceph/osd/ceph-7/var/lib/ceph/tmp/mnt.lAtztf/whoami: No such file or directory
def get_osd_id(device)
osd_path = %x[mount | grep #{device} | awk '{print $3}'].tr("\n","")
osd_id = %x[cat #{osd_path}/whoami].tr("\n","")
osd_id = %x[cat #{osd_path}/whoami 2>/dev/null].tr("\n","")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/CommandLiteral: Use backticks around command string. (https://github.com/bbatsov/ruby-style-guide#percent-x)
Style/PercentLiteralDelimiters: %x-literals should be delimited by ( and ). (https://github.com/bbatsov/ruby-style-guide#percent-literal-braces)
Layout/SpaceAfterComma: Space missing after comma. (https://github.com/bbatsov/ruby-style-guide#spaces-operators)

@jsuchome

jsuchome commented Feb 7, 2018

Copy link
Copy Markdown
Member

Shouldn't we add a check for that file presence?

@bmwiedemann

Copy link
Copy Markdown
Member Author

what would be the advantage? cat already checks for presence...
or do you mean a separate checking function?

@jsuchome

jsuchome commented Feb 7, 2018

Copy link
Copy Markdown
Member

Just thought it might be nicer and more readable, but probably is not really needed

@nicolasbock nicolasbock left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's definitely compact @bmwiedemann 😉. I still don't quite understand how stderr ends up in the log file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants