From bc5dd50ccabd699c111ee469f7c8a4a996520ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=B6nthal?= Date: Wed, 29 Jan 2025 17:54:32 +0100 Subject: [PATCH] feat(percentage): use actual percentage for cookie value (#6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Robert Schönthal --- .github/workflows/test.yaml | 4 ++-- haproxy.cfg | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ef05e37..5a59a5c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -98,13 +98,13 @@ jobs: id: test-percentage-sticky-old-domain continue-on-error: true run: | - curl -Is localhost:80 --cookie "my_app=old_domain" | grep -i -e "server: Apache" + curl -Is localhost:80 --cookie "my_app=old_domain_50" | grep -i -e "server: Apache" - name: Test Docker Image with Percentage Strategy with sticky cookie on new domain id: test-percentage-sticky-new-domain continue-on-error: true run: | - curl -Is localhost:80 --cookie "my_app=new_domain" | grep -i -e "x-served-by: cache-" + curl -Is localhost:80 --cookie "my_app=new_domain_50" | grep -i -e "x-served-by: cache-" - name: Test Docker Image with Percentage Strategy with round robin id: test-percentage-round-robin diff --git a/haproxy.cfg b/haproxy.cfg index 953d910..dcbb524 100644 --- a/haproxy.cfg +++ b/haproxy.cfg @@ -67,10 +67,10 @@ backend percentage_strategy cookie "$COOKIE_PERCENTAGE_NAME" insert indirect # old domain - server-template old_domain_percentage "$SERVER_COUNT" "$OLD_DOMAIN" cookie old_domain weight "$PERCENTAGE_OLD" + server-template old_domain_percentage "$SERVER_COUNT" "$OLD_DOMAIN" cookie "old_domain_$PERCENTAGE_OLD" weight "$PERCENTAGE_OLD" # new domain - server-template new_domain_percentage "$SERVER_COUNT" "$NEW_DOMAIN" cookie new_domain weight "$PERCENTAGE_NEW" + server-template new_domain_percentage "$SERVER_COUNT" "$NEW_DOMAIN" cookie "new_domain_$PERCENTAGE_NEW" weight "$PERCENTAGE_NEW" backend cookie_strategy balance leastconn