Merge pull request #582 from netbox-community/develop

Version 1.4.0
This commit is contained in:
Tobias Genannt 2021-09-17 11:35:56 +02:00 committed by GitHub
commit 6a52a48b71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 52 additions and 14 deletions

View File

@ -62,11 +62,12 @@ RUN apk add --no-cache \
libevent \ libevent \
libffi \ libffi \
libjpeg-turbo \ libjpeg-turbo \
openssl \
libxslt \ libxslt \
openssl \
postgresql-libs \ postgresql-libs \
python3 \
py3-pip \ py3-pip \
python3 \
tini \
unit \ unit \
unit-python3 unit-python3
@ -82,6 +83,7 @@ COPY ${NETBOX_PATH} /opt/netbox
COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py COPY docker/configuration.docker.py /opt/netbox/netbox/netbox/configuration.py
COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh COPY docker/docker-entrypoint.sh /opt/netbox/docker-entrypoint.sh
COPY docker/housekeeping.sh /opt/netbox/housekeeping.sh
COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh COPY docker/launch-netbox.sh /opt/netbox/launch-netbox.sh
COPY startup_scripts/ /opt/netbox/startup_scripts/ COPY startup_scripts/ /opt/netbox/startup_scripts/
COPY initializers/ /opt/netbox/initializers/ COPY initializers/ /opt/netbox/initializers/
@ -98,9 +100,9 @@ RUN mkdir -p static /opt/unit/state/ /opt/unit/tmp/ \
--config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \ --config-file /opt/netbox/mkdocs.yml --site-dir /opt/netbox/netbox/project-static/docs/ \
&& SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input && SECRET_KEY="dummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input
ENTRYPOINT [ "/opt/netbox/docker-entrypoint.sh" ] ENTRYPOINT [ "/sbin/tini", "--" ]
CMD [ "/opt/netbox/launch-netbox.sh" ] CMD [ "/opt/netbox/docker-entrypoint.sh", "/opt/netbox/launch-netbox.sh" ]
LABEL ORIGINAL_TAG="" \ LABEL ORIGINAL_TAG="" \
NETBOX_GIT_BRANCH="" \ NETBOX_GIT_BRANCH="" \

View File

@ -1 +1 @@
1.3.1 1.4.0

View File

@ -118,6 +118,14 @@ NETBOX_PATH="${NETBOX_PATH-.netbox}"
# Fetching the NetBox source # Fetching the NetBox source
### ###
if [ "${2}" != "--push-only" ] && [ -z "${SKIP_GIT}" ]; then if [ "${2}" != "--push-only" ] && [ -z "${SKIP_GIT}" ]; then
REMOTE_EXISTS=$(git ls-remote --heads --tags "${URL}" "${NETBOX_BRANCH}" | wc -l)
if [ "${REMOTE_EXISTS}" == "0" ]; then
echo "❌ Remote branch '${NETBOX_BRANCH}' not found in '${URL}'; Nothing to do"
if [ -n "${GH_ACTION}" ]; then
echo "::set-output name=skipped::true"
fi
exit 0
fi
echo "🌐 Checking out '${NETBOX_BRANCH}' of NetBox from the url '${URL}' into '${NETBOX_PATH}'" echo "🌐 Checking out '${NETBOX_BRANCH}' of NetBox from the url '${URL}' into '${NETBOX_PATH}'"
if [ ! -d "${NETBOX_PATH}" ]; then if [ ! -d "${NETBOX_PATH}" ]; then
$DRY git clone -q --depth 10 -b "${NETBOX_BRANCH}" "${URL}" "${NETBOX_PATH}" $DRY git clone -q --depth 10 -b "${NETBOX_BRANCH}" "${URL}" "${NETBOX_PATH}"

View File

@ -17,8 +17,6 @@ services:
- ./reports:/etc/netbox/reports:z,ro - ./reports:/etc/netbox/reports:z,ro
- ./scripts:/etc/netbox/scripts:z,ro - ./scripts:/etc/netbox/scripts:z,ro
- netbox-media-files:/opt/netbox/netbox/media:z - netbox-media-files:/opt/netbox/netbox/media:z
ports:
- 8080
postgres: postgres:
image: postgres:13-alpine image: postgres:13-alpine
env_file: env/postgres.env env_file: env/postgres.env

View File

@ -20,11 +20,18 @@ services:
<<: *netbox <<: *netbox
depends_on: depends_on:
- redis - redis
entrypoint: - postgres
command:
- /opt/netbox/venv/bin/python - /opt/netbox/venv/bin/python
- /opt/netbox/netbox/manage.py - /opt/netbox/netbox/manage.py
command:
- rqworker - rqworker
netbox-housekeeping:
<<: *netbox
depends_on:
- redis
- postgres
command:
- /opt/netbox/housekeeping.sh
# postgres # postgres
postgres: postgres:

View File

@ -15,7 +15,19 @@ source /opt/netbox/venv/bin/activate
DB_WAIT_TIMEOUT=${DB_WAIT_TIMEOUT-3} DB_WAIT_TIMEOUT=${DB_WAIT_TIMEOUT-3}
MAX_DB_WAIT_TIME=${MAX_DB_WAIT_TIME-30} MAX_DB_WAIT_TIME=${MAX_DB_WAIT_TIME-30}
CUR_DB_WAIT_TIME=0 CUR_DB_WAIT_TIME=0
while ! ./manage.py showmigrations >/dev/null 2>&1 && [ "${CUR_DB_WAIT_TIME}" -lt "${MAX_DB_WAIT_TIME}" ]; do while [ "${CUR_DB_WAIT_TIME}" -lt "${MAX_DB_WAIT_TIME}" ]; do
# Read and truncate connection error tracebacks to last line by default
exec {psfd}< <(./manage.py showmigrations 2>&1)
read -rd '' DB_ERR <&$psfd || :
exec {psfd}<&-
wait $! && break
if [ -n "$DB_WAIT_DEBUG" ]; then
echo "$DB_ERR"
else
readarray -tn 0 DB_ERR_LINES <<<"$DB_ERR"
echo "${DB_ERR_LINES[@]: -1}"
echo "[ Use DB_WAIT_DEBUG=1 in netbox.env to print full traceback for errors here ]"
fi
echo "⏳ Waiting on DB... (${CUR_DB_WAIT_TIME}s / ${MAX_DB_WAIT_TIME}s)" echo "⏳ Waiting on DB... (${CUR_DB_WAIT_TIME}s / ${MAX_DB_WAIT_TIME}s)"
sleep "${DB_WAIT_TIMEOUT}" sleep "${DB_WAIT_TIMEOUT}"
CUR_DB_WAIT_TIME=$((CUR_DB_WAIT_TIME + DB_WAIT_TIMEOUT)) CUR_DB_WAIT_TIME=$((CUR_DB_WAIT_TIME + DB_WAIT_TIMEOUT))

8
docker/housekeeping.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
SECONDS=${HOUSEKEEPING_INTERVAL:=86400}
echo "Interval set to ${SECONDS} seconds"
while true; do
date
/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py housekeeping
sleep "${SECONDS}s"
done

View File

@ -51,4 +51,6 @@ exec unitd \
--pid /opt/unit/unit.pid \ --pid /opt/unit/unit.pid \
--log /dev/stdout \ --log /dev/stdout \
--state /opt/unit/state/ \ --state /opt/unit/state/ \
--tmp /opt/unit/tmp/ --tmp /opt/unit/tmp/ \
--user 101 \
--group 0

1
env/netbox.env vendored
View File

@ -14,6 +14,7 @@ EMAIL_USERNAME=netbox
# EMAIL_USE_SSL and EMAIL_USE_TLS are mutually exclusive, i.e. they can't both be `true`! # EMAIL_USE_SSL and EMAIL_USE_TLS are mutually exclusive, i.e. they can't both be `true`!
EMAIL_USE_SSL=false EMAIL_USE_SSL=false
EMAIL_USE_TLS=false EMAIL_USE_TLS=false
HOUSEKEEPING_INTERVAL=86400
MAX_PAGE_SIZE=1000 MAX_PAGE_SIZE=1000
MEDIA_ROOT=/opt/netbox/netbox/media MEDIA_ROOT=/opt/netbox/netbox/media
METRICS_ENABLED=false METRICS_ENABLED=false

View File

@ -1,5 +1,5 @@
napalm==3.3.1 napalm==3.3.1
ruamel.yaml==0.17.16 ruamel.yaml==0.17.16
django-auth-ldap==3.0.0 django-auth-ldap==3.0.0
google-crc32c==1.1.4 google-crc32c==1.1.5
django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1 django-storages[azure,boto3,dropbox,google,libcloud,sftp]==1.11.1

View File

@ -56,13 +56,13 @@ test_setup() {
test_netbox_unit_tests() { test_netbox_unit_tests() {
echo "⏱ Running NetBox Unit Tests" echo "⏱ Running NetBox Unit Tests"
SKIP_STARTUP_SCRIPTS=true $doco run --rm netbox ./manage.py test $doco run --rm netbox /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py test
} }
test_initializers() { test_initializers() {
echo "🏭 Testing Initializers" echo "🏭 Testing Initializers"
export INITIALIZERS_DIR export INITIALIZERS_DIR
$doco run --rm netbox ./manage.py check $doco run --rm netbox /opt/netbox/docker-entrypoint.sh ./manage.py check
} }
test_cleanup() { test_cleanup() {