@@ -291,8 +291,8 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
291291
292292 SearchBuilder <IPAddressVO > AssignIpAddressSearch ;
293293 SearchBuilder <IPAddressVO > AssignIpAddressFromPodVlanSearch ;
294- private final Object _allocatedLock = new Object ();
295- private final Object _allocatingLock = new Object ();
294+ private static final Object allocatedLock = new Object ();
295+ private static final Object allocatingLock = new Object ();
296296
297297 static Boolean rulesContinueOnErrFlag = true ;
298298
@@ -834,7 +834,7 @@ public IPAddressVO doInTransaction(TransactionStatus status) throws Insufficient
834834 @ DB
835835 @ Override
836836 public void markPublicIpAsAllocated (final IPAddressVO addr ) {
837- synchronized (_allocatedLock ) {
837+ synchronized (allocatedLock ) {
838838 Transaction .execute (new TransactionCallbackNoReturn () {
839839 @ Override
840840 public void doInTransactionWithoutResult (TransactionStatus status ) {
@@ -857,6 +857,8 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
857857 _resourceLimitMgr .incrementResourceCount (owner .getId (), ResourceType .public_ip );
858858 }
859859 }
860+ } else {
861+ s_logger .error ("Failed to mark public IP as allocated with id=" + addr .getId () + " address=" + addr .getAddress ());
860862 }
861863 }
862864 }
@@ -867,14 +869,18 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
867869
868870 @ DB
869871 private void markPublicIpAsAllocating (final IPAddressVO addr ) {
870- synchronized (_allocatingLock ) {
872+ synchronized (allocatingLock ) {
871873 Transaction .execute (new TransactionCallbackNoReturn () {
872874 @ Override
873875 public void doInTransactionWithoutResult (TransactionStatus status ) {
874876
875877 if (_ipAddressDao .lockRow (addr .getId (), true ) != null ) {
876878 addr .setState (IpAddress .State .Allocating );
877- _ipAddressDao .update (addr .getId (), addr );
879+ if (!_ipAddressDao .update (addr .getId (), addr )) {
880+ s_logger .error ("Failed to update public IP as allocating with id=" + addr .getId () + " and address=" + addr .getAddress ());
881+ }
882+ } else {
883+ s_logger .error ("Failed to lock row to mark public IP as allocating with id=" + addr .getId () + " and address=" + addr .getAddress ());
878884 }
879885 }
880886 });
@@ -935,8 +941,8 @@ public PublicIp assignDedicateIpAddress(Account owner, final Long guestNtwkId, f
935941 displayIp = vpc .isDisplay ();
936942 }
937943
938- return fetchNewPublicIp (dcId , null , null , owner , VlanType .VirtualNetwork , guestNtwkId , isSourceNat , false , null , false , vpcId , displayIp );
939-
944+ ip = fetchNewPublicIp (dcId , null , null , owner , VlanType .VirtualNetwork , guestNtwkId , isSourceNat , true , null , false , vpcId , displayIp );
945+ return ip ;
940946 } finally {
941947 if (owner != null ) {
942948 if (s_logger .isDebugEnabled ()) {
0 commit comments