Skip to content

Commit 6de28bb

Browse files
author
Anthony Xu
committed
in XenServer, host eject may fail due to diffent reasons, it's hard for CS to handle all failure.
in CS, removing a host means CS will not manage the host, admin needs to eject the host from XS pool outside of CS
1 parent 6d103e6 commit 6de28bb

4 files changed

Lines changed: 0 additions & 138 deletions

File tree

core/src/com/cloud/agent/api/PoolEjectCommand.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
import com.cloud.agent.api.PingTestCommand;
163163
import com.cloud.agent.api.PlugNicAnswer;
164164
import com.cloud.agent.api.PlugNicCommand;
165-
import com.cloud.agent.api.PoolEjectCommand;
166165
import com.cloud.agent.api.PrepareForMigrationAnswer;
167166
import com.cloud.agent.api.PrepareForMigrationCommand;
168167
import com.cloud.agent.api.PvlanSetupCommand;
@@ -465,8 +464,6 @@ public Answer executeRequest(Command cmd) {
465464
answer = execute((CheckOnHostCommand)cmd);
466465
} else if (clz == ModifySshKeysCommand.class) {
467466
answer = execute((ModifySshKeysCommand)cmd);
468-
} else if (clz == PoolEjectCommand.class) {
469-
answer = execute((PoolEjectCommand)cmd);
470467
} else if (clz == NetworkUsageCommand.class) {
471468
answer = execute((NetworkUsageCommand)cmd);
472469
} else if (clz == StartCommand.class) {
@@ -4161,13 +4158,6 @@ protected Answer execute(ModifySshKeysCommand cmd) {
41614158
return new Answer(cmd);
41624159
}
41634160

4164-
protected Answer execute(PoolEjectCommand cmd) {
4165-
if (s_logger.isInfoEnabled()) {
4166-
s_logger.info("Executing resource PoolEjectCommand: " + _gson.toJson(cmd));
4167-
}
4168-
4169-
return new Answer(cmd, false, "PoolEjectCommand is not available for vmware");
4170-
}
41714161

41724162
@Override
41734163
public PrimaryStorageDownloadAnswer execute(PrimaryStorageDownloadCommand cmd) {

plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import com.cloud.agent.api.AgentControlCommand;
4141
import com.cloud.agent.api.Answer;
4242
import com.cloud.agent.api.Command;
43-
import com.cloud.agent.api.PoolEjectCommand;
4443
import com.cloud.agent.api.SetupAnswer;
4544
import com.cloud.agent.api.SetupCommand;
4645
import com.cloud.agent.api.StartupCommand;
@@ -730,34 +729,6 @@ public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForc
730729
}
731730

732731
_resourceMgr.deleteRoutingHost(host, isForced, isForceDeleteStorage);
733-
if (host.getClusterId() != null) {
734-
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHosts(com.cloud.host.Host.Type.Routing, host.getClusterId(), host.getPodId(), host.getDataCenterId());
735-
boolean success = true;
736-
for (HostVO thost : hosts) {
737-
if (thost.getId() == host.getId()) {
738-
continue;
739-
}
740-
741-
long thostId = thost.getId();
742-
PoolEjectCommand eject = new PoolEjectCommand(host.getGuid());
743-
Answer answer = _agentMgr.easySend(thostId, eject);
744-
if (answer != null && answer.getResult()) {
745-
s_logger.debug("Eject Host: " + host.getId() + " from " + thostId + " Succeed");
746-
success = true;
747-
break;
748-
} else {
749-
success = false;
750-
s_logger.warn("Eject Host: " + host.getId() + " from " + thostId + " failed due to " + (answer != null ? answer.getDetails() : "no answer"));
751-
}
752-
}
753-
if (!success) {
754-
String msg =
755-
"Unable to eject host " + host.getGuid() + " due to there is no host up in this cluster, please execute xe pool-eject host-uuid=" + host.getGuid() +
756-
"in this host " + host.getPrivateIpAddress();
757-
s_logger.warn(msg);
758-
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Unable to eject host " + host.getGuid(), msg);
759-
}
760-
}
761732
return new DeleteHostAnswer(true);
762733
}
763734

plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
import com.cloud.agent.api.PingTestCommand;
8888
import com.cloud.agent.api.PlugNicAnswer;
8989
import com.cloud.agent.api.PlugNicCommand;
90-
import com.cloud.agent.api.PoolEjectCommand;
9190
import com.cloud.agent.api.PrepareForMigrationAnswer;
9291
import com.cloud.agent.api.PrepareForMigrationCommand;
9392
import com.cloud.agent.api.PvlanSetupCommand;
@@ -499,8 +498,6 @@ public Answer executeRequest(Command cmd) {
499498
return execute((CheckOnHostCommand)cmd);
500499
} else if (clazz == ModifySshKeysCommand.class) {
501500
return execute((ModifySshKeysCommand)cmd);
502-
} else if (clazz == PoolEjectCommand.class) {
503-
return execute((PoolEjectCommand)cmd);
504501
} else if (clazz == StartCommand.class) {
505502
return execute((StartCommand)cmd);
506503
} else if (clazz == CheckSshCommand.class) {
@@ -7055,58 +7052,6 @@ public void setAgentControl(IAgentControl agentControl) {
70557052
_agentControl = agentControl;
70567053
}
70577054

7058-
protected Answer execute(PoolEjectCommand cmd) {
7059-
Connection conn = getConnection();
7060-
String hostuuid = cmd.getHostuuid();
7061-
try {
7062-
Host host = Host.getByUuid(conn, hostuuid);
7063-
if (isRefNull(host)) {
7064-
s_logger.debug("host " + hostuuid + " has already been ejected from pool " + _host.pool);
7065-
return new Answer(cmd);
7066-
}
7067-
// remove all tags cloud stack add before eject
7068-
Host.Record hr = host.getRecord(conn);
7069-
Iterator<String> it = hr.tags.iterator();
7070-
while (it.hasNext()) {
7071-
String tag = it.next();
7072-
if (tag.contains("cloud")) {
7073-
it.remove();
7074-
}
7075-
}
7076-
host.setTags(conn, hr.tags);
7077-
Pool pool = Pool.getByUuid(conn, _host.pool);
7078-
Pool.Record poolr = pool.getRecord(conn);
7079-
7080-
Host.Record hostr = poolr.master.getRecord(conn);
7081-
if (_host.uuid.equals(hostr.uuid)) {
7082-
Map<Host, Host.Record> hostMap = Host.getAllRecords(conn);
7083-
if (hostMap.size() > 1) {
7084-
String msg = "This host is XS master, please designate a new XS master throught XenCenter before you delete this host from CS";
7085-
s_logger.debug(msg);
7086-
return new Answer(cmd, false, msg);
7087-
}
7088-
}
7089-
7090-
// eject from pool
7091-
try {
7092-
Pool.eject(conn, host);
7093-
try {
7094-
Thread.sleep(10 * 1000);
7095-
} catch (InterruptedException e) {
7096-
}
7097-
} catch (XenAPIException e) {
7098-
String msg = "Unable to eject host " + _host.uuid + " due to " + e.toString();
7099-
s_logger.warn(msg);
7100-
host.destroy(conn);
7101-
}
7102-
return new Answer(cmd);
7103-
} catch (Exception e) {
7104-
String msg = "Exception Unable to destroy host " + _host.uuid + " in xenserver database due to " + e.toString();
7105-
s_logger.warn(msg, e);
7106-
return new Answer(cmd, false, msg);
7107-
}
7108-
}
7109-
71107055
private Answer execute(CleanupNetworkRulesCmd cmd) {
71117056
if (!_canBridgeFirewall) {
71127057
return new Answer(cmd, true, null);

0 commit comments

Comments
 (0)