Skip to content

Add support for raid0 devices in mdadm_linux collector.#253

Merged
matthiasr merged 2 commits intomasterfrom
superq/md_raid0
Jun 14, 2016
Merged

Add support for raid0 devices in mdadm_linux collector.#253
matthiasr merged 2 commits intomasterfrom
superq/md_raid0

Conversation

@SuperQ
Copy link
Copy Markdown
Member

@SuperQ SuperQ commented Jun 6, 2016

Fix for #219

@SuperQ SuperQ force-pushed the superq/md_raid0 branch 2 times, most recently from dc3d7f8 to 3711be7 Compare June 6, 2016 21:20
@SuperQ
Copy link
Copy Markdown
Member Author

SuperQ commented Jun 6, 2016

Hmmm, I think I need to make an example of failed raid0.

@SuperQ SuperQ changed the title Add support for raid0 devices in mdadm_linux collector. [WIP] Add support for raid0 devices in mdadm_linux collector. Jun 6, 2016
@SuperQ SuperQ force-pushed the superq/md_raid0 branch 3 times, most recently from 2c950e1 to 60e134f Compare June 6, 2016 21:31
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

End comments with periods everywhere.

@juliusv
Copy link
Copy Markdown
Member

juliusv commented Jun 6, 2016

Looks good in general, would be good to get a second opinion from someone with mdadm / RAID experience, like probably @brian-brazil.

@SuperQ SuperQ force-pushed the superq/md_raid0 branch 3 times, most recently from 493b1b6 to 5516297 Compare June 6, 2016 21:52
@SuperQ SuperQ changed the title [WIP] Add support for raid0 devices in mdadm_linux collector. Add support for raid0 devices in mdadm_linux collector. Jun 6, 2016
@SuperQ
Copy link
Copy Markdown
Member Author

SuperQ commented Jun 6, 2016

Ok, fixed my go newbie bugs, and end-to-end tests. 💚

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the check above we only ensure that the line has at least 3 parts. While I assume a line with less than 4 parts to be invalid, it's possible to run into an out-of-bound panic with this change, no?

Bonus points for adding a test for such invalid short lines.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ahh, yea, mainLine should always have atleast 4 parts anyway. I'll update the test.

@SuperQ SuperQ force-pushed the superq/md_raid0 branch 2 times, most recently from 9ebcf4c to ce739bf Compare June 7, 2016 06:26
if len(mainLine) < 4 {
return mdStates, fmt.Errorf("error parsing mdline: %s", l)
}
currentMD = mainLine[0] // name of md-device
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.

Comments here should be full sentences.

@brian-brazil
Copy link
Copy Markdown
Contributor

👍

// +1 to make it more obvious that the whole string containing the info is also returned as matches[0].
if len(matches) < 1+1 {
return 0, fmt.Errorf("too few matches found in statusline: %s", statusline)
} else {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reduce the indentation level in go if possible. This else branch is not necessary.

@SuperQ SuperQ force-pushed the superq/md_raid0 branch from ce739bf to 3bea583 Compare June 11, 2016 06:26
@SuperQ SuperQ force-pushed the superq/md_raid0 branch from 3bea583 to 8c809cd Compare June 11, 2016 06:54
@SuperQ
Copy link
Copy Markdown
Member Author

SuperQ commented Jun 11, 2016

Ok, addressed all comments.

@matthiasr
Copy link
Copy Markdown
Contributor

👍

@matthiasr matthiasr merged commit 344fe2c into master Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants