<commit_before>#!/bin/bash
set -e

function check_KV_IP {
: ${K8S_NETWORK:=${CEPH_CLUSTER_NETWORK}}
: ${FLANNEL_NETWORK:="10.0.0.0/8"}

# check default KV_IP, if wrong then search ip from K8S_NETWORK
if ! curl http://"${KV_IP}":"${KV_PORT}" &>/dev/null; then
    local k8s_ip=$(ip -4 -o a | awk '{ sub ("/..", "", $4); print $4 }' | grepcidr "${K8S_NETWORK}")
else
    log_success "Communicate with ETCD server using ${KV_IP}:${KV_PORT}"
    return 0
fi

# if k8s_ip still can't connect to ETCD then search FLANNEL_NETWORK
if ! curl http://${k8s_ip}:${KV_PORT} &>/dev/null; then
    local pre_flan_ip=$(ip -4 -o a | awk '{ sub ("/..", "", $4); print $4 }' | grepcidr "${FLANNEL_NETWORK}")
    local flannel_ip=$(echo ${pre_flan_ip} | awk -F "." '{ sub ($4,1); print $0 }')
else
    log_success "Communicate with ETCD server using ${k8s_ip}:${KV_PORT}"
    KV_IP=${k8s_ip}
    return 0
fi

# finally we check flannel ip then exit
if ! curl http://${flannel_ip}:${KV_PORT} &>/dev/null; then
    log_err "Can't connect to ETCD Server using the following ips. Please check network setting."
    log_err "http://${KV_IP}:${KV_PORT}"
    log_err "http://${k8s_ip}:${KV_PORT}"
    log_err "http://${flannel_ip}:${KV_PORT}"
    exit 1
else
    log_success "Communicate with ETCD server using ${flannel_ip}:${KV_PORT}"
    KV_IP=${flannel_ip}
fi
}

sed -r "s/@CLUSTER@/${CLUSTER:-ceph}/g" \
    /etc/confd/conf.d/ceph.conf.toml.in > /etc/confd/conf.d/ceph.conf.toml

# make sure etcd uses http or https as a prefix
if [[ "$KV_TYPE" == "etcd" ]]; then
  if [ ! -z "${KV_CA_CERT}" ]; then
  	CONFD_NODE_SCHEMA="https://"
  else
    CONFD_NODE_SCHEMA="http://"<commit_msg>Get ETCD Key using default gateway ip<commit_after>#!/bin/bash
set -e

function check_KV_IP {
: ${K8S_NETWORK:=${CEPH_CLUSTER_NETWORK}}

# check default KV_IP, if wrong then search ip from K8S_NETWORK
if ! curl http://"${KV_IP}":"${KV_PORT}" &>/dev/null; then
    local k8s_ip=$(ip -4 -o a | awk '{ sub ("/..", "", $4); print $4 }' | grepcidr "${K8S_NETWORK}")
else
    log_success "Communicate with ETCD server using ${KV_IP}:${KV_PORT}"
    return 0
fi

# if k8s_ip still can't connect to ETCD then search FLANNEL_NETWORK
if ! curl http://${k8s_ip}:${KV_PORT} &>/dev/null; then
    local flannel_gw=$(route | awk '/default/ {print $2 }')
else
    log_success "Communicate with ETCD server using ${k8s_ip}:${KV_PORT}"
    KV_IP=${k8s_ip}
    return 0
fi

# finally we check flannel ip then exit
if ! curl http://${flannel_gw}:${KV_PORT} &>/dev/null; then
    log_err "Can't connect to ETCD Server using the following ips. Please check network setting."
    log_err "http://${KV_IP}:${KV_PORT}"
    log_err "http://${k8s_ip}:${KV_PORT}"
    log_err "http://${flannel_gw}:${KV_PORT}"
    exit 1
else
    log_success "Communicate with ETCD server using ${flannel_gw}:${KV_PORT}"
    KV_IP=${flannel_gw}
fi
}

sed -r "s/@CLUSTER@/${CLUSTER:-ceph}/g" \
    /etc/confd/conf.d/ceph.conf.toml.in > /etc/confd/conf.d/ceph.conf.toml

# make sure etcd uses http or https as a prefix
if [[ "$KV_TYPE" == "etcd" ]]; then
  if [ ! -z "${KV_CA_CERT}" ]; then
  	CONFD_NODE_SCHEMA="https://"
  else
    CONFD_NODE_SCHEMA="http://"
{'fraction_non_alphanumeric': 0.18047244094488188, 'fraction_numerical': 0.013543307086614173, 'mean_word_length': 3.848854961832061, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7584566', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1295, 'n_words': 315}