[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 2/6] cr-ensure-disk-space: -F option



May be repeated (cuddled with itself) or given a number.  Forces
deletion, even if there is enough space.  Normally clean up one less
flight than specified, since cr-ensure-disk-space reruns its check
after acquiring the lock.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 cr-ensure-disk-space | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/cr-ensure-disk-space b/cr-ensure-disk-space
index bfdbcc5..c65423a 100755
--- a/cr-ensure-disk-space
+++ b/cr-ensure-disk-space
@@ -26,6 +26,7 @@ use Osstest::Management qw(:logs);
 use Fcntl qw(:flock);
 
 our $dryrun= 0;
+our $force;
 
 open DEBUG, ">/dev/null" or die $!;
 
@@ -34,6 +35,10 @@ while (@ARGV && $ARGV[0] =~ m/^\-/) {
     last if $_ eq '--';
     if (m/^-n$/) {
         $dryrun= 1;
+    } elsif (m/^-(F+)$/) {
+        $force += length $1;
+    } elsif (m/^-F(\d+)$/) {
+        $force += $1;
     } elsif (m/^-D$/) {
         open DEBUG, ">&2" or die $!;
     } else {
@@ -58,6 +63,11 @@ sub check_space () {
     $!=0; $?=0; close P or die "$! $?";
     my $space= $1;
     printf "space: %8d, wanted: %8d ", $space, logcfg('MinSpaceMby');
+    if ($force) {
+       $force--;
+       printf "FORCING ";
+       return 0;
+    }
     return $space >= logcfg('MinSpaceMby');
 }
 
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.