You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/11/03 09:26:01 UTC

[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #5658: remove VmWorkJob after adding a nic to a vm

DaanHoogland commented on a change in pull request #5658:
URL: https://github.com/apache/cloudstack/pull/5658#discussion_r741740943



##########
File path: engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java
##########
@@ -4026,25 +4027,39 @@ public NicProfile addVmToNetwork(final VirtualMachine vm, final Network network,
 
             final Object jobException = _jobMgr.unmarshallResultObject(outcome.getJob());
             if (jobException != null) {
-                if (jobException instanceof ResourceUnavailableException) {
-                    throw (ResourceUnavailableException)jobException;
-                } else if (jobException instanceof ConcurrentOperationException) {
-                    throw (ConcurrentOperationException)jobException;
-                } else if (jobException instanceof InsufficientCapacityException) {
-                    throw (InsufficientCapacityException)jobException;
-                } else if (jobException instanceof RuntimeException) {
-                    throw (RuntimeException)jobException;
-                } else if (jobException instanceof Throwable) {
-                    throw new RuntimeException("Unexpected exception", (Throwable)jobException);
-                } else if (jobException instanceof NicProfile) {
-                    return (NicProfile)jobException;
-                }
+                return getNewNicProfile(vm, network, requested, outcome, jobException);
             }
 
             throw new RuntimeException("Unexpected job execution result");
         }
     }
 
+    @NotNull
+    private NicProfile getNewNicProfile(VirtualMachine vm, Network network, NicProfile requested, Outcome<VirtualMachine> outcome, Object jobException) throws ResourceUnavailableException, InsufficientCapacityException {
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug(String.format("remove vmworkjob record %d for adding nic %s to net %s in vm %s",
+                    outcome.getJob().getId(),
+                    requested.getUuid(),
+                    network.getUuid(),
+                    vm.getUuid()));// remove vmworkjob record
+        }
+        _workJobDao.expunge(outcome.getJob().getId());
+
+        if (jobException instanceof ResourceUnavailableException) {
+            throw (ResourceUnavailableException) jobException;
+        } else if (jobException instanceof ConcurrentOperationException) {
+            throw (ConcurrentOperationException) jobException;
+        } else if (jobException instanceof InsufficientCapacityException) {
+            throw (InsufficientCapacityException) jobException;
+        } else if (jobException instanceof RuntimeException) {
+            throw (RuntimeException) jobException;
+        } else if (jobException instanceof Throwable) {
+            throw new RuntimeException("Unexpected exception", (Throwable) jobException);
+        } else if (jobException instanceof NicProfile) {
+            return (NicProfile) jobException;
+        }

Review comment:
       there should actually be a throw. let me check




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org