-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parents to varnish cache #7669
Changes from 4 commits
2fc572e
7b4a027
6a59baa
6a5c26a
312c673
fc55c79
c42d0d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cfgfile | ||
|
||
import ( | ||
"github.com/apache/trafficcontrol/cache-config/t3c-generate/config" | ||
"github.com/apache/trafficcontrol/cache-config/t3cutil" | ||
"github.com/apache/trafficcontrol/lib/varnishcfg" | ||
) | ||
|
||
/* | ||
* 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. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. license header should go above imports, below package declaration |
||
|
||
// GetVarnishConfigs returns varnish configuration files | ||
// TODO: add varnishncsa and hitch configs | ||
func GetVarnishConfigs(toData *t3cutil.ConfigData, cfg config.Cfg) ([]t3cutil.ATSConfigFile, error) { | ||
vclBuilder := varnishcfg.NewVCLBuilder(toData) | ||
vcl, warnings, err := vclBuilder.BuildVCLFile() | ||
logWarnings("Generating varnish configuration files: ", warnings) | ||
|
||
configs := make([]t3cutil.ATSConfigFile, 0) | ||
// TODO: should be parameterized and generated from varnishcfg | ||
configs = append(configs, t3cutil.ATSConfigFile{ | ||
Name: "default.vcl", | ||
Text: vcl, | ||
Path: cfg.Dir, | ||
ContentType: "text/plain; charset=us-ascii", | ||
LineComment: "//", | ||
Secure: false, | ||
}) | ||
return configs, err | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,9 @@ COPY ./traffic_ops/toclientlib/ /go/src/github.com/apache/trafficcontrol/traffic | |
COPY ./traffic_ops/v4-client/ /go/src/github.com/apache/trafficcontrol/traffic_ops/v4-client/ | ||
COPY ./infrastructure/cdn-in-a-box/ /go/src/github.com/apache/trafficcontrol/infrastructure/cdn-in-a-box/ | ||
|
||
# varnishcfg requires t3c for ToData struct and not needed for enroller | ||
RUN rm -rf /go/src/github.com/apache/trafficcontrol/lib/varnishcfg | ||
|
||
Comment on lines
+45
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't worry about it; the enroller is pulling in a lot of things it doesn't strictly need. We can evaluate it if it becomes a problem, and try to clean it up a bit, but varnishcfg is small compared to the rest of the cruft so there's no point worrying about it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the comment can be improved, but it is not removed for optimization reasons. if we remove this line it won't be able to build the enroller binary because |
||
WORKDIR /go/src/github.com/apache/trafficcontrol/infrastructure/cdn-in-a-box/enroller | ||
RUN set -o errexit -o nounset; \ | ||
go clean; \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# 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. | ||
|
||
ARG BASE_IMAGE=rockylinux \ | ||
RHEL_VERSION=8 | ||
FROM ${BASE_IMAGE}:${RHEL_VERSION} AS common-varnish-cache-config-layers | ||
ARG RHEL_VERSION=8 | ||
# Makes RHEL_VERSION available at runtime | ||
ENV RHEL_VERSION="$RHEL_VERSION" | ||
|
||
RUN dnf module disable varnish -y && yum install -y epel-release | ||
|
||
RUN curl -s https://packagecloud.io/install/repositories/varnishcache/varnish73/script.rpm.sh | bash | ||
|
||
RUN yum install varnish-7.3.0-1.el8.x86_64 -y | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you really want to pin down to a specific release like that? If there's a major security bug that gets fixed with no breaking changes in v7.3.0-2 then we'd have to update this script. Also not sure it's a good idea to hard-code the CPU architecture; a lot of ATC devs use Macs, for example, and their new chipset isn't x86_64. |
||
|
||
RUN dnf install -y bind-utils kyotocabinet-libs initscripts iproute net-tools nmap-ncat gettext autoconf automake libtool gcc-c++ cronie glibc-devel openssl-devel git perl && \ | ||
dnf install -y jq logrotate findutils && \ | ||
dnf clean all | ||
|
||
|
||
COPY infrastructure/cdn-in-a-box/varnish/run.sh infrastructure/cdn-in-a-box/traffic_ops/to-access.sh infrastructure/cdn-in-a-box/enroller/server_template.json / | ||
|
||
COPY infrastructure/cdn-in-a-box/dns/set-dns.sh \ | ||
infrastructure/cdn-in-a-box/dns/insert-self-into-dns.sh \ | ||
/usr/local/sbin/ | ||
|
||
|
||
COPY infrastructure/cdn-in-a-box/varnish/systemctl.sh /usr/bin/systemctl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it absolutely necessary to use systemd? Doing that in a Docker container is prone to problems and headaches There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
|
||
ARG ORT_RPM=infrastructure/cdn-in-a-box/cache/trafficcontrol-cache-config.rpm | ||
COPY $ORT_RPM / | ||
RUN rpm -Uvh /$(basename $ORT_RPM) &&\ | ||
rm /$(basename $ORT_RPM) | ||
|
||
COPY infrastructure/cdn-in-a-box/varnish/traffic_ops_ort.crontab /etc/cron.d/traffic_ops_ort-cron-template | ||
|
||
|
||
CMD /run.sh | ||
|
||
FROM common-varnish-cache-config-layers AS mid | ||
ENV CACHE_TYPE=mid | ||
COPY infrastructure/cdn-in-a-box/mid/init.d/ /opt/init.d/ | ||
|
||
FROM common-varnish-cache-config-layers AS edge | ||
ENV CACHE_TYPE=edge | ||
COPY infrastructure/cdn-in-a-box/edge/init.d/ /opt/init.d/ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be relying on
varnishreload
being in the running user's$PATH
- with ATS cache servers we typically install everything under/opt/trafficserver
(not that I think that's a good idea, personally) but it seems like that won't work for varnish caches if everything winds up installed under e.g./opt/varnish
. Or, at least, not without some extra work. Is that intentional, or is there some reason why it wouldn't findvarnishreload
in the same directory as thevarnish
binary?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is done that way because Varnish currently is installed under root. So,
varnishreload
is currently installed in user's$PATH
. It will be a problem indeed if Varnish is installed under different directory. Should Varnish be installed under different directory?