Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3116,6 +3116,8 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
if (networkAccount != null) {
_networkAccountDao.remove(networkAccount.getId());
}

networkDetailsDao.removeDetails(networkFinal.getId());
Copy link
Copy Markdown
Contributor

@sureshanaparti sureshanaparti Nov 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The foreign key should serve the purpose here. But, when a network is destroyed, the removed date is set, and the record is not removed from the table (to keep/track the history at later stage when needed). The same is the case with most of the resources, where the foreign key is set with 'ON DELETE CASCADE' but unused. May be, a cleanup (enabled/disabled) for all such removed entires from the DB, have to be introduced at regular intervals (that can be set using global config).

CONSTRAINT `fk_network_details__network_id` FOREIGN KEY `fk_network_details__network_id`(`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sureshanaparti
yes, you are absolutely right. ON DELETE CASCADE does not work as expected because cloudstack updates removed field instead deleting the record from DB.

}

final NetworkOffering ntwkOff = _entityMgr.findById(NetworkOffering.class, networkFinal.getNetworkOfferingId());
Expand Down Expand Up @@ -4403,4 +4405,4 @@ public ConfigKey<?>[] getConfigKeys() {
GuestDomainSuffix, NetworkThrottlingRate, MinVRVersion,
PromiscuousMode, MacAddressChanges, ForgedTransmits, MacLearning, RollingRestartEnabled};
}
}
}