Skip to content

Commit fe19c55

Browse files
Srivastava, PiyushSrivastava, Piyush
authored andcommitted
vm restart issue
1 parent f89bb1b commit fe19c55

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ExportRule.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public static ProtocolsEnum fromValue(String text) {
8282
@JsonProperty("rw_rule")
8383
private List<String> rwRule = null;
8484

85+
@JsonProperty("superuser")
86+
private List<String> superuser = null;
87+
8588

8689
public ExportRule anonymousUser(String anonymousUser) {
8790
this.anonymousUser = anonymousUser;
@@ -163,6 +166,14 @@ public void setRoRule(List<String> roRule) {
163166
this.roRule = roRule;
164167
}
165168

169+
public List<String> getSuperuser() {
170+
return superuser;
171+
}
172+
173+
public void setSuperuser(List<String> superuser) {
174+
this.superuser = superuser;
175+
}
176+
166177
@Override
167178
public String toString() {
168179
StringBuilder sb = new StringBuilder();

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
291291
_storageMgr.connectHostToSharedPool(host, dataStore.getId());
292292
} catch (Exception e) {
293293
logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e);
294+
throw new CloudRuntimeException("Failed to attach storage pool to cluster: " + e.getMessage(), e);
294295
}
295296
}
296297
_dataStoreHelper.attachCluster(dataStore);
@@ -327,6 +328,7 @@ public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.Hyper
327328
_storageMgr.connectHostToSharedPool(host, dataStore.getId());
328329
} catch (Exception e) {
329330
logger.warn("Unable to establish a connection between " + host + " and " + dataStore, e);
331+
throw new CloudRuntimeException("Failed to attach storage pool to host: " + e.getMessage(), e);
330332
}
331333
}
332334
_dataStoreHelper.attachZone(dataStore);

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/listener/OntapHostListener.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,21 @@ public boolean hostConnect(long hostId, long poolId) {
6767

6868
// TODO add host type check also since we support only KVM for now, host.getHypervisorType().equals(HypervisorType.KVM)
6969
StoragePool pool = _storagePoolDao.findById(poolId);
70+
if (pool == null) {
71+
logger.error("Failed to connect host - storage pool not found with id: {}", poolId);
72+
return false;
73+
}
74+
75+
// CRITICAL: Check if already connected to avoid infinite loops
76+
StoragePoolHostVO existingConnection = storagePoolHostDao.findByPoolHost(poolId, hostId);
77+
if (existingConnection != null && existingConnection.getLocalPath() != null && !existingConnection.getLocalPath().isEmpty()) {
78+
logger.info("Host {} is already connected to storage pool {} at path {}. Skipping reconnection.",
79+
host.getName(), pool.getName(), existingConnection.getLocalPath());
80+
return true;
81+
}
82+
7083
logger.info("Connecting host {} to ONTAP storage pool {}", host.getName(), pool.getName());
7184

72-
7385
try {
7486
// Create the ModifyStoragePoolCommand to send to the agent
7587
ModifyStoragePoolCommand cmd = new ModifyStoragePoolCommand(true, pool);
@@ -123,7 +135,9 @@ public boolean hostConnect(long hostId, long poolId) {
123135

124136
} catch (Exception e) {
125137
logger.error("Exception while connecting host {} to storage pool {}", host.getName(), pool.getName(), e);
126-
throw new CloudRuntimeException("Failed to connect host to storage pool: " + e.getMessage(), e);
138+
// CRITICAL: Don't throw exception - it crashes the agent and causes restart loops
139+
// Return false to indicate failure without crashing
140+
return false;
127141
}
128142
return true;
129143
}

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ private ExportPolicy createExportPolicyRequest(AccessGroup accessGroup,String sv
381381
exportRule.setProtocols(List.of(ExportRule.ProtocolsEnum.any));
382382
exportRule.setRoRule(List.of("any"));
383383
exportRule.setRwRule(List.of("any"));
384+
exportRule.setSuperuser(List.of("any")); // Allow root/superuser access for NFS writes
384385
rules.add(exportRule);
385386

386387
Svm svm = new Svm();

0 commit comments

Comments
 (0)