File tree Expand file tree Collapse file tree
compute/src/main/java/org/zstack/compute/vm Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,18 +98,18 @@ public void run(MessageReply reply) {
9898 }).run (new WhileDoneCompletion (trigger ){
9999 @ Override
100100 public void done (ErrorCodeList errorCodeList ) {
101- dbf .removeByPrimaryKey (nic .getUuid (), VmNicVO .class );
102-
103101 callReleaseSdnNics (java .util .Collections .singletonList (nic ), new Completion (trigger ) {
104102 @ Override
105103 public void success () {
104+ dbf .removeByPrimaryKey (nic .getUuid (), VmNicVO .class );
106105 trigger .next ();
107106 }
108107
109108 @ Override
110109 public void fail (ErrorCode errorCode ) {
111110 logger .warn (String .format ("releaseSdnNics failed for nic[uuid:%s]: %s, continue" ,
112111 nic .getUuid (), errorCode ));
112+ dbf .removeByPrimaryKey (nic .getUuid (), VmNicVO .class );
113113 trigger .next ();
114114 }
115115 });
Original file line number Diff line number Diff line change @@ -79,12 +79,13 @@ public void run(MessageReply reply) {
7979 @ Override
8080 public void done (ErrorCodeList errorCodeList ) {
8181 List <VmNicInventory > releasedNics = new ArrayList <>();
82+ List <VmNicVO > nicsToDelete = new ArrayList <>();
8283 for (VmNicInventory nic : spec .getVmInventory ().getVmNics ()) {
8384 VmNicVO vo = dbf .findByUuid (nic .getUuid (), VmNicVO .class );
8485 if (VmInstanceConstant .USER_VM_TYPE .equals (spec .getVmInventory ().getType ())) {
8586 VmInstanceDeletionPolicy deletionPolicy = getDeletionPolicy (spec , data );
8687 if (deletionPolicy == VmInstanceDeletionPolicy .Direct ) {
87- dbf . remove (vo );
88+ nicsToDelete . add (vo );
8889 } else {
8990 vo .setUsedIpUuid (null );
9091 vo .setIp (null );
@@ -93,20 +94,22 @@ public void done(ErrorCodeList errorCodeList) {
9394 dbf .update (vo );
9495 }
9596 } else {
96- dbf . remove (vo );
97+ nicsToDelete . add (vo );
9798 }
9899 releasedNics .add (nic );
99100 }
100101
101102 callReleaseSdnNics (releasedNics , new Completion (chain ) {
102103 @ Override
103104 public void success () {
105+ nicsToDelete .forEach (dbf ::remove );
104106 chain .next ();
105107 }
106108
107109 @ Override
108110 public void fail (ErrorCode errorCode ) {
109111 logger .warn (String .format ("releaseSdnNics failed: %s, continue anyway" , errorCode ));
112+ nicsToDelete .forEach (dbf ::remove );
110113 chain .next ();
111114 }
112115 });
You can’t perform that action at this time.
0 commit comments