Skip to content

Commit 644f3a3

Browse files
authored
Add, Delete Storage Pool commands should be able execute on a host in maintenance (apache#9301)
* Restart agent when host comes out of maintenance * Don't send CreateStoragePoolCommand to hosts in maintenance mode * CreateStoragePoolCommand can run when host in maintenance. Reverted the change to restart agent when host was already up and in maintenance * Reverted changes done to ResourceManagerImplTest
1 parent 6b25ed7 commit 644f3a3

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

engine/components-api/src/main/java/com/cloud/resource/ResourceManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ public interface ResourceManager extends ResourceService, Configurable {
126126

127127
public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType type, long dcId);
128128

129+
public List<HostVO> listAllUpHostsInOneZoneByHypervisor(HypervisorType type, long dcId);
130+
129131
public List<HostVO> listAllUpAndEnabledHostsInOneZone(long dcId);
130132

131133
public List<HostVO> listAllHostsInOneZoneByType(Host.Type type, long dcId);

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentAttache.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
import com.cloud.agent.api.CheckVirtualMachineCommand;
4545
import com.cloud.agent.api.CleanupNetworkRulesCmd;
4646
import com.cloud.agent.api.Command;
47+
import com.cloud.agent.api.CreateStoragePoolCommand;
48+
import com.cloud.agent.api.DeleteStoragePoolCommand;
4749
import com.cloud.agent.api.MaintainCommand;
4850
import com.cloud.agent.api.MigrateCommand;
4951
import com.cloud.agent.api.ModifySshKeysCommand;
@@ -119,8 +121,9 @@ public int compare(final Object o1, final Object o2) {
119121
StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(),
120122
ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(),
121123
CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString(), CheckOnHostCommand.class.toString(),
122-
ModifyTargetsCommand.class.toString(), ModifySshKeysCommand.class.toString(), ModifyStoragePoolCommand.class.toString(), SetupMSListCommand.class.toString(), RollingMaintenanceCommand.class.toString(),
123-
CleanupPersistentNetworkResourceCommand.class.toString()};
124+
ModifyTargetsCommand.class.toString(), ModifySshKeysCommand.class.toString(),
125+
CreateStoragePoolCommand.class.toString(), DeleteStoragePoolCommand.class.toString(), ModifyStoragePoolCommand.class.toString(),
126+
SetupMSListCommand.class.toString(), RollingMaintenanceCommand.class.toString(), CleanupPersistentNetworkResourceCommand.class.toString()};
124127
protected final static String[] s_commandsNotAllowedInConnectingMode = new String[] { StartCommand.class.toString(), CreateCommand.class.toString() };
125128
static {
126129
Arrays.sort(s_commandsAllowedInMaintenanceMode);

plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public boolean attachCluster(DataStore store, ClusterScope scope) {
467467

468468
@Override
469469
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
470-
List<HostVO> hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(hypervisorType, scope.getScopeId());
470+
List<HostVO> hosts = _resourceMgr.listAllUpHostsInOneZoneByHypervisor(hypervisorType, scope.getScopeId());
471471
s_logger.debug("In createPool. Attaching the pool to each of the hosts.");
472472
List<HostVO> poolHosts = new ArrayList<HostVO>();
473473
for (HostVO host : hosts) {

server/src/main/java/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3255,6 +3255,15 @@ public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(final Hypervis
32553255
return sc.list();
32563256
}
32573257

3258+
@Override
3259+
public List<HostVO> listAllUpHostsInOneZoneByHypervisor(final HypervisorType type, final long dcId) {
3260+
final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
3261+
sc.and(sc.entity().getHypervisorType(), Op.EQ, type);
3262+
sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId);
3263+
sc.and(sc.entity().getStatus(), Op.EQ, Status.Up);
3264+
return sc.list();
3265+
}
3266+
32583267
@Override
32593268
public List<HostVO> listAllUpAndEnabledHostsInOneZone(final long dcId) {
32603269
final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);

server/src/test/java/com/cloud/resource/MockResourceManagerImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,12 @@ public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(final Hypervis
588588
return null;
589589
}
590590

591+
@Override
592+
public List<HostVO> listAllUpHostsInOneZoneByHypervisor(final HypervisorType type, final long dcId) {
593+
// TODO Auto-generated method stub
594+
return null;
595+
}
596+
591597
@Override
592598
public List<HostVO> listAllUpAndEnabledHostsInOneZone(final long dcId) {
593599
// TODO Auto-generated method stub

0 commit comments

Comments
 (0)