Skip to content

Commit 4d8df02

Browse files
committed
bug 8245: mark storage pool status as Removed before performing actual cleanup
status 8245: resolved fixed
1 parent 253b883 commit 4d8df02

4 files changed

Lines changed: 167 additions & 115 deletions

File tree

api/src/com/cloud/api/commands/DeletePoolCmd.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,57 @@
88
import com.cloud.api.Parameter;
99
import com.cloud.api.ServerApiException;
1010
import com.cloud.api.response.SuccessResponse;
11+
import com.cloud.storage.StoragePool;
12+
import com.cloud.storage.StoragePoolStatus;
1113
import com.cloud.user.Account;
1214

13-
@Implementation(description="Deletes a storage pool.", responseObject=SuccessResponse.class)
15+
@Implementation(description = "Deletes a storage pool.", responseObject = SuccessResponse.class)
1416
public class DeletePoolCmd extends BaseCmd {
1517
public static final Logger s_logger = Logger.getLogger(DeletePoolCmd.class.getName());
1618
private static final String s_name = "deletestoragepoolresponse";
17-
18-
/////////////////////////////////////////////////////
19-
//////////////// API parameters /////////////////////
20-
/////////////////////////////////////////////////////
2119

22-
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="Storage pool id")
23-
private Long id;
20+
// ///////////////////////////////////////////////////
21+
// ////////////// API parameters /////////////////////
22+
// ///////////////////////////////////////////////////
2423

24+
@Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "Storage pool id")
25+
private Long id;
2526

26-
/////////////////////////////////////////////////////
27-
/////////////////// Accessors ///////////////////////
28-
/////////////////////////////////////////////////////
27+
// ///////////////////////////////////////////////////
28+
// ///////////////// Accessors ///////////////////////
29+
// ///////////////////////////////////////////////////
2930

3031
public Long getId() {
3132
return id;
3233
}
3334

34-
35-
/////////////////////////////////////////////////////
36-
/////////////// API Implementation///////////////////
37-
/////////////////////////////////////////////////////
35+
// ///////////////////////////////////////////////////
36+
// ///////////// API Implementation///////////////////
37+
// ///////////////////////////////////////////////////
3838

3939
@Override
4040
public String getCommandName() {
4141
return s_name;
4242
}
43-
43+
4444
@Override
4545
public long getEntityOwnerId() {
4646
return Account.ACCOUNT_ID_SYSTEM;
4747
}
48-
48+
4949
@Override
50-
public void execute(){
50+
public void execute() {
5151
boolean result = _storageService.deletePool(this);
5252
if (result) {
5353
SuccessResponse response = new SuccessResponse(getCommandName());
5454
this.setResponseObject(response);
5555
} else {
56-
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete storage pool");
56+
StoragePool pool = _storageService.getStoragePool(id);
57+
if (pool != null && pool.getStatus() == StoragePoolStatus.Removed) {
58+
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to finish storage pool removal. The storage pool will not be used but cleanup is needed");
59+
} else {
60+
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete storage pool");
61+
}
5762
}
5863
}
5964
}

api/src/com/cloud/storage/StorageService.java

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,23 @@
3737
public interface StorageService {
3838
/**
3939
* Create StoragePool based on uri
40-
* @param cmd the command object that specifies the zone, cluster/pod, URI, details, etc. to use to create the storage pool.
40+
*
41+
* @param cmd
42+
* the command object that specifies the zone, cluster/pod, URI, details, etc. to use to create the storage pool.
4143
* @return
4244
* @throws ResourceInUseException
4345
* @throws IllegalArgumentException
4446
* @throws UnknownHostException
45-
* @throws ResourceUnavailableException TODO
47+
* @throws ResourceUnavailableException
48+
* TODO
4649
*/
4750
StoragePool createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException, UnknownHostException, ResourceUnavailableException;
48-
51+
4952
/**
5053
* Creates the database object for a volume based on the given criteria
51-
* @param cmd the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot, name)
54+
*
55+
* @param cmd
56+
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot, name)
5257
* @return the volume object
5358
* @throws InvalidParameterValueException
5459
* @throws PermissionDeniedException
@@ -57,39 +62,51 @@ public interface StorageService {
5762

5863
/**
5964
* Creates the volume based on the given criteria
60-
* @param cmd the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot, name)
65+
*
66+
* @param cmd
67+
* the API command wrapping the criteria (account/domainId [admin only], zone, diskOffering, snapshot, name)
6168
* @return the volume object
6269
*/
6370
Volume createVolume(CreateVolumeCmd cmd);
6471

6572
boolean deleteVolume(DeleteVolumeCmd cmd) throws ConcurrentOperationException;
73+
6674
/**
6775
* Delete the storage pool
68-
* @param cmd - the command specifying poolId
76+
*
77+
* @param cmd
78+
* - the command specifying poolId
6979
* @return success or failure
7080
* @throws InvalidParameterValueException
7181
*/
7282
boolean deletePool(DeletePoolCmd cmd) throws InvalidParameterValueException;
83+
7384
/**
7485
* Enable maintenance for primary storage
75-
* @param cmd - the command specifying primaryStorageId
86+
*
87+
* @param cmd
88+
* - the command specifying primaryStorageId
7689
* @return the primary storage pool
77-
* @throws ResourceUnavailableException TODO
78-
* @throws InsufficientCapacityException TODO
90+
* @throws ResourceUnavailableException
91+
* TODO
92+
* @throws InsufficientCapacityException
93+
* TODO
7994
*/
8095
public StoragePool preparePrimaryStorageForMaintenance(PreparePrimaryStorageForMaintenanceCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException;
81-
96+
8297
/**
8398
* Complete maintenance for primary storage
84-
* @param cmd - the command specifying primaryStorageId
99+
*
100+
* @param cmd
101+
* - the command specifying primaryStorageId
85102
* @return the primary storage pool
86-
* @throws ResourceUnavailableException TODO
103+
* @throws ResourceUnavailableException
104+
* TODO
87105
*/
88106
public StoragePool cancelPrimaryStorageForMaintenance(CancelPrimaryStorageMaintenanceCmd cmd) throws ResourceUnavailableException;
89107

90108
public StoragePool updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException;
91-
92-
93109

110+
public StoragePool getStoragePool(long id);
94111

95112
}

core/src/com/cloud/alert/AlertManager.java

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,37 @@
1616
*
1717
*/
1818

19-
package com.cloud.alert;
20-
19+
package com.cloud.alert;
20+
2121
import com.cloud.capacity.CapacityVO;
2222
import com.cloud.utils.component.Manager;
23-
24-
public interface AlertManager extends Manager {
25-
public static final short ALERT_TYPE_MEMORY = CapacityVO.CAPACITY_TYPE_MEMORY;
26-
public static final short ALERT_TYPE_CPU = CapacityVO.CAPACITY_TYPE_CPU;
27-
public static final short ALERT_TYPE_STORAGE = CapacityVO.CAPACITY_TYPE_STORAGE;
28-
public static final short ALERT_TYPE_STORAGE_ALLOCATED = CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED;
29-
public static final short ALERT_TYPE_PUBLIC_IP = CapacityVO.CAPACITY_TYPE_PUBLIC_IP;
30-
public static final short ALERT_TYPE_PRIVATE_IP = CapacityVO.CAPACITY_TYPE_PRIVATE_IP;
31-
public static final short ALERT_TYPE_HOST = 6;
32-
public static final short ALERT_TYPE_USERVM = 7;
33-
public static final short ALERT_TYPE_DOMAIN_ROUTER = 8;
34-
public static final short ALERT_TYPE_CONSOLE_PROXY = 9;
35-
public static final short ALERT_TYPE_ROUTING = 10; // lost connection to default route (to the gateway)
36-
public static final short ALERT_TYPE_STORAGE_MISC = 11; // lost connection to default route (to the gateway)
37-
public static final short ALERT_TYPE_USAGE_SERVER = 12; // lost connection to default route (to the gateway)
38-
public static final short ALERT_TYPE_MANAGMENT_NODE = 13; // lost connection to default route (to the gateway)
39-
public static final short ALERT_TYPE_DOMAIN_ROUTER_MIGRATE = 14;
40-
public static final short ALERT_TYPE_CONSOLE_PROXY_MIGRATE = 15;
41-
public static final short ALERT_TYPE_USERVM_MIGRATE = 16;
23+
24+
public interface AlertManager extends Manager {
25+
public static final short ALERT_TYPE_MEMORY = CapacityVO.CAPACITY_TYPE_MEMORY;
26+
public static final short ALERT_TYPE_CPU = CapacityVO.CAPACITY_TYPE_CPU;
27+
public static final short ALERT_TYPE_STORAGE = CapacityVO.CAPACITY_TYPE_STORAGE;
28+
public static final short ALERT_TYPE_STORAGE_ALLOCATED = CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED;
29+
public static final short ALERT_TYPE_PUBLIC_IP = CapacityVO.CAPACITY_TYPE_PUBLIC_IP;
30+
public static final short ALERT_TYPE_PRIVATE_IP = CapacityVO.CAPACITY_TYPE_PRIVATE_IP;
31+
public static final short ALERT_TYPE_HOST = 6;
32+
public static final short ALERT_TYPE_USERVM = 7;
33+
public static final short ALERT_TYPE_DOMAIN_ROUTER = 8;
34+
public static final short ALERT_TYPE_CONSOLE_PROXY = 9;
35+
public static final short ALERT_TYPE_ROUTING = 10; // lost connection to default route (to the gateway)
36+
public static final short ALERT_TYPE_STORAGE_MISC = 11; // lost connection to default route (to the gateway)
37+
public static final short ALERT_TYPE_USAGE_SERVER = 12; // lost connection to default route (to the gateway)
38+
public static final short ALERT_TYPE_MANAGMENT_NODE = 13; // lost connection to default route (to the gateway)
39+
public static final short ALERT_TYPE_DOMAIN_ROUTER_MIGRATE = 14;
40+
public static final short ALERT_TYPE_CONSOLE_PROXY_MIGRATE = 15;
41+
public static final short ALERT_TYPE_USERVM_MIGRATE = 16;
4242
public static final short ALERT_TYPE_VLAN = 17;
4343
public static final short ALERT_TYPE_SSVM = 18;
44-
public static final short ALERT_TYPE_USAGE_SERVER_RESULT = 19; // Usage job result
45-
46-
void clearAlert(short alertType, long dataCenterId, long podId);
47-
void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String body);
48-
void recalculateCapacity();
49-
}
44+
public static final short ALERT_TYPE_USAGE_SERVER_RESULT = 19; // Usage job result
45+
public static final short ALERT_TYPE_STORAGE_DELETE = 20;
46+
47+
void clearAlert(short alertType, long dataCenterId, long podId);
48+
49+
void sendAlert(short alertType, long dataCenterId, Long podId, String subject, String body);
50+
51+
void recalculateCapacity();
52+
}

0 commit comments

Comments
 (0)