From ee08b8c0fddad3094484dea7fdfb3c262196dc77 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 12 Mar 2024 22:21:16 -0400 Subject: [PATCH] chore: remove traefik priority functionality Setting a priority appears to cause minor outages in certain cases, so we should just avoid setting it on behalf of users and allow them to set this directly. --- docs/networking/proxies/traefik.md | 10 ------- plugins/traefik-vhosts/command-functions | 1 - .../traefik-vhosts/docker-args-process-deploy | 9 +----- plugins/traefik-vhosts/internal-functions | 5 ---- plugins/traefik-vhosts/subcommands/set | 4 +-- tests/unit/traefik.bats | 28 ------------------- 6 files changed, 3 insertions(+), 54 deletions(-) diff --git a/docs/networking/proxies/traefik.md b/docs/networking/proxies/traefik.md index bf89e9398..8657f3054 100644 --- a/docs/networking/proxies/traefik.md +++ b/docs/networking/proxies/traefik.md @@ -116,16 +116,6 @@ dokku traefik:set --global log-level DEBUG After modifying, the Traefik container will need to be restarted. -### Setting rule priority - -By default, app deployments will result in the newer traefik rules using a higher priority in order to have any newer rules respected by Traefik. Rule priorities will always increase according to the current unix timestamp. The priority may be fixed by setting the app-level `priority` property: - -```shell -dokku traefik:set node-js-app priority 12345 -``` - -After modifying, the app container will need to be recreated via a `ps:rebuild` or an app deployment. - ### SSL Configuration The traefik plugin only supports automatic ssl certificates from it's letsencrypt integration. Managed certificates provided by the `certs` plugin are ignored. diff --git a/plugins/traefik-vhosts/command-functions b/plugins/traefik-vhosts/command-functions index 68f194d5b..c37a19f8c 100755 --- a/plugins/traefik-vhosts/command-functions +++ b/plugins/traefik-vhosts/command-functions @@ -44,7 +44,6 @@ cmd-traefik-report-single() { "--traefik-letsencrypt-email: $(fn-traefik-letsencrypt-email)" "--traefik-letsencrypt-server: $(fn-traefik-letsencrypt-server)" "--traefik-log-level: $(fn-traefik-log-level)" - "--traefik-priority: $(fn-traefik-priority "$APP")" ) if [[ -z "$INFO_FLAG" ]]; then diff --git a/plugins/traefik-vhosts/docker-args-process-deploy b/plugins/traefik-vhosts/docker-args-process-deploy index f9d94ffa4..6cb1c8da4 100755 --- a/plugins/traefik-vhosts/docker-args-process-deploy +++ b/plugins/traefik-vhosts/docker-args-process-deploy @@ -8,7 +8,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() { declare desc="nginx-vhosts core-post-deploy plugin trigger" declare trigger="docker-args-process-deploy" declare APP="$1" IMAGE_SOURCE_TYPE="$2" IMAGE_TAG="$3" PROC_TYPE="$4" CONTAINER_INDEX="$5" - local app_domains is_app_listening letsencrypt_email output proxy_container_port proxy_host_port port_map priority proxy_scheme proxy_schemes traefik_domains + local app_domains is_app_listening letsencrypt_email output proxy_container_port proxy_host_port port_map proxy_scheme proxy_schemes traefik_domains local proxy_container_http_port proxy_container_http_port_candidate proxy_host_http_port_candidate local proxy_container_https_port proxy_container_https_port_candidate proxy_host_https_port_candidate local STDIN=$(cat) @@ -87,11 +87,6 @@ trigger-traefik-vhosts-docker-args-process-deploy() { traefik_domains="${traefik_domains// /\\\`,\\\`}" fi - priority="$(fn-traefik-priority "$APP")" - if [[ -z "$priority" ]]; then - priority="$(date +%s)" - fi - output="--label traefik.enable=true" if [[ -n "$proxy_container_http_port" ]] || [[ -n "$proxy_container_http_port_candidate" ]]; then if [[ -z "$proxy_container_http_port" ]]; then @@ -102,7 +97,6 @@ trigger-traefik-vhosts-docker-args-process-deploy() { output="$output --label traefik.http.services.$APP-$PROC_TYPE-http.loadbalancer.server.port=$proxy_container_http_port" output="$output --label traefik.http.routers.$APP-$PROC_TYPE-http.entrypoints=http" - output="$output --label traefik.http.routers.$APP-$PROC_TYPE-http.priority=$priority" output="$output --label traefik.http.routers.$APP-$PROC_TYPE-http.service=$APP-$PROC_TYPE-http" if [[ -n "$traefik_domains" ]]; then output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE-http.rule=Host(\\\`$traefik_domains\\\`)\"" @@ -118,7 +112,6 @@ trigger-traefik-vhosts-docker-args-process-deploy() { output="$output --label traefik.http.services.$APP-$PROC_TYPE-https.loadbalancer.server.port=$proxy_container_https_port" output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.entrypoints=https" - output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.priority=$priority" output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.service=$APP-$PROC_TYPE-https" output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.tls.certresolver=leresolver" if [[ -n "$traefik_domains" ]]; then diff --git a/plugins/traefik-vhosts/internal-functions b/plugins/traefik-vhosts/internal-functions index f2e7e4134..ce981215d 100755 --- a/plugins/traefik-vhosts/internal-functions +++ b/plugins/traefik-vhosts/internal-functions @@ -92,8 +92,3 @@ fn-traefik-log-level() { log_level="$(fn-plugin-property-get-default "traefik" "--global" "log-level" "ERROR")" echo "${log_level^^}" } - -fn-traefik-priority() { - declare APP="$1" - fn-plugin-property-get-default "traefik" "$APP" "priority" "" -} diff --git a/plugins/traefik-vhosts/subcommands/set b/plugins/traefik-vhosts/subcommands/set index 0c51777b2..c9a10476b 100755 --- a/plugins/traefik-vhosts/subcommands/set +++ b/plugins/traefik-vhosts/subcommands/set @@ -9,13 +9,13 @@ cmd-traefik-set() { declare cmd="traefik:set" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" KEY="$2" VALUE="$3" - local VALID_KEYS=("api-enabled" "api-vhost" "dashboard-enabled" "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level" "priority") + local VALID_KEYS=("api-enabled" "api-vhost" "dashboard-enabled" "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level") local GLOBAL_KEYS=("api-enabled" "api-vhost" "dashboard"-enabled "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level") [[ -z "$KEY" ]] && dokku_log_fail "No key specified" if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then - dokku_log_fail "Invalid key specified, valid keys include: api-enabled api-vhost dashboard-enabled basic-auth-username basic-auth-password image letsencrypt-email letsencrypt-server log-level priority" + dokku_log_fail "Invalid key specified, valid keys include: api-enabled api-vhost dashboard-enabled basic-auth-username basic-auth-password image letsencrypt-email letsencrypt-server log-level" fi if ! fn-in-array "$KEY" "${GLOBAL_KEYS[@]}"; then diff --git a/tests/unit/traefik.bats b/tests/unit/traefik.bats index 835b974cd..efebbedcd 100644 --- a/tests/unit/traefik.bats +++ b/tests/unit/traefik.bats @@ -140,34 +140,6 @@ teardown() { assert_success } -@test "(traefik) traefik:set priority" { - run /bin/bash -c "dokku proxy:set $TEST_APP traefik" - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "dokku traefik:set $TEST_APP priority 12345" - echo "output: $output" - echo "status: $status" - assert_success - - run deploy_app - echo "output: $output" - echo "status: $status" - assert_success - - run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"traefik.http.services.$TEST_APP-web-http.loadbalancer.server.port\" }}'" - echo "output: $output" - echo "status: $status" - assert_output "5000" - - run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"traefik.http.routers.$TEST_APP-web-http.priority\" }}'" - echo "output: $output" - echo "status: $status" - assert_success - assert_output "12345" -} - @test "(traefik) ssl" { run /bin/bash -c "dokku builder-herokuish:set $TEST_APP allowed true" echo "output: $output"