containers / docker-lvm-plugin

Docker volume plugin for LVM volumes
GNU Lesser General Public License v3.0
155 stars 64 forks source link

grep exit code 1 is not an error. It just means, there was no matching pattern found. #12

Closed shishir-a412ed closed 8 years ago

shishir-a412ed commented 8 years ago

Signed-off-by: Shishir Mahajan shishir.mahajan@redhat.com

shishir-a412ed commented 8 years ago

Let's say I have a regular volume foobar and I call isThinlyProvisioned() function to determine if foobar is a regular or thin volume.

IsThinlyProvisioned() will do a lvdisplay /dev/volume_group_one/foobar | grep "LV Pool" where volume_group_one is my volume group name. Since foobar is a regular volume, grep will return no output and an exit code 1.

http://www.gnu.org/software/grep/manual/html_node/Exit-Status.html According to GNU Grep:

Exit code 0: Match found Exit code 1: No match found Exit code 2: Error

With Exit code 1, our golang code will treat this as an error and https://github.com/projectatomic/docker-lvm-plugin/blob/master/driver.go#L320 will return an error. We need to ignore this error, since this is not really an error. It is just a pattern match not found.

More Explanation here: https://github.com/projectatomic/docker-lvm-plugin/pull/9#issuecomment-235129127

Shishir

shishir-a412ed commented 8 years ago

@rhatdan @runcom Please review.

shishir-a412ed commented 8 years ago

@runcom PTAL.

Shishir

runcom commented 8 years ago

Seems ok to me Shishir