nvazquez commented on a change in pull request #5977:
URL: https://github.com/apache/cloudstack/pull/5977#discussion_r830172702
##########
File path:
engine/storage/volume/src/main/java/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java
##########
@@ -142,11 +192,62 @@ public boolean hostDisconnected(long hostId, long poolId)
{
@Override
public boolean hostAboutToBeRemoved(long hostId) {
+ // send host the cleanup persistent network resources
+ HostVO host = hostDao.findById(hostId);
+ if (host == null) {
+ s_logger.warn("Host with id " + hostId + " can't be found");
+ return false;
+ }
+
+ List<NetworkVO> allPersistentNetworks =
networkDao.getAllPersistentNetworksFromZone(host.getDataCenterId()); // find
zoneId of host
+ for (NetworkVO persistentNetworkVO : allPersistentNetworks) {
+ NetworkOfferingVO networkOfferingVO =
networkOfferingDao.findById(persistentNetworkVO.getNetworkOfferingId());
+ CleanupPersistentNetworkResourceCommand cleanupCmd =
+ new
CleanupPersistentNetworkResourceCommand(createNicTOFromNetworkAndOffering(persistentNetworkVO,
networkOfferingVO, host));
+ Answer answer = agentMgr.easySend(hostId, cleanupCmd);
Review comment:
Hi @Pearl1594 - @NuxRo found there is an issue when the host is on
maintenance, the command cannot be sent and the resources are not removed, can
you please check?
````
2022-03-18 16:26:36,292 WARN [c.c.a.m.AgentManagerImpl]
(qtp1747352992-22:ctx-86e6bd15 ctx-c42a5840) (logid:3ca85a2b) Resource [Host:5]
is unreachable: Host 5: Unable to send class c
om.cloud.agent.api.CleanupPersistentNetworkResourceCommand because agent
ref-trl-2736-k-M7-nicolas-vazquez-kvm2 is in maintenance mode
2022-03-18 16:26:36,292 ERROR [o.a.c.s.d.p.DefaultHostListener]
(qtp1747352992-22:ctx-86e6bd15 ctx-c42a5840) (logid:3ca85a2b) Unable to get
answer to the cleanup persistent network command 205
2022-03-18 16:26:36,295 DEBUG [c.c.n.NetworkModelImpl]
(qtp1747352992-22:ctx-86e6bd15 ctx-c42a5840) (logid:3ca85a2b) Service
SecurityGroup is not supported in the network id=205
2022-03-18 16:26:36,296 WARN [c.c.a.m.AgentManagerImpl]
(qtp1747352992-22:ctx-86e6bd15 ctx-c42a5840) (logid:3ca85a2b) Resource [Host:5]
is unreachable: Host 5: Unable to send class
com.cloud.agent.api.CleanupPersistentNetworkResourceCommand because agent
ref-trl-2736-k-M7-nicolas-vazquez-kvm2 is in maintenance mode
2022-03-18 16:26:36,296 ERROR [o.a.c.s.d.p.DefaultHostListener]
(qtp1747352992-22:ctx-86e6bd15 ctx-c42a5840) (logid:3ca85a2b) Unable to get
answer to the cleanup persistent network command 205
````
Could verify it works using the deleteHost API passing forced=true
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]