You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/08/08 13:56:36 UTC
[GitHub] dewrich closed pull request #2641: fix cdn-in-a-box issues;
add comments
dewrich closed pull request #2641: fix cdn-in-a-box issues; add comments
URL: https://github.com/apache/trafficcontrol/pull/2641
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/infrastructure/cdn-in-a-box/docker-compose.yml b/infrastructure/cdn-in-a-box/docker-compose.yml
index c8c4dbc64..14e0bc104 100644
--- a/infrastructure/cdn-in-a-box/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/docker-compose.yml
@@ -157,6 +157,9 @@ services:
- tcnet
ports:
- "8010:80"
+
+ # Apache Traffic Server (ATS) caches defined here
+ # edge cache
edge:
build:
context: edge
@@ -169,6 +172,7 @@ services:
ports:
- "8080:80"
+ # mid cache
mid:
build:
context: mid
@@ -181,6 +185,7 @@ services:
ports:
- "8081:80"
+ # origin provides the content to be distributed through the CDN caches
origin:
build:
context: origin
diff --git a/infrastructure/cdn-in-a-box/to-access.sh b/infrastructure/cdn-in-a-box/to-access.sh
new file mode 100644
index 000000000..87514fc86
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/to-access.sh
@@ -0,0 +1,90 @@
+#!/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.
+#
+# Defines bash functions to consistently interact with the Traffic Ops API
+
+
+export TO_URL TO_ADMIN_USER TO_ADMIN_PASSWORD
+export CURLOPTS=${CURLOPTS:--L}
+export CURLAUTH=${CURLAUTH:--k}
+export COOKIEJAR=$(mktemp -t XXXX.cookie)
+
+TO_URL=https://$TO_HOST:$TO_PORT
+
+login=$(mktemp -t XXXX.login)
+
+cleanup() {
+ rm -f "$COOKIEJAR" "$login"
+}
+
+trap cleanup EXIT
+
+cookie_current() {
+ local cookiefile=$1
+ [[ -s $cookiefile ]] || return 1
+
+ # get expiration from cookiejar -- compare to current time
+ exp=$(awk '/mojolicious/ {print $5}' $cookiefile | tail -n 1)
+ cur=$(date +%s)
+
+ # return value is the comparison itself
+ (( $exp > $cur ))
+}
+
+to-auth() {
+ # These are required
+ if [[ -z $TO_URL || -z $TO_ADMIN_USER || -z $TO_ADMIN_PASSWORD ]]; then
+ echo TO_URL TO_ADMIN_USER TO_ADMIN_PASSWORD must all be set
+ return 1
+ fi
+
+ # if cookiejar is current, nothing to do..
+ cookie_current $COOKIEJAR && return
+
+ local url=$TO_URL/api/1.3/user/login
+ local datatype='Accept: application/json'
+ cat >"$login" <<-CREDS
+{ "u" : "$TO_ADMIN_USER", "p" : "$TO_ADMIN_PASSWORD" }
+CREDS
+ res=$(curl $CURLAUTH $CURLOPTS -H "$datatype" --cookie "$COOKIEJAR" --cookie-jar "$COOKIEJAR" -X POST --data @"$login" "$url")
+ if [[ $res != *"Successfully logged in."* ]]; then
+ echo "Login failed: $res"
+ return 1
+ fi
+}
+
+to-get() {
+ to-auth && \
+ curl $CURLAUTH $CURLOPTS -s --cookie "$COOKIEJAR" -X GET "$TO_URL/$1"
+}
+
+to-post() {
+ to-auth && \
+ curl $CURLAUTH $CURLOPTS -s --cookie "$COOKIEJAR" -X POST --data @"$2" "$TO_URL/$1"
+}
+
+to-put() {
+ to-auth && \
+ curl $CURLAUTH $CURLOPTS -s --cookie "$COOKIEJAR" -X PUT --data @"$2" "$TO_URL/$1"
+}
+
+to-delete() {
+ to-auth && \
+ curl $CURLAUTH $CURLOPTS -s --cookie "$COOKIEJAR" -X DELETE "$TO_URL/$1"
+}
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/run.sh b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
index 453578787..8cd5051dc 100755
--- a/infrastructure/cdn-in-a-box/traffic_ops/run.sh
+++ b/infrastructure/cdn-in-a-box/traffic_ops/run.sh
@@ -25,7 +25,6 @@
#
# DB_SERVER
# DB_PORT
-# DB_ROOT_PASS
# DB_USER
# DB_USER_PASS
# DB_NAME
@@ -40,7 +39,7 @@
# TODO: Unused -- should be removed? TRAFFIC_VAULT_PASS
# Check that env vars are set
-envvars=( DB_SERVER DB_PORT DB_ROOT_PASS DB_USER DB_USER_PASS ADMIN_USER ADMIN_PASS CERT_COUNTRY CERT_STATE CERT_CITY CERT_COMPANY DOMAIN)
+envvars=( DB_SERVER DB_PORT DB_USER DB_USER_PASS ADMIN_USER ADMIN_PASS CERT_COUNTRY CERT_STATE CERT_CITY CERT_COMPANY DOMAIN)
for v in $envvars
do
if [[ -z $$v ]]; then echo "$v is unset"; exit 1; fi
@@ -52,8 +51,14 @@ if [[ -r /config.sh ]]; then
. /config.sh
fi
-while ! nc $DB_SERVER $DB_PORT </dev/null 2>/dev/null ; do
- echo "waiting for $DB_SERVER $DB_PORT"
+pg_isready=$(rpm -ql postgresql96 | grep bin/pg_isready)
+if [[ ! -x $pg_isready ]] ; then
+ echo "Can't find pg_ready in postgresql96"
+ exit 1
+fi
+
+while ! $pg_isready -h$DB_SERVER -p$DB_PORT -d $DB_NAME; do
+ echo "waiting for db on $DB_SERVER $DB_PORT"
sleep 3
done
@@ -65,6 +70,7 @@ export PATH=/usr/local/go/bin:/opt/traffic_ops/go/bin:$PATH
export GOPATH=/opt/traffic_ops/go
cd $TO_DIR && \
+ ./db/admin.pl --env=production reset && \
./db/admin.pl --env=production upgrade || echo "db upgrade failed!"
# Add admin user -- all other users should be created using API
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services