Author: jfthomps
Date: Thu Feb 23 21:10:15 2012
New Revision: 1292957

URL: http://svn.apache.org/viewvc?rev=1292957&view=rev
Log:
VCL-44
getPossibleRecentFailures in isAvailable can end up removing only available 
machine

modified isAvailable - if calling getPossibleRecentFailures results in 
decreasing the number of computers to look at, save the original set, then if 
allocComputer doesn't allocate anything, try calling it again with the original 
set of computers

Modified:
    incubator/vcl/trunk/web/.ht-inc/utils.php

Modified: incubator/vcl/trunk/web/.ht-inc/utils.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/utils.php?rev=1292957&r1=1292956&r2=1292957&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/utils.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/utils.php Thu Feb 23 21:10:15 2012
@@ -2250,12 +2250,6 @@ function getKey($data) {
 ///
 
////////////////////////////////////////////////////////////////////////////////
 function encryptData($data) {
-       /*global $mcryptkey, $mcryptiv;
-       if(! $data)
-               return false;
-
-       $cryptdata = mcrypt_encrypt(MCRYPT_BLOWFISH, $mcryptkey, $data, 
MCRYPT_MODE_CBC, $mcryptiv);
-       return trim(base64_encode($cryptdata));*/
        global $cryptkey;
        if(! $data)
                return false;
@@ -2277,13 +2271,6 @@ function encryptData($data) {
 ///
 
////////////////////////////////////////////////////////////////////////////////
 function decryptData($data) {
-       /*global $mcryptkey, $mcryptiv;
-       if(! $data)
-               return false;
-
-       $cryptdata = base64_decode($data);
-       $decryptdata = mcrypt_decrypt(MCRYPT_BLOWFISH, $mcryptkey, $cryptdata, 
MCRYPT_MODE_CBC, $mcryptiv);
-       return trim($decryptdata);*/
        global $cryptkey;
        if(! $data)
                return false;
@@ -4000,28 +3987,39 @@ function isAvailable($images, $imageid, 
                # remove any recently reserved computers that could have been an
                #   undetected failure
                $failedids = getPossibleRecentFailures($userid, $imageid);
+               $shortened = 0;
                if(! empty($failedids)) {
+                       $origcomputerids = $computerids;
+                       $origcurrentids = $currentids;
+                       $origblockids = $blockids;
                        if(! empty($computerids)) {
                                $testids = array_diff($computerids, $failedids);
                                if(! empty($testids)) {
+                                       $shortened = 1;
                                        $computerids = $testids;
                                        $currentids = array_diff($currentids, 
$failedids);
                                }
                        }
                        if(! empty($blockids)) {
                                $testids = array_diff($blockids, $failedids);
-                               if(! empty($testids))
+                               if(! empty($testids)) {
+                                       $shortened = 1;
                                        $blockids = $testids;
+                               }
                        }
                }
 
                # allocate a computer
                $comparr = allocComputer($blockids, $currentids, $computerids,
                                         $startstamp, $nowfuture);
+               if(empty($comparr) && $shortened)
+                       $comparr = allocComputer($origblockids, $origcurrentids,
+                                                $origcomputerids, $startstamp, 
$nowfuture);
                if(empty($comparr)) {
                        semUnlock();
                        return 0;
                }
+
                $requestInfo["computers"][$key] = $comparr['compid'];
                $requestInfo["mgmtnodes"][$key] = $comparr['mgmtid'];
                $requestInfo["loaded"][$key] = $comparr['loaded'];


Reply via email to