This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new 056e7d15bc Fix ping NFS server on ssvm-check.sh (#6900)
056e7d15bc is described below
commit 056e7d15bc20e5f767acf303149ad68bb33e9963
Author: Daniel Augusto Veronezi Salvador
<[email protected]>
AuthorDate: Thu Feb 2 06:20:22 2023 -0300
Fix ping NFS server on ssvm-check.sh (#6900)
---
.../SecondaryStorageManagerImpl.java | 26 +++++++++++++--
systemvm/agent/scripts/ssvm-check.sh | 37 ++++++++++++++++------
2 files changed, 51 insertions(+), 12 deletions(-)
diff --git
a/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
b/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
index 75bcbf2496..ac3567b21f 100644
---
a/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
+++
b/services/secondary-storage/controller/src/main/java/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
@@ -48,6 +48,7 @@ import
org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
@@ -1087,12 +1088,13 @@ public class SecondaryStorageManagerImpl extends
ManagerBase implements Secondar
buf.append(" template=domP type=secstorage");
buf.append("
host=").append(com.cloud.utils.StringUtils.toCSVList(indirectAgentLB.getManagementServerList(dest.getHost().getId(),
dest.getDataCenter().getId(), null)));
buf.append(" port=").append(_mgmtPort);
- buf.append(" name=").append(profile.getVirtualMachine().getHostName());
+ String vmName = profile.getVirtualMachine().getHostName();
+ buf.append(" name=").append(vmName);
buf.append(" zone=").append(dest.getDataCenter().getId());
buf.append(" pod=").append(dest.getPod().getId());
- buf.append(" guid=").append(profile.getVirtualMachine().getHostName());
+ buf.append(" guid=").append(vmName);
buf.append(" workers=").append(_configDao.getValue("workers"));
String msPublicKey = _configDao.getValue("ssh.publickey");
@@ -1180,9 +1182,29 @@ public class SecondaryStorageManagerImpl extends
ManagerBase implements Secondar
s_logger.debug(String.format("Setting UseHttpsToUpload config on
cmdline with [%s] value.", useHttpsToUpload));
buf.append(" useHttpsToUpload=").append(useHttpsToUpload);
+ addSecondaryStorageServerAddressToBuffer(buf, secStore, vmName);
+
return true;
}
+ /**
+ * Adds the secondary storage address to the buffer if it is in the
following pattern: <protocol>//<address>/...
+ */
+ protected void addSecondaryStorageServerAddressToBuffer(StringBuilder
buffer, DataStore dataStore, String vmName) {
+ String url = dataStore.getTO().getUrl();
+ String[] urlArray = url.split("/");
+
+ s_logger.debug(String.format("Found [%s] as secondary storage's URL
for SSVM [%s].", url, vmName));
+ if (ArrayUtils.getLength(urlArray) < 3) {
+ s_logger.debug(String.format("Could not retrieve secondary storage
address from URL [%s] of SSVM [%s].", url, vmName));
+ return;
+ }
+
+ String address = urlArray[2];
+ s_logger.info(String.format("Using [%s] as address of secondary
storage of SSVM [%s].", address, vmName));
+ buffer.append(" secondaryStorageServerAddress=").append(address);
+ }
+
@Override
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile
profile, DeployDestination dest, ReservationContext context) {
diff --git a/systemvm/agent/scripts/ssvm-check.sh
b/systemvm/agent/scripts/ssvm-check.sh
index 850e71d275..5fdc244deb 100644
--- a/systemvm/agent/scripts/ssvm-check.sh
+++ b/systemvm/agent/scripts/ssvm-check.sh
@@ -99,19 +99,36 @@ then
fi
done
else
- echo "ERROR: NFS is not currently mounted"
- echo "Try manually mounting from inside the VM"
- NFSSERVER=`awk '{print $17}' $CMDLINE|awk -F= '{print $2}'|awk -F: '{print
$1}'`
- echo "NFS server is " $NFSSERVER
- ping -c 2 $NFSSERVER
- if [ $? -eq 0 ]
+ echo "ERROR: Storage $storage is not currently mounted"
+ echo "Verifying if we can at least ping the storage"
+ STORAGE_ADDRESS=`grep "secondaryStorageServerAddress" $CMDLINE | sed -E
's/.*secondaryStorageServerAddress=([^ ]*).*/\1/g'`
+
+ if [[ -z "$STORAGE_ADDRESS" ]]
then
- echo "Good: Can ping $storage server"
+ STORAGE_NETWORK_GATEWAY=`grep "storagegateway" $CMDLINE | sed -E
's/.*storagegateway=([^ ]*).*/\1/g'`
+ echo "Storage address is empty, trying to ping storage network gateway
instead ($STORAGE_NETWORK_GATEWAY)"
+ ping -c 2 $STORAGE_NETWORK_GATEWAY
+ if [ $? -eq 0 ]
+ then
+ echo "Good: Can ping $storage storage network gateway"
+ else
+ echo "WARNING: Cannot ping $storage storage network gateway"
+ echo routing table follows
+ route -n
+ fi
else
- echo "WARNING: cannot ping $storage server"
- echo routing table follows
- route -n
+ echo "Storage address is $STORAGE_ADDRESS, trying to ping it"
+ ping -c 2 $STORAGE_ADDRESS
+ if [ $? -eq 0 ]
+ then
+ echo "Good: Can ping $storage storage address"
+ else
+ echo "WARNING: Cannot ping $storage storage address"
+ echo routing table follows
+ route -n
+ fi
fi
+
fi