kpartx: print "loop deleted" to stdout, not stderr
PATCH 1/1 kpartx: print "loop deleted" to stdout, not stderr
Commit fa643f5d2590028a59c671b81ab41383806fd258 moved some code around and changed the print for loop deleted from stdout to stderr - but this is not an error message, and also printed to stdout in another place, so let's just use printf() again here.
--- kpartx/kpartx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kpartx/kpartx.c +1 -1
@@ -399,7 +399,7 @@ main(int argc, char **argv){ loopdev); r =1 ; }else -fprintf (stderr,"loop deleted : %s\n" , loopdev); +printf ("loop deleted : %s\n" , loopdev); } goto end; }
Signature · 1 line
2.15.1
Quoted 24 lines · Julian Andres Klode
Commit
fa643f5d2590028a59c671b81ab41383806fd258moved some code around and changed the print for loop deleted from stdout to stderr - but this is not an error message, and also printed to stdout in another place, so let's just useprintf()again here.Signed-off-by Julian Andres Klode <[email protected]>--- kpartx/kpartx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kpartx/kpartx.c +1
-1@@ -399,7 +399,7 @@ main(int argc, char **argv){ loopdev); r =1 ; }else - fprintf(stderr, "loop deleted : %s\n", loopdev); +printf ("loop deleted : %s\n" , loopdev); }
kpartx/kpartx.c main(int argc, char **argv){ · line 405
Quoted 2 lines
kpartx/kpartx.c +0
-0goto end; }
Hm. This is a log message, and as such, should go to stderr. kpartx, as a program primarily intended to run in udev rules, shouldn't print log messages to stdout unless we have compelling reasons for it to do so.
I'm aware that this isn't done consistently in kpartx at the moment, but IMO your patch goes in the wrong direction.
Regards
Martin
Signature · 8 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107 SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
Quoted 33 lines · Martin Wilck
Quoted 24 lines · Julian Andres Klode
Commit
fa643f5d2590028a59c671b81ab41383806fd258moved some code around and changed the print for loop deleted from stdout to stderr - but this is not an error message, and also printed to stdout in another place, so let's just useprintf()again here.Signed-off-by Julian Andres Klode <[email protected]>--- kpartx/kpartx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kpartx/kpartx.c +1
-1@@ -399,7 +399,7 @@ main(int argc, char **argv){ loopdev); r =1 ; }else - fprintf(stderr, "loop deleted : %s\n", loopdev); +printf ("loop deleted : %s\n" , loopdev); }kpartx/kpartx.c main(int argc, char **argv){ · line 405
Quoted 2 lines
kpartx/kpartx.c +0
-0goto end; }Hm. This is a log message, and as such, should go to stderr. kpartx, as a program primarily intended to run in udev rules, shouldn't print log messages to stdout unless we have compelling reasons for it to do so.
Quoted 2 lines
I'm aware that this isn't done consistently in kpartx at the moment, but IMO your patch goes in the wrong direction.
It seems very consistent for me: stderr is used for errors and warnings, and printf() for the rest. There are two exceptions: This one, and
kpartx/devmapper.c: fprintf(stderr, "found map %s for uuid %s, renaming to %s\n",
But that one really is what I'd consider a log message. Stuff like "del devmap" and "loop deleted" seem somehow different - you tell it to delete a mapping, and to be verbose, and then it should tell you what it deleted, on stdout. Maybe people are parsing this, who knows? It definitely broke our tests because unexpected stderr output appeared.
Signature · 2 lines
debian developer - deb.li/jak | jak-linux.org - free software dev ubuntu core developer i speak de, en
Quoted 40 lines · Julian Andres Klode
Quoted 33 lines · Martin Wilck
Quoted 24 lines · Julian Andres Klode
Commit
fa643f5d2590028a59c671b81ab41383806fd258moved some code around and changed the print for loop deleted from stdout to stderr - but this is not an error message, and also printed to stdout in another place, so let's just useprintf()again here.Signed-off-by Julian Andres Klode <[email protected]>--- kpartx/kpartx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kpartx/kpartx.c +1
-1@@ -399,7 +399,7 @@ main(int argc, char **argv){ loopdev); r =1 ; }else - fprintf(stderr, "loop deleted : %s\n", loopdev); +printf ("loop deleted : %s\n" , loopdev); }kpartx/kpartx.c main(int argc, char **argv){ · line 405
Quoted 2 lines
kpartx/kpartx.c +0
-0goto end; }Hm. This is a log message, and as such, should go to stderr. kpartx, as a program primarily intended to run in udev rules, shouldn't print log messages to stdout unless we have compelling reasons for it to do so.
Quoted 2 lines
I'm aware that this isn't done consistently in kpartx at the moment, but IMO your patch goes in the wrong direction.
It seems very consistent for me: stderr is used for errors and warnings, and
printf()for the rest. There are two exceptions: This one, and
Quoted 9 lines
kpartx/devmapper.c: fprintf(stderr, "found map %s for uuid %s, renaming to %s\n",But that one really is what I'd consider a log message. Stuff like "del devmap" and "loop deleted" seem somehow different - you tell it to delete a mapping, and to be verbose, and then it should tell you what it deleted, on stdout. Maybe people are parsing this, who knows? It definitely broke our tests because unexpected stderr output appeared.
In fact, if you look at the bug mentioned in the previous patch,
https://bugs.launchpad.net/ubuntu/+source/multipath-tools/+bug/1747044
you'll see that we explicitly check the output of kpartx -v -d for "loop deleted" apparently because kpartx was (or is?) flaky and returned an error even when it successfully deleted the loop device, as seen in
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860894
It seems reasonable that Debian and Ubuntu are not the only ones relying on that output.
Signature · 2 lines
debian developer - deb.li/jak | jak-linux.org - free software dev ubuntu core developer i speak de, en
Quoted 64 lines · Julian Andres Klode
Quoted 49 lines · Julian Andres Klode
Quoted 37 lines · Martin Wilck
Quoted 24 lines · Julian Andres Klode
Commit
fa643f5d2590028a59c671b81ab41383806fd258moved some code around and changed the print for loop deleted from stdout to stderr - but this is not an error message, and also printed to stdout in another place, so let's just useprintf()again here.Signed-off-by Julian Andres Klode <[email protected]>--- kpartx/kpartx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kpartx/kpartx.c +0
-1@@ -399,7 +399,7 @@ main(int argc, char **argv){ loopdev); r =1 ; }else - fprintf(stderr, "loop deleted:
%s\n", loopdev);kpartx/kpartx.c +1
-0+ printf("loop deleted : %s\n",loopdev);
kpartx/kpartx.c main(int argc, char **argv){ · line 405
Quoted 3 lines
kpartx/kpartx.c +0
-0} goto end; }Hm. This is a log message, and as such, should go to stderr. kpartx, as
a program primarily intended to run in udev rules, shouldn't print log
messages to stdout unless we have compelling reasons for it to do so.Quoted 3 lines
I'm aware that this isn't done consistently in kpartx at the moment,
but IMO your patch goes in the wrong direction.It seems very consistent for me: stderr is used for errors and warnings,
andprintf()for the rest. There are two exceptions: This one, and
kpartx/devmapper.c: fprintf(stderr, "found map %s for
uuid %s, renaming to %s\n",Quoted 8 lines
But that one really is what I'd consider a log message. Stuff like "del devmap" and "loop deleted" seem somehow different - you tell it to delete a mapping, and to be verbose, and then it should tell you what it deleted, on stdout. Maybe people are parsing this, who knows? It definitely broke our tests because unexpected stderr output
appeared.In fact, if you look at the bug mentioned in the previous patch,
https://bugs.launchpad.net/ubuntu/+source/multipath-tools/+bug/174704
4
Quoted 7 lines
you'll see that we explicitly check the output of kpartx -v -d for "loop deleted" apparently because kpartx was (or is?) flaky and returned
an error even when it successfully deleted the loop device, as seen in
That's a very different issue. Without digging much deeper into it, I'd like to repeat that kpartx' job is to delete _partition mappings_, not loop devices. The ability to delete the loop device as well ist just a convenience, saving users another call to "losetup -d". So it's not necessarily "flaky" for kpartx to return a non-zero error code if errors were encountered during it's core task (removing the partitions), even if removing the loop device was successful later. (*)
Quoted 3 lines
It seems reasonable that Debian and Ubuntu are not the only ones relying on that output.
The fact that they rely on parsing this this message on stdout is sufficient justification for me to keep it there, even though I'm not buying your "errors to stderr, the rest to stdout" argument in general.
Please submit again, adding a comment that Ubuntu/Debian rely on the presence of this output, lest it be changed again in the future.
Regards
Martin
(*) One might argue whether the loop device shouldn't have been deleted in that error case, but that's yet another issue.
Signature · 8 lines
Dr. Martin Wilck <[email protected]>, Tel. +49 (0)911 74053 2107 SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel