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 2020/04/28 02:29:01 UTC

[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #4663: Add readiness container to ciab

ocket8888 commented on a change in pull request #4663:
URL: https://github.com/apache/trafficcontrol/pull/4663#discussion_r416278916



##########
File path: infrastructure/cdn-in-a-box/readiness/run.sh
##########
@@ -0,0 +1,59 @@
+#!/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.
+
+start_time=$(date +%s)
+
+source to-access.sh
+
+set-dns.sh
+insert-self-into-dns.sh

Review comment:
       This is intended to be a short-lived container that other components don't make requests to, right? So why does it need to insert itself into the DNS records of the dns container?

##########
File path: infrastructure/cdn-in-a-box/readiness/run.sh
##########
@@ -0,0 +1,59 @@
+#!/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.
+

Review comment:
       This should `set -x` so it stops if e.g. `set-dns.sh` fails.

##########
File path: infrastructure/cdn-in-a-box/docker-compose.readiness.yml
##########
@@ -0,0 +1,51 @@
+# 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.
+
+# This docker-compose file starts a readiness service that will exit
+# successfully when it is able to successfully curl all delivery
+# service example URLs.
+#
+# For example:
+#
+#     docker-compose -f docker-compose.yml -f docker-compose.readiness.yml up
+#
+# Or, start up the main services in the background and run the readiness
+# service in the foreground:
+#
+#     docker-compose up -d
+#     docker-compose -f docker-compose.readiness.yml up
+
+---
+version: '2.1'
+
+services:
+  readiness:
+    build:
+      context: ../..
+      dockerfile: infrastructure/cdn-in-a-box/readiness/Dockerfile
+    env_file:
+      - variables.env
+    hostname: readiness
+    domainname: infra.ciab.test
+    volumes:
+      - shared:/shared

Review comment:
       Does it need the shared volume? Maybe for certs? I'm not sure, just wondering if you know.

##########
File path: infrastructure/cdn-in-a-box/readiness/run.sh
##########
@@ -0,0 +1,59 @@
+#!/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.
+
+start_time=$(date +%s)
+
+source to-access.sh
+
+set-dns.sh
+insert-self-into-dns.sh
+
+while ! to-ping 2>/dev/null; do
+   echo waiting for trafficops
+   sleep 3
+done
+
+while true; do
+    sleep 3
+    exampleURLs=($(to-get /api/${TO_API_VERSION}/deliveryservices | jq -r '.response[].exampleURLs[]'))
+    if [[ "${#exampleURLs[@]}" -eq 0 ]]; then
+        echo waiting for delivery service example URLs
+        continue
+    else
+        echo "example URLs: '${exampleURLs[@]}'"
+        success="true"
+        for u in "${exampleURLs[@]}"; do
+            status=$(curl -Lkvs --connect-timeout 2 -m5 -o /dev/null -w "%{http_code}" "$u")
+            if [[ "$status" -ne 200 ]]; then
+                echo "failed to curl delivery service example URL '$u' got status code '$status'"
+                success="false"
+                break
+            else
+                echo "successfully curled delivery service example URL '$u'"
+            fi
+        done
+        if [[ "$success" == "true" ]]; then
+            echo "successfully curled all delivery service example URLs '${exampleURLs[@]}'"
+            break
+        fi
+    fi

Review comment:
       Yeah, see, this is why I gotta stop you here. You were going <kbd>&nbsp;</kbd> in a <kbd>⭾</kbd> zone. That's gonna be a $80 fine or you can take it up with the 3<sup>rd</sup> Circuit Court of Best Practices. Take care now, and watch your indentation.

##########
File path: infrastructure/cdn-in-a-box/readiness/Dockerfile
##########
@@ -0,0 +1,34 @@
+# 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.
+
+FROM alpine:3.11
+
+RUN apk add --no-cache --update \
+  curl \
+  bind-tools \
+  net-tools \
+  jq \
+  bash
+
+# MANIFEST
+# to-access.sh (sourced, get to-get and env vars)
+# run.sh       (wait on TO, then to-get deliveryservices, then curl the exampleURLs)
+COPY ./infrastructure/cdn-in-a-box/traffic_ops/to-access.sh /opt/readiness/
+COPY ./infrastructure/cdn-in-a-box/readiness/run.sh /opt/readiness/

Review comment:
       You can do this in one line to save a cache layer: `COPY file [files...] destination`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org