diff --git a/pkg/es/config/config.go b/pkg/es/config/config.go index 28f9ae901df..ebe729c3ed3 100644 --- a/pkg/es/config/config.go +++ b/pkg/es/config/config.go @@ -466,7 +466,6 @@ func addLoggerOptions(options []elastic.ClientOptionFunc, logLevel string) ([]el prodConfig := zap.NewProductionConfig() var lvl zapcore.Level - var loggerOpts []zapgrpc.Option var setLogger func(logger elastic.Logger) elastic.ClientOptionFunc switch logLevel { @@ -490,7 +489,7 @@ func addLoggerOptions(options []elastic.ClientOptionFunc, logLevel string) ([]el } // Elastic client requires a "Printf"-able logger. - l := zapgrpc.NewLogger(esLogger, loggerOpts...) + l := zapgrpc.NewLogger(esLogger) options = append(options, setLogger(l)) return options, nil } diff --git a/plugin/storage/cassandra/schema/create.sh b/plugin/storage/cassandra/schema/create.sh index 76fef2ab68e..1c0d1377b5d 100755 --- a/plugin/storage/cassandra/schema/create.sh +++ b/plugin/storage/cassandra/schema/create.sh @@ -12,6 +12,7 @@ function usage { >&2 echo " DEPENDENCIES_TTL - time to live for dependencies data, in seconds (default: 0, no TTL)" >&2 echo " KEYSPACE - keyspace (default: jaeger_v1_{datacenter})" >&2 echo " REPLICATION_FACTOR - replication factor for prod (default: 2 for prod, 1 for test)" + >&2 echo " VERSION - Cassandra backend version, 3 or 4 (default: 4). Ignored if template is is provided." >&2 echo "" >&2 echo "The template-file argument must be fully qualified path to a v00#.cql.tmpl template file." >&2 echo "If omitted, the template file with the highest available version will be used." @@ -20,17 +21,7 @@ function usage { trace_ttl=${TRACE_TTL:-172800} dependencies_ttl=${DEPENDENCIES_TTL:-0} - -# Extract cassandra version -# -# $ cqlsh -e "show version" -# [cqlsh 5.0.1 | Cassandra 3.11.11 | CQL spec 3.4.4 | Native protocol v4] -# -cas_version=$(cqlsh -e "show version" \ - | awk -F "|" '{print $2}' \ - | awk -F " " '{print $2}' \ - | awk -F "." '{print $1}' \ -) +cas_version=${VERSION:-4} template=$1 if [[ "$template" == "" ]]; then @@ -54,7 +45,7 @@ elif [[ "$MODE" == "prod" ]]; then datacenter=$DATACENTER replication_factor=${REPLICATION_FACTOR:-2} replication="{'class': 'NetworkTopologyStrategy', '$datacenter': '${replication_factor}' }" -elif [[ "$MODE" == "test" ]]; then +elif [[ "$MODE" == "test" ]]; then datacenter=${DATACENTER:-'test'} replication_factor=${REPLICATION_FACTOR:-1} replication="{'class': 'SimpleStrategy', 'replication_factor': '${replication_factor}'}" diff --git a/plugin/storage/cassandra/schema/docker.sh b/plugin/storage/cassandra/schema/docker.sh index ca812fb2011..69da932244d 100755 --- a/plugin/storage/cassandra/schema/docker.sh +++ b/plugin/storage/cassandra/schema/docker.sh @@ -14,15 +14,18 @@ MODE=${MODE:-"test"} TEMPLATE=${TEMPLATE:-""} USER=${CASSANDRA_USERNAME:-""} PASSWORD=${CASSANDRA_PASSWORD:-""} +SCHEMA_SCRIPT=${SCHEMA_SCRIPT:-"/cassandra-schema/create.sh"} + +CQLSH_CMD="${CQLSH} ${CQLSH_SSL} ${CQLSH_HOST} ${CQLSH_PORT}" +if [ ! -z "$PASSWORD" ]; then + CQLSH_CMD="${CQLSH_CMD} -u ${USER} -p ${PASSWORD}" +fi total_wait=0 while true do - if [ -z "$PASSWORD" ]; then - ${CQLSH} ${CQLSH_SSL} ${CQLSH_HOST} ${CQLSH_PORT} -e "describe keyspaces" - else - ${CQLSH} ${CQLSH_SSL} ${CQLSH_HOST} ${CQLSH_PORT} -u ${USER} -p ${PASSWORD} -e "describe keyspaces" - fi + echo "Checking if Cassandra is up at ${CQLSH_HOST}:${CQLSH_PORT}." + ${CQLSH_CMD} -e "describe keyspaces" if (( $? == 0 )); then break else @@ -36,11 +39,20 @@ do fi done -echo "Generating the schema for the keyspace ${KEYSPACE} and datacenter ${DATACENTER}" +# Extract cassandra version +# +# $ cqlsh -e "show version" +# [cqlsh 5.0.1 | Cassandra 3.11.11 | CQL spec 3.4.4 | Native protocol v4] +VERSION= +if [ -z "$TEMPLATE" ]; then + VERSION=$(${CQLSH_CMD} -e "show version" \ + | awk -F "|" '{print $2}' \ + | awk -F " " '{print $2}' \ + | awk -F "." '{print $1}' \ + ) + echo "Cassandra version detected: ${VERSION}" +fi +echo "Generating the schema for the keyspace ${KEYSPACE} and datacenter ${DATACENTER}." -if [ -z "$PASSWORD" ]; then - MODE="${MODE}" DATACENTER="${DATACENTER}" KEYSPACE="${KEYSPACE}" /cassandra-schema/create.sh "${TEMPLATE}" | ${CQLSH} ${CQLSH_SSL} ${CQLSH_HOST} ${CQLSH_PORT} -else - MODE="${MODE}" DATACENTER="${DATACENTER}" KEYSPACE="${KEYSPACE}" /cassandra-schema/create.sh "${TEMPLATE}" | ${CQLSH} ${CQLSH_SSL} ${CQLSH_HOST} ${CQLSH_PORT} -u ${USER} -p ${PASSWORD} -fi +MODE="${MODE}" DATACENTER="${DATACENTER}" KEYSPACE="${KEYSPACE}" VERSION="${VERSION}" ${SCHEMA_SCRIPT} "${TEMPLATE}" | ${CQLSH_CMD}