weizhouapache commented on code in PR #14320: URL: https://github.com/apache/cloudstack/pull/14320#discussion_r4222381729
########## scripts/vm/hypervisor/kvm/kvmheartbeat_rbd.sh: ########## @@ -0,0 +1,157 @@ +#!/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. + +# Ceph RBD flavor of kvmheartbeat.sh/kvmsmpheartbeat.sh. +# +# There is no shared POSIX mount point to write a heartbeat file to when the +# primary storage pool is Ceph RBD, so the heartbeat timestamp is instead +# stored as a small RADOS object (one object per host) in the same RBD pool. +# Any host with a working path to the Ceph cluster can write/read this object, +# which gives the same semantics as the NFS/SharedMountPoint heartbeat file. + +help() { + printf "Usage: $0 + -s ceph monitor host(s), comma separated + -o ceph/rbd pool name + -n cephx auth user (optional) + -k cephx auth key, base64 (optional, required if -n is set) + -h host + -r write/read hb log + -c cleanup + -t interval between read hb log\n" + exit 1 +} +#set -x +MonHosts= +PoolName= +CephUser= +CephKey= +HostIP= +interval= +rflag=0 +cflag=0 + +while getopts 's:o:n:k:h:t:rc' OPTION +do + case $OPTION in + s) + MonHosts="$OPTARG" + ;; + o) + PoolName="$OPTARG" + ;; + n) + CephUser="$OPTARG" + ;; + k) + CephKey="$OPTARG" + ;; + h) + HostIP="$OPTARG" + ;; + r) + rflag=1 + ;; + t) + interval="$OPTARG" + ;; + c) + cflag=1 + ;; + *) + help + ;; + esac +done + +if [ -z "$MonHosts" ] || [ -z "$PoolName" ] +then + exit 1 +fi + +# the host IP names the heartbeat object, so it is required except for the self-fencing (-c) +if [ "$cflag" != "1" ] && [ -z "$HostIP" ] +then + exit 1 +fi + +if [ -n "$CephUser" ] && [ -z "$CephKey" ] +then + exit 1 +fi + +RadosOpts=(--mon-host "$MonHosts") +if [ -n "$CephUser" ] +then + RadosOpts+=(--id "$CephUser" --key "$CephKey") +fi Review Comment: The key is now masked in the agent log and given to rados/rbd in a temporary mode-600 keyfile, so it is no longer in their arguments. It is still an argument of this script (and KVMStorageProcessor passes it the same way for RBD snapshot sizes). Passing it through the environment is possible as a follow-up. -- 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]
