From nobody@FreeBSD.org  Sat Dec  5 11:12:38 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D10E11065672
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  5 Dec 2009 11:12:38 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 722498FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  5 Dec 2009 11:12:38 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nB5BCcb2003286
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 5 Dec 2009 11:12:38 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id nB5BCbAj003284;
	Sat, 5 Dec 2009 11:12:37 GMT
	(envelope-from nobody)
Message-Id: <200912051112.nB5BCbAj003284@www.freebsd.org>
Date: Sat, 5 Dec 2009 11:12:37 GMT
From: Anselm Strauss <amsibamsi@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: freebsd-snapshot does not report all errors
X-Send-Pr-Version: www-3.1
X-GNATS-Notify: gtodd@bellanet.org

>Number:         141188
>Category:       ports
>Synopsis:       sysutils/freebsd-snapshot does not report all errors
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Dec 05 11:20:01 UTC 2009
>Closed-Date:    Mon Feb 08 00:55:18 UTC 2010
>Last-Modified:  Mon Feb 08 00:55:18 UTC 2010
>Originator:     Anselm Strauss
>Release:        8.0
>Organization:
-
>Environment:
FreeBSD hulk.l.ttyv0.net 8.0-RELEASE FreeBSD 8.0-RELEASE #1: Fri Dec  4 00:20:25 CET 2009     root@hulk.l.ttyv0.net:/usr/obj/usr/src/sys/CUSTOM  amd64

>Description:
Port: freebsd-snapshot

The commands snapshot and periodic-snapshot both return 0 and very few to no error messages in some cases when there was clearly an error and the requested operation did not succeed.
>How-To-Repeat:
Do not have a concrete case, just looked at the code ...
>Fix:
Insert some checks of return codes and log messages.

One case I did not catch: When zfs_enable is set to NO but zfs file systems were configured by hand. "snapshot make" will run silently even though no snapshot was made.

Patch attached with submission follows:

*** snapshot.orig       Fri Dec  4 19:24:06 2009
--- snapshot    Sat Dec  5 10:54:53 2009
***************
*** 311,316 ****
--- 312,321 ----
  
              #   create new snapshot
              system zfs snapshot "$fs_name@$fs_tag.$fs_gen"
+             if [ $? -ne 0 ]; then
+                 echo "snapshot:ERROR: making ZFS snapshot failed" 1>&2
+                 exit 1
+             fi
          fi
      else
          #   UFS filesystem 
***************
*** 353,358 ****
--- 358,367 ----
  
              #   create new snapshot
              system mount -u -o snapshot $fs_dir/.snap/$fs_tag.$fs_gen $fs_dir
+             if [ $? -ne 0 ]; then
+                 echo "snapshot:ERROR: making UFS snapshot failed" 1>&2
+                 exit 1
+             fi
          fi
      fi
  
***************
*** 537,542 ****
--- 546,555 ----
      if [ ".`echo $src | fgrep /.zfs/snapshot/`" != . ]; then
          #   unmount implicitly mounted ZFS snapshot directory
          umount $src
+         if [ $? -ne 0 ]; then
+             echo "snapshot:ERROR: unmounting snapshot failed" 1>&2
+             exit 1
+         fi
      fi
  
      return 0

*** periodic-snapshot.orig      Fri Dec  4 20:13:06 2009
--- periodic-snapshot   Sat Dec  5 10:45:35 2009
***************
*** 120,125 ****
--- 120,130 ----
                  lockf -s -t 0 $fs/.snapshot.lock \
                  snapshot make -g$when $fs:$time_tag.0
                  time_end=`date '+%s'`
+                 if [ "$?" -ne 0 ]; then
+                     logger -p daemon.error \
+                         "snapshot: making snapshot on $fs failed"
+                     exit 1
+                 fi
                  duration=$((($time_end - $time_start) / 60))
                  logger -p daemon.notice \
                      "snapshot: $time_tag.0 snapshot on filesystem $fs made (duration: $duration min)"


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Sun Dec 6 20:57:46 UTC 2009 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141188 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: gtodd@bellanet.org
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/141188: sysutils/freebsd-snapshot does not report all errors
Date: Sun, 6 Dec 2009 20:57:44 UT

 Maintainer of sysutils/freebsd-snapshot,
 
 Please note that PR ports/141188 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/141188
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org

From: Graham Todd <gtodd@bellanet.org>
To: bug-followup@FreeBSD.org
Cc: "Ralf S. Engelschall" <rse@FreeBSD.org>
Subject: Re: ports/141188: sysutils/freebsd-snapshot does not report all errors
Date: Mon, 07 Dec 2009 10:08:44 -0500

 I approve of these enhancements.
 
 They should also find their way upstream.
 
 Cheers,
 
 Edwin Groothuis wrote:
 > Maintainer of sysutils/freebsd-snapshot,
 > 
 > Please note that PR ports/141188 has just been submitted.
 > 
 > If it contains a patch for an upgrade, an enhancement or a bug fix
 > you agree on, reply to this email stating that you approve the patch
 > and a committer will take care of it.
 > 
 > The full text of the PR can be found at:
 >     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/141188
 > 
 
State-Changed-From-To: feedback->open 
State-Changed-By: linimon 
State-Changed-When: Mon Dec 7 17:48:33 UTC 2009 
State-Changed-Why:  
Maintainer approved. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141188 

From: "Ralf S. Engelschall" <rse@FreeBSD.org>
To: Graham Todd <gtodd@bellanet.org>
Cc: bug-followup@FreeBSD.org, "Ralf S. Engelschall" <rse@FreeBSD.org>
Subject: Re: ports/141188: sysutils/freebsd-snapshot does not report all
	errors
Date: Tue, 8 Dec 2009 21:18:26 +0100

 On Mon, Dec 07, 2009, Graham Todd wrote:
 
 > I approve of these enhancements.
 >
 > They should also find their way upstream.
 >
 > Cheers,
 >
 > Edwin Groothuis wrote:
 > > Maintainer of sysutils/freebsd-snapshot,
 > >
 > > Please note that PR ports/141188 has just been submitted.
 > >
 > > If it contains a patch for an upgrade, an enhancement or a bug fix
 > > you agree on, reply to this email stating that you approve the patch
 > > and a committer will take care of it.
 > >
 > > The full text of the PR can be found at:
 > >     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/141188
 
 Attention: the patch has a bug in its last chunk: it checks for $? after
 the "time_end=`date '+%s'`" command and this way does not check the
 possible failure of "snapshot make -g$when $fs:$time_tag.0" but of the
 "date" command.
 
 I've fixed this bug and have taken over the other changes into the
 latest version of my snapshot utilities. Find the new version on
 http://people.freebsd.org/~rse/dist/
 
 --
 rse@FreeBSD.org                        Ralf S. Engelschall
 FreeBSD.org/~rse                       rse@engelschall.com
 FreeBSD committer                      www.engelschall.com
 

From: Graham Todd <gtodd@bellanet.org>
To: "Ralf S. Engelschall" <rse@FreeBSD.org>, bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/141188: sysutils/freebsd-snapshot does not report all errors
Date: Sun, 13 Dec 2009 09:35:27 -0500

 Ralf S. Engelschall wrote:
 >> Edwin Groothuis wrote:
 >>> Maintainer of sysutils/freebsd-snapshot,
 >>>
 >>> Please note that PR ports/141188 has just been submitted.
 >>>
 >>> If it contains a patch for an upgrade, an enhancement or a bug fix
 >>> you agree on, reply to this email stating that you approve the patch
 >>> and a committer will take care of it.
 >>>
 >>> The full text of the PR can be found at:
 >>>     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/141188
 > 
 > Attention: the patch has a bug in its last chunk: it checks for $? after
 > the "time_end=`date '+%s'`" command and this way does not check the
 > possible failure of "snapshot make -g$when $fs:$time_tag.0" but of the
 > "date" command.
 > 
 > I've fixed this bug and have taken over the other changes into the
 > latest version of my snapshot utilities. Find the new version on
 > http://people.freebsd.org/~rse/dist/
 
 Thanks! With the latest patch to the port everything has been fixed upstream.

From: Graham Todd <gtodd@bellanet.org>
To: bug-followup@FreeBSD.org, amsibamsi@gmail.com
Cc:  
Subject: Re: ports/141188: sysutils/freebsd-snapshot does not report all errors
Date: Sun, 07 Feb 2010 19:45:46 -0500

 This PR can be closed
 
State-Changed-From-To: open->closed 
State-Changed-By: pgollucci 
State-Changed-When: Mon Feb 8 00:55:18 UTC 2010 
State-Changed-Why:  
submitter requested close 

http://www.freebsd.org/cgi/query-pr.cgi?pr=141188 
>Unformatted:
