wido commented on a change in pull request #5862:
URL: https://github.com/apache/cloudstack/pull/5862#discussion_r795642715



##########
File path: 
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHABase.java
##########
@@ -181,6 +206,26 @@ protected String runScriptRetry(String cmdString, 
OutputInterpreter interpreter)
         return result;
     }
 
+    public static String getRbdMonIpAddress(String sourceHost) {
+        try {
+            String[] hostArr = sourceHost.split(",");
+            String sourceHostIP = "";
+            for (String host : hostArr) {
+                String ipRegex = 
"(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])";

Review comment:
       Does this support IPv6?

##########
File path: scripts/vm/hypervisor/kvm/kvmheartbeat_rbd.sh
##########
@@ -0,0 +1,151 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+help() {
+  printf "Usage: $0 
+                    -p rbd pool name
+                    -n pool auth username
+                    -s pool auth secret
+                    -h host
+                    -i source host ip
+                    -r write/read hb log 
+                    -c cleanup
+                    -t interval between read hb log\n"
+  exit 1
+}
+#set -x
+PoolName=
+PoolAuthUserName=
+PoolAuthSecret=
+HostIP=
+SourceHostIP=
+interval=
+rflag=0
+cflag=0
+
+while getopts 'p:n:s:h:i:t:rc' OPTION
+do
+  case $OPTION in
+  p)
+     PoolName="$OPTARG"
+     ;;
+  n)
+     PoolAuthUserName="$OPTARG"
+     ;;
+  s)
+     PoolAuthSecret="$OPTARG"
+     ;;
+  h)
+     HostIP="$OPTARG"
+     ;;
+  i)
+     SourceHostIP="$OPTARG"
+     ;;
+  t)
+     interval="$OPTARG"
+     ;;
+  r)
+     rflag=1 
+     ;;
+  c)
+    cflag=1
+     ;;
+  *)
+     help
+     ;;
+  esac
+done
+
+if [ -z "$PoolName" ]; then
+  exit 2
+fi
+
+keyringFile="/etc/ceph/keyring"
+confFile="/etc/ceph/ceph.conf"
+
+create_cephConf() {
+#Creating Ceph keyring and conf for executing rados commands
+  if [ ! -f $keyringFile ]; then
+    echo -e "[client.$PoolAuthUserName]\n key=$PoolAuthSecret" > $keyringFile

Review comment:
       We should never write to files in /etc/ceph from a script like this.
   
   CloudStack hosts can work without files in /etc/ceph

##########
File path: 
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHABase.java
##########
@@ -181,6 +206,26 @@ protected String runScriptRetry(String cmdString, 
OutputInterpreter interpreter)
         return result;
     }
 
+    public static String getRbdMonIpAddress(String sourceHost) {
+        try {
+            String[] hostArr = sourceHost.split(",");
+            String sourceHostIP = "";
+            for (String host : hostArr) {
+                String ipRegex = 
"(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])";
+                if (host.matches(ipRegex)) {
+                    sourceHostIP += host + ",";
+                } else {
+                    InetAddress addr = InetAddress.getByName(host);

Review comment:
       Does this support IPv6?

##########
File path: scripts/vm/hypervisor/kvm/kvmheartbeat_rbd.sh
##########
@@ -0,0 +1,151 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+help() {
+  printf "Usage: $0 
+                    -p rbd pool name
+                    -n pool auth username
+                    -s pool auth secret
+                    -h host
+                    -i source host ip
+                    -r write/read hb log 
+                    -c cleanup
+                    -t interval between read hb log\n"
+  exit 1
+}
+#set -x
+PoolName=
+PoolAuthUserName=
+PoolAuthSecret=
+HostIP=
+SourceHostIP=
+interval=
+rflag=0
+cflag=0
+
+while getopts 'p:n:s:h:i:t:rc' OPTION
+do
+  case $OPTION in
+  p)
+     PoolName="$OPTARG"
+     ;;
+  n)
+     PoolAuthUserName="$OPTARG"
+     ;;
+  s)
+     PoolAuthSecret="$OPTARG"
+     ;;
+  h)
+     HostIP="$OPTARG"
+     ;;
+  i)
+     SourceHostIP="$OPTARG"
+     ;;
+  t)
+     interval="$OPTARG"
+     ;;
+  r)
+     rflag=1 
+     ;;
+  c)
+    cflag=1
+     ;;
+  *)
+     help
+     ;;
+  esac
+done
+
+if [ -z "$PoolName" ]; then
+  exit 2
+fi
+
+keyringFile="/etc/ceph/keyring"
+confFile="/etc/ceph/ceph.conf"
+
+create_cephConf() {
+#Creating Ceph keyring and conf for executing rados commands
+  if [ ! -f $keyringFile ]; then
+    echo -e "[client.$PoolAuthUserName]\n key=$PoolAuthSecret" > $keyringFile
+  fi
+  
+  if [ ! -f $confFile ]; then
+    confContents="[global]\n mon host = "
+    for ip in $(echo $SourceHostIP | sed 's/,/ /g'); do
+        confContents+="[v2:${ip}:3300/0,v1:${ip}:6789/0], "
+    done
+    echo -e "$confContents" | sed 's/, $//' > $confFile

Review comment:
       Same here. We should not write to /etc/ceph/ceph.conf in any 
circumstance.
   
   Not needed as well

##########
File path: 
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/KVMHAChecker.java
##########
@@ -71,6 +73,30 @@ public Boolean checkingHeartBeat() {
             }
         }
 
+        for (RbdStoragePool pool : rbdStoragePools) {
+            Script cmd = new Script(s_heartBeatPathRbd, 
heartBeatCheckerTimeout, s_logger);
+            cmd.add("-i", getRbdMonIpAddress(pool._poolSourceHost));
+            cmd.add("-p", pool._poolMountSourcePath);
+            cmd.add("-n", pool._poolAuthUserName);
+            cmd.add("-s", pool._poolAuthSecret);

Review comment:
       Should we not use the UUID of the host? IPs can change, UUIDs should not




-- 
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]


Reply via email to