Skip to content

Commit

Permalink
[PowerDNS] Update dependencies and force re-release (NR-303974) (#252)
Browse files Browse the repository at this point in the history
* powerdns: update dependencies and force re-release

* fix tests

* fix golangci-lint errors

* powerdns: use forked repo

* change authoritative pdns image to one that is maintained

* print logs at e2e scenario exit

* final fixes and cleanup

* upgrade go-mod for the config generator
  • Loading branch information
kilokang authored Sep 4, 2024
1 parent 7da0106 commit 2bf2f45
Show file tree
Hide file tree
Showing 20 changed files with 167 additions and 565 deletions.
31 changes: 2 additions & 29 deletions exporters/powerdns/build-exporter-linux.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
#!/bin/bash

set -euo pipefail

# ###############################################################
# Integration variables
root_dir=$1
integration_dir="${root_dir}/exporters/powerdns"
integration_bin_dir="${integration_dir}/target/bin"

# ###############################################################
# Clone exporter
tmp_dir=$(mktemp -d)
git clone --no-checkout "${EXPORTER_REPO_URL}" "${tmp_dir}"
cd "${tmp_dir}"

if [[ -z "${EXPORTER_TAG}" ]]
then
git -c advice.detachedHead=false checkout "${EXPORTER_COMMIT}"
else
git checkout "${EXPORTER_TAG}" -d
fi

IFS=',' read -r -a goarchs <<< "$PACKAGE_LINUX_GOARCHS"
for goarch in "${goarchs[@]}"
do
echo "Build exporter Linux ${goarch}"
GOARCH=${goarch} make build
mkdir -p "${integration_bin_dir}/linux_${goarch}"
cp "${tmp_dir}/powerdns_exporter" "${integration_bin_dir}/linux_${goarch}/powerdns-exporter"
done
location=$(dirname "${BASH_SOURCE[0]}")
${location}/build-exporter.sh "linux" "$@"
32 changes: 2 additions & 30 deletions exporters/powerdns/build-exporter-windows.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,5 @@
# This script is not currently used as we are not packaging
# this integration for Windows. It is kept for testing purposes.

set -euo pipefail

# ###############################################################
# Integration variables
root_dir=$1
integration_dir="${root_dir}/exporters/powerdns"
integration_bin_dir="${integration_dir}/target/bin"

# ###############################################################
# Clone exporter
tmp_dir=$(mktemp -d)
git clone --no-checkout ${EXPORTER_REPO_URL} "${tmp_dir}"
cd "${tmp_dir}"

if [[ -z $EXPORTER_TAG ]]
then
git -c advice.detachedHead=false checkout ${EXPORTER_COMMIT}
else
git checkout ${EXPORTER_TAG} -d
fi

# ###############################################################
# Build exporter
make build

# ###############################################################
# Move binary to its final path to be copied from the next step
mkdir -p ${integration_bin_dir}

cp "${tmp_dir}/powerdns_exporter" "${integration_bin_dir}/powerdns-exporter"
location=$(dirname "${BASH_SOURCE[0]}")
${location}/build-exporter.sh "windows" "$@"
39 changes: 39 additions & 0 deletions exporters/powerdns/build-exporter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -euo pipefail

# ###############################################################
# Integration variables
os="$1"
root_dir="$2"
integration_dir="${root_dir}/exporters/powerdns"
integration_bin_dir="${integration_dir}/target/bin"
download_url="https://github.com/newrelic-forks/prometheus-powerdns_exporter/releases/download"

# ###############################################################
# Validate variables
if ! [ -z "$EXPORTER_COMMIT" ]; then
echo "This script does not support to build by commit anymore."
exit 1
fi

if [ -z "$EXPORTER_TAG" ]; then
echo "This script requires .exporter_tag to download the exporter."
exit 2
fi

if [ "$os" != "linux" ] && [ "$os" != "windows" ]; then
echo "os not supported: $os."
exit 3
fi

# ###############################################################
# Download the exporter
IFS=',' read -r -a goarchs <<< "$PACKAGE_LINUX_GOARCHS"
for goarch in "${goarchs[@]}"
do
echo "Downloading exporter for ${os} ${goarch}"
mkdir -p "${integration_bin_dir}/${os}_${goarch}"
curl -qsLo "${integration_bin_dir}/${os}_${goarch}/powerdns-exporter" "${download_url}/${EXPORTER_TAG}/prometheus-powerdns_exporter_${EXPORTER_TAG}_${os}_${goarch}"
chmod a+x "${integration_bin_dir}/${os}_${goarch}/powerdns-exporter"
done
24 changes: 5 additions & 19 deletions exporters/powerdns/e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

services:

pdns-recursor:
Expand All @@ -19,36 +17,24 @@ services:
build:
context: pdns-authoritative
container_name: pdns-authoritative
links:
- "mysql:mysql"
ports:
- "5300:53"
- "5300:53/udp"
- "8081:8081"
environment:
- PDNSCONF_DNSUPDATE=no
- SECALLZONES_CRONJOB=yes
volumes:
- ./pdns-authoritative/pdns.conf:/etc/powerdns/pdns.conf:ro
- ./pdns-authoritative/pdns.conf:/usr/local/etc/pdns.conf:ro
- data:/data
networks:
vpcbr:
ipv4_address: 10.5.0.3

mysql:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=mysqlrootpw
- MYSQL_DATABASE=pdns
- MYSQL_USER=pdns
- MYSQL_PASSWORD=pdnspw
command: --default-authentication-plugin=mysql_native_password
networks:
vpcbr:
ipv4_address: 10.5.0.4
networks:
vpcbr:
driver: bridge
ipam:
config:
- subnet: 10.5.0.0/16
gateway: 10.5.0.1

volumes:
data: {}
42 changes: 36 additions & 6 deletions exporters/powerdns/e2e/e2e_spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@ scenarios:
This scenario will verify that metrics from both PDNS authoritative & PDNS recursor
are correcly collected.
before:
- docker-compose up -d
- docker compose up -d
after:
- docker-compose down -v
- >-
docker ps --format json |
jq -r '.Names' |
xargs -I '{}' bash -c '
echo ===========================;
echo CONTAINER: {};
echo ===========================;
docker logs {};
echo;
'
- docker compose down -v
integrations:
- name: nri-powerdns
binary_path: ../target/bin/linux_amd64/nri-powerdns
Expand Down Expand Up @@ -46,9 +56,19 @@ scenarios:
This scenario will verify that metrics from PDNS authoritative
are correcly collected.
before:
- docker-compose up -d
- docker compose up -d
after:
- docker-compose down -v
- >-
docker ps --format json |
jq -r '.Names' |
xargs -I '{}' bash -c '
echo ===========================;
echo CONTAINER: {};
echo ===========================;
docker logs {};
echo;
'
- docker compose down -v
integrations:
- name: nri-powerdns
binary_path: ../target/bin/linux_amd64/nri-powerdns
Expand Down Expand Up @@ -80,9 +100,19 @@ scenarios:
This scenario will verify that metrics froms PDNS recursor
are correcly collected.
before:
- docker-compose up -d
- docker compose up -d
after:
- docker-compose down -v
- >-
docker ps --format json |
jq -r '.Names' |
xargs -I '{}' bash -c '
echo ===========================;
echo CONTAINER: {};
echo ===========================;
docker logs {};
echo;
'
- docker compose down -v
integrations:
- name: nri-powerdns
binary_path: ../target/bin/linux_amd64/nri-powerdns
Expand Down
35 changes: 3 additions & 32 deletions exporters/powerdns/e2e/pdns-authoritative/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,6 @@
FROM debian:bookworm

ENV PDNSCONF_LAUNCH="gmysql"
ENV PDNSCONF_GMYSQL_HOST="mysql"
ENV PDNSCONF_GMYSQL_USER="pdns"
ENV PDNSCONF_GMYSQL_DBNAME="pdns"
ENV PDNSCONF_GMYSQL_PASSWORD="pdnspw"
ENV PDNSCONF_INCLUDE_DIR="/etc/powerdns/pdns.d"
ENV PDNSCONF_GMYSQL_DNSSEC="yes"
ENV PDNSCONF_API_KEY="apisecret"
ENV SECALLZONES_CRONJOB="no"

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -q -y curl gnupg && \
curl https://repo.powerdns.com/FD380FBB-pub.asc | apt-key add -

ADD pdns.list /etc/apt/sources.list.d/pdns.list
ADD pdns.preference /etc/apt/preferences.d/pdns

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -q -y pdns-server pdns-backend-mysql mariadb-client && \
rm /etc/powerdns/pdns.d/*.conf && rm /etc/powerdns/*.conf && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends cron jq && \
rm /etc/cron.daily/* && \
mkdir /var/run/pdns && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

EXPOSE 53/udp 53/tcp
FROM ghcr.io/txqueuelen/powerdns-docker/powerdns:v4.9.1

ADD start.sh /usr/local/bin/start.sh
ADD fixdsrrs.sh /usr/local/bin/fixdsrrs.sh
ADD secallzones.sh /usr/local/bin/secallzones.sh
ADD schema.mysql.sql /usr/share/doc/pdns-backend-mysql/
RUN chmod a+x /usr/local/bin/*.sh

CMD ["/usr/local/bin/start.sh"]
ENTRYPOINT [ "/bin/bash", "/usr/local/bin/start.sh" ]
CMD []
46 changes: 0 additions & 46 deletions exporters/powerdns/e2e/pdns-authoritative/fixdsrrs.sh

This file was deleted.

13 changes: 4 additions & 9 deletions exporters/powerdns/e2e/pdns-authoritative/pdns.conf
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
query-cache-ttl=20
cache-ttl=20
slave=yes
webserver=yes
webserver-address=0.0.0.0
webserver-allow-from=0.0.0.0/0,::/0
launch=gmysql
gmysql-dbname=pdns
gmysql-dnssec=yes
gmysql-host=mysql
gmysql-password=pdnspw
gmysql-user=pdns
launch=gsqlite3
gsqlite3-database=/data/db.sqlite
api-key=authoritative-secret
dnsupdate=yes
allow-axfr-ips=0.0.0.0/0,::/0
api=yes
api-key=authoritative-secret
local-address=0.0.0.0
local-port=53
setgid=pdns
setuid=pdns
any-to-tcp=yes
dnsupdate=no
1 change: 0 additions & 1 deletion exporters/powerdns/e2e/pdns-authoritative/pdns.list

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions exporters/powerdns/e2e/pdns-authoritative/pdns.preference

This file was deleted.

Loading

0 comments on commit 2bf2f45

Please sign in to comment.