vishesh92 commented on code in PR #11071:
URL: https://github.com/apache/cloudstack/pull/11071#discussion_r2526734792
##########
scripts/storage/multipath/connectVolume.sh:
##########
@@ -29,103 +29,40 @@ WWID=${2:?"WWID required"}
WWID=$(echo $WWID | tr '[:upper:]' '[:lower:]')
-systemctl is-active multipathd || systemctl restart multipathd || {
- echo "$(date): Multipathd is NOT running and cannot be started. This must
be corrected before this host can access this storage volume."
- logger -t "CS_SCSI_VOL_FIND" "${WWID} cannot be mapped to this host because
multipathd is not currently running and cannot be started"
+START_CONNECT=$(dirname $0)/startConnect.sh
+if [ -x "${START_CONNECT}" ]; then
+ echo "$(date): Starting connect process for ${WWID} on lun ${LUN}"
+ ${START_CONNECT} ${LUN} ${WWID}
+ if [ $? -ne 0 ]; then
+ echo "$(date): Failed to start connect process for ${WWID} on lun ${LUN}"
+ logger -t "CS_SCSI_VOL_FIND" "${WWID} failed to start connect process on
lun ${LUN}"
+ exit 1
+ fi
+else
+ echo "$(date): Unable to find startConnect.sh script!"
exit 1
-}
-
-echo "$(date): Looking for ${WWID} on lun ${LUN}"
-
-# get vendor OUI. we will only delete a device on the designated lun if it
matches the
-# incoming WWN OUI value. This is because multiple storage arrays may be
mapped to the
-# host on different fiber channel hosts with the same LUN
-INCOMING_OUI=$(echo ${WWID} | cut -c2-7)
-echo "$(date): Incoming OUI: ${INCOMING_OUI}"
-
-# first we need to check if any stray references are left from a previous use
of this lun
-for fchost in $(ls /sys/class/fc_host | sed -e 's/host//g'); do
- lingering_devs=$(lsscsi -w "${fchost}:*:*:${LUN}" | grep /dev | awk '{if
(NF > 6) { printf("%s:%s ", $NF, $(NF-1));} }' | sed -e 's/0x/3/g')
+fi
- if [ ! -z "${lingering_devs}" ]; then
- for dev in ${lingering_devs}; do
- LSSCSI_WWID=$(echo $dev | awk -F: '{print $2}' | sed -e 's/0x/3/g')
- FOUND_OUI=$(echo ${LSSCSI_WWID} | cut -c3-8)
- if [ "${INCOMING_OUI}" != "${FOUND_OUI}" ]; then
- continue;
- fi
- dev=$(echo $dev | awk -F: '{ print $1}')
- logger -t "CS_SCSI_VOL_FIND" "${WWID} processing identified a lingering
device ${dev} from previous lun use, attempting to clean up"
- MP_WWID=$(multipath -l ${dev} | head -1 | awk '{print $1}')
- MP_WWID=${MP_WWID:1} # strip first character (3) off
- # don't do this if the WWID passed in matches the WWID from multipath
- if [ ! -z "${MP_WWID}" ] && [ "${MP_WWID}" != "${WWID}" ]; then
- # run full removal again so all devices and multimap are cleared
- $(dirname $0)/disconnectVolume.sh ${MP_WWID}
- # we don't have a multimap but we may still have some stranded devices
to clean up
- elif [ "${LSSCSI_WWID}" != "${WWID}" ]; then
- echo "1" > /sys/block/$(echo ${dev} | awk -F'/' '{print
$NF}')/device/delete
- fi
- done
- sleep 3
- fi
+// wait for the device path to show up
Review Comment:
```suggestion
# wait for the device path to show up
```
##########
plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/driver/AdaptiveDataStoreDriverImpl.java:
##########
@@ -840,55 +840,95 @@ public boolean canHostAccessStoragePool(Host host,
StoragePool pool) {
}
void persistVolumeOrTemplateData(StoragePoolVO storagePool, Map<String,
String> storagePoolDetails,
- DataObject dataObject, ProviderVolume volume, Map<String,String>
connIdMap) {
+ DataObject dataObject, ProviderVolume volume, Map<String,String>
connIdMap, Long size) {
if (dataObject.getType() == DataObjectType.VOLUME) {
- persistVolumeData(storagePool, storagePoolDetails, dataObject,
volume, connIdMap);
+ persistVolumeData(storagePool, storagePoolDetails, dataObject,
volume, connIdMap, size);
} else if (dataObject.getType() == DataObjectType.TEMPLATE) {
- persistTemplateData(storagePool, storagePoolDetails, dataObject,
volume, connIdMap);
+ persistTemplateData(storagePool, storagePoolDetails, dataObject,
volume, connIdMap, size);
}
}
void persistVolumeData(StoragePoolVO storagePool, Map<String, String>
details, DataObject dataObject,
- ProviderVolume managedVolume, Map<String,String> connIdMap) {
+ ProviderVolume managedVolume, Map<String,String> connIdMap, Long
size) {
+
+ // Get the volume by dataObject id
VolumeVO volumeVO = _volumeDao.findById(dataObject.getId());
+ long volumeId = volumeVO.getId();
+ // Generate path for volume and details
String finalPath = generatePathInfo(managedVolume, connIdMap);
- volumeVO.setPath(finalPath);
- volumeVO.setFormat(ImageFormat.RAW);
- volumeVO.setPoolId(storagePool.getId());
- volumeVO.setExternalUuid(managedVolume.getExternalUuid());
- volumeVO.setDisplay(true);
- volumeVO.setDisplayVolume(true);
- _volumeDao.update(volumeVO.getId(), volumeVO);
- volumeVO = _volumeDao.findById(volumeVO.getId());
+ try {
+ if (finalPath != null) {
+ volumeVO.setPath(finalPath);
+ }
+ volumeVO.setFormat(ImageFormat.RAW);
+ volumeVO.setPoolId(storagePool.getId());
+ volumeVO.setExternalUuid(managedVolume.getExternalUuid());
+ volumeVO.setDisplay(true);
+ volumeVO.setDisplayVolume(true);
+ // the size may have been adjusted by the storage provider
+ if (size != null) {
+ volumeVO.setSize(size);
+ }
+ _volumeDao.update(volumeVO.getId(), volumeVO);
+ } catch (Throwable e) {
+ logger.error("Failed to persist volume path", e);
+ throw e;
+ }
- VolumeDetailVO volumeDetailVO = new VolumeDetailVO(volumeVO.getId(),
- DiskTO.PATH, finalPath, true);
- _volumeDetailsDao.persist(volumeDetailVO);
+ // PATH
+ try {
+ // If volume_detail exist
+ _volumeDetailsDao.removeDetail(volumeId, DiskTO.PATH);
+ VolumeDetailVO volumeDetailVO = new VolumeDetailVO(volumeId,
DiskTO.PATH, finalPath, true);
+ _volumeDetailsDao.persist(volumeDetailVO);
+ } catch (Exception e) {
+ logger.error("Failed to persist volume path", e);
+ throw e;
+ }
- volumeDetailVO = new VolumeDetailVO(volumeVO.getId(),
- ProviderAdapterConstants.EXTERNAL_NAME,
managedVolume.getExternalName(), true);
- _volumeDetailsDao.persist(volumeDetailVO);
+ // EXTERNAL_NAME
+ try {
+ _volumeDetailsDao.removeDetail(volumeId,
ProviderAdapterConstants.EXTERNAL_NAME);
+ VolumeDetailVO volumeDetailVO = new VolumeDetailVO(volumeId,
ProviderAdapterConstants.EXTERNAL_NAME, managedVolume.getExternalName(), true);
+ _volumeDetailsDao.persist(volumeDetailVO);
+ } catch (Exception e) {
+ logger.error("Failed to persist volume external name", e);
+ throw e;
+ }
- volumeDetailVO = new VolumeDetailVO(volumeVO.getId(),
- ProviderAdapterConstants.EXTERNAL_UUID,
managedVolume.getExternalUuid(), true);
- _volumeDetailsDao.persist(volumeDetailVO);
+ // EXTERNAL_UUID
+ try {
+ _volumeDetailsDao.removeDetail(volumeId,
ProviderAdapterConstants.EXTERNAL_UUID);
+ VolumeDetailVO volumeDetailVO = new VolumeDetailVO(volumeId,
ProviderAdapterConstants.EXTERNAL_UUID, managedVolume.getExternalUuid(), true);
+ _volumeDetailsDao.persist(volumeDetailVO);
+ } catch (Exception e) {
+ logger.error("Failed to persist volume external uuid", e);
+ throw e;
+ }
}
void persistTemplateData(StoragePoolVO storagePool, Map<String, String>
details, DataObject dataObject,
- ProviderVolume volume, Map<String,String> connIdMap) {
+ ProviderVolume volume, Map<String,String> connIdMap, Long size) {
TemplateInfo templateInfo = (TemplateInfo) dataObject;
VMTemplateStoragePoolVO templatePoolRef =
_vmTemplatePoolDao.findByPoolTemplate(storagePool.getId(),
templateInfo.getId(), null);
templatePoolRef.setInstallPath(generatePathInfo(volume, connIdMap));
templatePoolRef.setLocalDownloadPath(volume.getExternalName());
- templatePoolRef.setTemplateSize(volume.getAllocatedSizeInBytes());
- _vmTemplatePoolDao.update(templatePoolRef.getId(), templatePoolRef);
+ if (size == null) {
+ templatePoolRef.setTemplateSize(volume.getAllocatedSizeInBytes());
+ } else {
+ templatePoolRef.setTemplateSize(size);
+ } _vmTemplatePoolDao.update(templatePoolRef.getId(),
templatePoolRef);
Review Comment:
```suggestion
}
_vmTemplatePoolDao.update(templatePoolRef.getId(), templatePoolRef);
```
--
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]