#!/usr/bin/env bash# Copyright 2021 The Rook Authors. All rights reserved.## Licensed 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.set -xeEo pipefail############## VARIABLES ##############: "${BLOCK:=$(sudo lsblk --paths | awk '/14G/ {print 1ドル}' | head -1)}"NETWORK_ERROR="connection reset by peer"SERVICE_UNAVAILABLE_ERROR="Service Unavailable"INTERNAL_ERROR="INTERNAL_ERROR"INTERNAL_SERVER_ERROR="500 Internal Server Error"############## FUNCTIONS ##############function install_deps() {sudo wget https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64 -O /usr/local/bin/yqsudo chmod +x /usr/local/bin/yq}function print_k8s_cluster_status() {kubectl cluster-infokubectl get pods -n kube-system}function use_local_disk() {BLOCK_DATA_PART=${BLOCK}1sudo dmsetup version || truesudo swapoff --all --verboseif mountpoint -q /mnt; thensudo umount /mnt# search for the device since it keeps changing between sda and sdbsudo wipefs --all --force "$BLOCK_DATA_PART"else# it's the hosted runner!sudo sgdisk --zap-all --clear --mbrtogpt -g -- "${BLOCK}"sudo dd if=/dev/zero of="${BLOCK}" bs=1M count=10 oflag=directsudo parted -s "${BLOCK}" mklabel gptfisudo lsblk}function use_local_disk_for_integration_test() {sudo udevadm control --log-priority=debugsudo swapoff --all --verbosesudo umount /mntsudo sed -i.bak '/\/mnt/d' /etc/fstab# search for the device since it keeps changing between sda and sdbPARTITION="${BLOCK}1"sudo wipefs --all --force "$PARTITION"sudo dd if=/dev/zero of="${PARTITION}" bs=1M count=1sudo lsblk --bytes# add a udev rule to force the disk partitions to ceph# we have observed that some runners keep detaching/re-attaching the additional disk overriding the permissions to the default root:disk# for more details see: https://github.com/rook/rook/issues/7405echo "SUBSYSTEM==\"block\", ATTR{size}==\"29356032\", ACTION==\"add\", RUN+=\"/bin/chown 167:167 $PARTITION\"" | sudo tee -a /etc/udev/rules.d/01-rook.rules# for below, see: https://access.redhat.com/solutions/1465913block_base="$(basename "${BLOCK}")"echo "ACTION==\"add|change\", KERNEL==\"${block_base}\", OPTIONS:=\"nowatch\"" | sudo tee -a /etc/udev/rules.d/99-z-rook-nowatch.rules# The partition is still getting reloaded occasionally during operation. See https://github.com/rook/rook/issues/8975# Try issuing some disk-inspection commands to jog the system so it won't reload the partitions# during OSD provisioning.sudo udevadm control --reload-rules || truesudo udevadm trigger || truetime sudo udevadm settle || truesudo partprobe || truesudo lsblk --noheadings --pairs "${BLOCK}" || truesudo sgdisk --print "${BLOCK}" || truesudo udevadm info --query=property "${BLOCK}" || truesudo lsblk --noheadings --pairs "${PARTITION}" || truejournalctl -o short-precise --dmesg | tail -40 || truecat /etc/fstab || true}function create_partitions_for_osds() {tests/scripts/create-bluestore-partitions.sh --disk "$BLOCK" --osd-count 2sudo lsblk}function create_bluestore_partitions_and_pvcs() {BLOCK_PART="$BLOCK"2DB_PART="$BLOCK"1tests/scripts/create-bluestore-partitions.sh --disk "$BLOCK" --bluestore-type block.db --osd-count 1tests/scripts/localPathPV.sh "$BLOCK_PART" "$DB_PART"}function create_bluestore_partitions_and_pvcs_for_wal(){BLOCK_PART="$BLOCK"3DB_PART="$BLOCK"1WAL_PART="$BLOCK"2tests/scripts/create-bluestore-partitions.sh --disk "$BLOCK" --bluestore-type block.wal --osd-count 1tests/scripts/localPathPV.sh "$BLOCK_PART" "$DB_PART" "$WAL_PART"}function collect_udev_logs_in_background() {local log_dir="${1:-"/home/runner/work/rook/rook/tests/integration/_output/tests"}"mkdir -p "${log_dir}"udevadm monitor --property &> "${log_dir}"/udev-monitor-property.txt &udevadm monitor --kernel &> "${log_dir}"/udev-monitor-kernel.txt &udevadm monitor --udev &> "${log_dir}"/udev-monitor-udev.txt &}function build_rook() {build_type=buildif [ -n "1ドル" ]; thenbuild_type=1ドルfiGOPATH=$(go env GOPATH) make cleanfor _ in $(seq 1 3); doif ! o=$(make -j"$(nproc)" IMAGES='ceph' "$build_type"); thencase "$o" in*"$NETWORK_ERROR"*)echo "network failure occurred, retrying..."continue;;*"$SERVICE_UNAVAILABLE_ERROR"*)echo "network failure occurred, retrying..."continue;;*"$INTERNAL_ERROR"*)echo "network failure occurred, retrying..."continue;;*"$INTERNAL_SERVER_ERROR"*)echo "network failure occurred, retrying..."continue;;*)# valid failureexit 1esacfi# no errors so we break the loop after the first iterationbreakdone# validate buildtests/scripts/validate_modified_files.sh builddocker imagesif [[ "$build_type" == "build" ]]; thendocker tag "$(docker images | awk '/build-/ {print 1ドル}')" rook/ceph:local-buildfi}function build_rook_all() {build_rook build.all}function validate_yaml() {cd cluster/examples/kubernetes/ceph# create the Rook CRDs and other resourceskubectl create -f crds.yaml -f common.yaml# create the volume replication CRDsreplication_version=v0.1.0replication_url="https://raw.githubusercontent.com/csi-addons/volume-replication-operator/${replication_version}/config/crd/bases"kubectl create -f "${replication_url}/replication.storage.openshift.io_volumereplications.yaml"kubectl create -f "${replication_url}/replication.storage.openshift.io_volumereplicationclasses.yaml"# skipping folders and some yamls that are only for openshift.manifests="$(find . -maxdepth 1 -type f -name '*.yaml' -and -not -name '*openshift*' -and -not -name 'scc*')"with_f_arg="$(echo "$manifests" | awk '{printf " -f %s",1ドル}')" # don't add newline# shellcheck disable=SC2086 # '-f manifest1.yaml -f manifest2.yaml etc.' should not be quotedkubectl create ${with_f_arg} --dry-run=client}function create_cluster_prerequisites() {# this might be called from another function that has already done a cd( cd cluster/examples/kubernetes/ceph && kubectl create -f crds.yaml -f common.yaml )}function deploy_manifest_with_local_build() {if [[ "$USE_LOCAL_BUILD" != "false" ]]; thensed -i "s|image: rook/ceph:.*|image: rook/ceph:local-build|g" 1ドルfikubectl create -f 1ドル}function deploy_cluster() {cd cluster/examples/kubernetes/cephdeploy_manifest_with_local_build operator.yamlsed -i "s|#deviceFilter:|deviceFilter: ${BLOCK/\/dev\/}|g" cluster-test.yamlkubectl create -f cluster-test.yamlkubectl create -f object-test.yamlkubectl create -f pool-test.yamlkubectl create -f filesystem-test.yamlkubectl create -f rbdmirror.yamlkubectl create -f filesystem-mirror.yamlkubectl create -f nfs-test.yamldeploy_manifest_with_local_build toolbox.yaml}function wait_for_prepare_pod() {get_pod_cmd=(kubectl --namespace rook-ceph get pod --no-headers)timeout=450start_time="${SECONDS}"while [[ $(( SECONDS - start_time )) -lt $timeout ]]; dopod="$("${get_pod_cmd[@]}" --selector=app=rook-ceph-osd-prepare --output custom-columns=NAME:.metadata.name,PHASE:status.phase | awk 'FNR <= 1')"if echo "$pod" | grep 'Running\|Succeeded\|Failed'; then break; fiecho 'waiting for at least one osd prepare pod to be running or finished'sleep 5donepod="$("${get_pod_cmd[@]}" --selector app=rook-ceph-osd-prepare --output name | awk 'FNR <= 1')"kubectl --namespace rook-ceph logs --follow "$pod"timeout=60start_time="${SECONDS}"while [[ $(( SECONDS - start_time )) -lt $timeout ]]; dopod="$("${get_pod_cmd[@]}" --selector app=rook-ceph-osd,ceph_daemon_id=0 --output custom-columns=NAME:.metadata.name,PHASE:status.phase)"if echo "$pod" | grep 'Running'; then break; fiecho 'waiting for OSD 0 pod to be running'sleep 1done# getting the below logs is a best-effort attempt, so use '|| true' to allow failurespod="$("${get_pod_cmd[@]}" --selector app=rook-ceph-osd,ceph_daemon_id=0 --output name)" || truekubectl --namespace rook-ceph logs "$pod" || truejob="$(kubectl --namespace rook-ceph get job --selector app=rook-ceph-osd-prepare --output name | awk 'FNR <= 1')" || truekubectl -n rook-ceph describe "$job" || truekubectl -n rook-ceph describe deployment/rook-ceph-osd-0 || true}function wait_for_ceph_to_be_ready() {DAEMONS=1ドルOSD_COUNT=2ドルmkdir testtests/scripts/validate_cluster.sh "$DAEMONS" "$OSD_COUNT"kubectl -n rook-ceph get pods}function check_ownerreferences() {curl -L https://github.com/kubernetes-sigs/kubectl-check-ownerreferences/releases/download/v0.2.0/kubectl-check-ownerreferences-linux-amd64.tar.gz -o kubectl-check-ownerreferences-linux-amd64.tar.gztar xzvf kubectl-check-ownerreferences-linux-amd64.tar.gzchmod +x kubectl-check-ownerreferences./kubectl-check-ownerreferences -n rook-ceph}function create_LV_on_disk() {sudo sgdisk --zap-all "${BLOCK}"VG=test-rook-vgLV=test-rook-lvsudo pvcreate "$BLOCK"sudo vgcreate "$VG" "$BLOCK" || sudo vgcreate "$VG" "$BLOCK" || sudo vgcreate "$VG" "$BLOCK"sudo lvcreate -l 100%FREE -n "${LV}" "${VG}"tests/scripts/localPathPV.sh /dev/"${VG}"/${LV}kubectl create -f cluster/examples/kubernetes/ceph/crds.yamlkubectl create -f cluster/examples/kubernetes/ceph/common.yaml}function deploy_first_rook_cluster() {BLOCK=$(sudo lsblk|awk '/14G/ {print 1ドル}'| head -1)create_cluster_prerequisitescd cluster/examples/kubernetes/ceph/deploy_manifest_with_local_build operator.yamlyq w -i -d1 cluster-test.yaml spec.dashboard.enabled falseyq w -i -d1 cluster-test.yaml spec.storage.useAllDevices falseyq w -i -d1 cluster-test.yaml spec.storage.deviceFilter "${BLOCK}"1kubectl create -f cluster-test.yamldeploy_manifest_with_local_build toolbox.yaml}function deploy_second_rook_cluster() {BLOCK=$(sudo lsblk|awk '/14G/ {print 1ドル}'| head -1)cd cluster/examples/kubernetes/ceph/NAMESPACE=rook-ceph-secondary envsubst < common-second-cluster.yaml | kubectl create -f -sed -i 's/namespace: rook-ceph/namespace: rook-ceph-secondary/g' cluster-test.yamlyq w -i -d1 cluster-test.yaml spec.storage.deviceFilter "${BLOCK}"2yq w -i -d1 cluster-test.yaml spec.dataDirHostPath "/var/lib/rook-external"kubectl create -f cluster-test.yamlyq w -i toolbox.yaml metadata.namespace rook-ceph-secondarydeploy_manifest_with_local_build toolbox.yaml toolbox.yaml}function wait_for_rgw() {for _ in {1..120}; doif [ "$(kubectl -n "1ドル" get pod -l app=rook-ceph-rgw --no-headers --field-selector=status.phase=Running|wc -l)" -ge 1 ] ; thenecho "rgw pod is found"breakfiecho "waiting for rgw pods"sleep 5donefor _ in {1..120}; doif [ "$(kubectl -n "1ドル" get deployment -l app=rook-ceph-rgw -o yaml | yq read - 'items[0].status.readyReplicas')" -ge 1 ] ; thenecho "rgw is ready"breakfiecho "waiting for rgw becomes ready"sleep 5done}function verify_operator_log_message() {local message="1ドル" # param 1: the message to verify existslocal namespace="${2:-rook-ceph}" # optional param 2: the namespace of the CephCluster (default: rook-ceph)kubectl --namespace "$namespace" logs deployment/rook-ceph-operator | grep "$message"}function wait_for_operator_log_message() {local message="1ドル" # param 1: the message to look forlocal timeout="2ドル" # param 2: the timeout for waiting for the message to existlocal namespace="${3:-rook-ceph}" # optional param 3: the namespace of the CephCluster (default: rook-ceph)start_time="${SECONDS}"while [[ $(( SECONDS - start_time )) -lt $timeout ]]; doif verify_operator_log_message "$message" "$namespace"; then return 0; fisleep 5doneecho "timed out" >&2 && return 1}function restart_operator () {local namespace="${1:-rook-ceph}" # optional param 1: the namespace of the CephCluster (default: rook-ceph)kubectl --namespace "$namespace" delete pod --selector app=rook-ceph-operator# wait for new pod to be runningget_pod_cmd=(kubectl --namespace "$namespace" get pod --selector app=rook-ceph-operator --no-headers)timeout 20 bash -c \"until [[ -n \"\$(${get_pod_cmd[*]} --field-selector=status.phase=Running 2>/dev/null)\" ]] ; do echo waiting && sleep 1; done""${get_pod_cmd[@]}"}function write_object_to_cluster1_read_from_cluster2() {cd cluster/examples/kubernetes/ceph/echo "[default]" > s3cfgecho "host_bucket = no.way.in.hell" >> ./s3cfgecho "use_https = False" >> ./s3cfgfallocate -l 1M ./1M.datecho "hello world" >> ./1M.datCLUSTER_1_IP_ADDR=$(kubectl -n rook-ceph get svc rook-ceph-rgw-multisite-store -o jsonpath="{.spec.clusterIP}")BASE64_ACCESS_KEY=$(kubectl -n rook-ceph get secrets realm-a-keys -o jsonpath="{.data.access-key}")BASE64_SECRET_KEY=$(kubectl -n rook-ceph get secrets realm-a-keys -o jsonpath="{.data.secret-key}")ACCESS_KEY=$(echo ${BASE64_ACCESS_KEY} | base64 --decode)SECRET_KEY=$(echo ${BASE64_SECRET_KEY} | base64 --decode)s3cmd -v -d --config=s3cfg --access_key=${ACCESS_KEY} --secret_key=${SECRET_KEY} --host=${CLUSTER_1_IP_ADDR} mb s3://bkts3cmd -v -d --config=s3cfg --access_key=${ACCESS_KEY} --secret_key=${SECRET_KEY} --host=${CLUSTER_1_IP_ADDR} put ./1M.dat s3://bktCLUSTER_2_IP_ADDR=$(kubectl -n rook-ceph-secondary get svc rook-ceph-rgw-zone-b-multisite-store -o jsonpath="{.spec.clusterIP}")timeout 60 bash <<EOFuntil s3cmd -v -d --config=s3cfg --access_key=${ACCESS_KEY} --secret_key=${SECRET_KEY} --host=${CLUSTER_2_IP_ADDR} get s3://bkt/1M.dat 1M-get.dat --force; doecho "waiting for object to be replicated"sleep 5doneEOFdiff 1M.dat 1M-get.dat}function create_helm_tag() {helm_tag="$(cat _output/version)"build_image="$(docker images | awk '/build-/ {print 1ドル}')"docker tag "${build_image}" "rook/ceph:${helm_tag}"}FUNCTION="1ドル"shift # remove function arg now that we've recorded it# call the function with the remainder of the user-provided args# -e, -E, and -o=pipefail will ensure this script returns a failure if a part of the function fails$FUNCTION "$@"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。