]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r417238, r437773, r446929, r453630 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 7 Nov 2006 13:49:09 +0000 (13:49 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 7 Nov 2006 13:49:09 +0000 (13:49 +0000)
* Add the following environment variables to expose the information
* about
  the route, the sticky session and the worker used during a request to
  other modules:

  BALANCER_SESSION_STICKY
  BALANCER_SESSION_ROUTE
  BALANCER_NAME
  BALANCER_WORKER_NAME
  BALANCER_WORKER_ROUTE

PR: 39806
Submitted by: Brian <brectanu gmail.com>
Reviewed by: rpluem

fix validation error

* Set the new environment variable BALANCER_ROUTE_CHANGED if a worker with a
  route different from the one supplied by the client had been chosen or if
  the client supplied no routing information for a balancer with sticky
  sessions.

* mod_proxy_balancer: Document BALANCER_ROUTE_CHANGED environment variable.

Submitted by: Brian Rectanus <brectanu gmail.com>
Reviewed by: rpluem

Reviewed by: jim

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@472114 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
docs/manual/mod/mod_proxy_balancer.xml
modules/proxy/mod_proxy_balancer.c

diff --git a/CHANGES b/CHANGES
index 9298aee997f64d5b6e709423694e0646cc679fc9..93961a8ac93766628186a2a6419a24dba08088d9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,15 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.4
 
+  *) mod_proxy_balancer: Set the new environment variable BALANCER_ROUTE_CHANGED
+     if a worker with a route different from the one supplied by the client
+     had been chosen or if the client supplied no routing information for
+     a balancer with sticky sessions. [Ruediger Pluem]
+
+  *) mod_proxy_balancer: Add information about the route, the sticky session
+     and the worker used during a request as environment variables. PR 39806.
+     [Brian <brectanu gmail.com>]
+
   *) mod_proxy: Don't try to use dead backend connection. PR 37770.
      [Olivier BOEL <ob dorrboel.com>] 
 
diff --git a/STATUS b/STATUS
index f531812ed44125cf6275ad43785aee27415594a8..563f5a7d4839aec7783a04ee99c4161d0cbe3762 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -77,22 +77,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-   * mod_proxy_balancer: Implement new environment variables
-                         BALANCER_NAME
-                         BALANCER_WORKER_NAME
-                         BALANCER_WORKER_ROUTE
-                         BALANCER_SESSION_STICKY
-                         BALANCER_SESSION_ROUTE
-                         BALANCER_ROUTE_CHANGED
-      Trunk versions of patch:
-        http://svn.apache.org/viewvc?view=rev&revision=417238 (including docs)
-        http://svn.apache.org/viewvc?view=rev&revision=437773 (docs)
-        http://svn.apache.org/viewvc?view=rev&revision=446929
-        http://svn.apache.org/viewvc?view=rev&revision=453630 (docs)
-      2.2.x version of patch:
-        Trunk version works
-      +1: rpluem, mturk, jim
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
 
     * mpm_winnt: Fix return values from wait_for_many_objects.
index b035a19af14da65373d1bb4b1fdc91cf756f70cb..532fc92fcb23029e4299ad147ef2ab0c12686424 100644 (file)
@@ -271,6 +271,59 @@ candidate lbstatus -= total factor</code></pre>
 
 </section>
 
+<section id="environment">
+    <title>Exported Environment Variables</title>
+    <p>At present there are 6 environment variables exported:</p>
+
+    <dl>
+    <!-- ============= BALANCER_SESSION_STICKY =============== -->
+    <dt><var><a name="balancer_session_sticky" id="balancer_session_sticky">BALANCER_SESSION_STICKY</a></var></dt>
+    <dd>
+    <p>This is assigned the <var>stickysession</var> value used in the current
+    request.  It is the cookie or parameter name used for sticky sessions</p>
+    </dd>
+
+    <!-- ============= BALANCER_SESSION_ROUTE ================ -->
+    <dt><var><a name="balancer_session_route" id="balancer_session_route">BALANCER_SESSION_ROUTE</a></var></dt>
+    <dd>
+    <p>This is assigned the <var>route</var> parsed from the current 
+    request.</p>
+    </dd>
+
+    <!-- ============= BALANCER_NAME ========================= -->
+    <dt><var><a name="balancer_name" id="balancer_name">BALANCER_NAME</a></var></dt>
+    <dd>
+    <p>This is assigned the name of the balancer used for the current 
+    request. The value is something like <code>balancer://foo</code>.</p>
+    </dd>
+
+    <!-- ============= BALANCER_WORKER_NAME ================== -->
+    <dt><var><a name="balancer_worker_name" id="balancer_worker_name">BALANCER_WORKER_NAME</a></var></dt>
+    <dd>
+    <p>This is assigned the name of the worker used for the current request.
+    The value is something like <code>http://hostA:1234</code>.</p>
+    </dd>
+
+    <!-- ============= BALANCER_WORKER_ROUTE ================= -->
+    <dt><var><a name="balancer_worker_route" id="balancer_worker_route">BALANCER_WORKER_ROUTE</a></var></dt>
+    <dd>
+    <p>This is assigned the <var>route</var> of the worker that will be 
+    used for the current request.</p>
+    </dd>
+
+    <!-- ============= BALANCER_ROUTE_CHANGED ================= -->
+    <dt><var><a name="balancer_route_changed" id="balancer_route_changed">BALANCER_ROUTE_CHANGED</a></var></dt>
+    <dd>
+    <p>This is set to 1 if the session route does not match the
+    worker route (BALANCER_SESSION_ROUTE != BALANCER_WORKER_ROUTE) or the
+    session does not yet have an established route.  This can be used to
+    determine when/if the client needs to be sent an updated route
+    when sticky sessions are used.</p>
+    </dd>
+    </dl>
+
+</section>
+
 <section id="enable">
     <title>Enabling Balancer Manager Support</title>
     <p>This module <em>requires</em> the service of 
index c4e3307901193e6f670d89c5bca4e9cdf0346e96..b7d4466ba74dd564bcf37d0bd6a74b1748a8bc22 100644 (file)
@@ -260,6 +260,16 @@ static proxy_worker *find_session_route(proxy_balancer *balancer,
          * Find the worker that has this route defined.
          */
         worker = find_route_worker(balancer, *route, r);
+        if (worker && strcmp(*route, worker->s->route)) {
+            /*
+             * Notice that the route of the worker chosen is different from
+             * the route supplied by the client.
+             */
+            apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                         "proxy: BALANCER: Route changed from %s to %s",
+                         *route, worker->s->route);
+        }
         return worker;
     }
     else
@@ -417,9 +427,28 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
 
             return HTTP_SERVICE_UNAVAILABLE;
         }
+        if ((*balancer)->sticky && runtime) {
+            /*
+             * This balancer has sticky sessions and the client either has not
+             * supplied any routing information or all workers for this route
+             * including possible redirect and hotstandby workers are in error
+             * state, but we have found another working worker for this
+             * balancer where we can send the request. Thus notice that we have
+             * changed the route to the backend.
+             */
+            apr_table_setn(r->subprocess_env, "BALANCER_ROUTE_CHANGED", "1");
+        }
         *worker = runtime;
     }
 
+    /* Add balancer/worker info to env. */
+    apr_table_setn(r->subprocess_env,
+                   "BALANCER_NAME", (*balancer)->name);
+    apr_table_setn(r->subprocess_env,
+                   "BALANCER_WORKER_NAME", (*worker)->name);
+    apr_table_setn(r->subprocess_env,
+                   "BALANCER_WORKER_ROUTE", (*worker)->s->route);
+
     /* Rewrite the url from 'balancer://url'
      * to the 'worker_scheme://worker_hostname[:worker_port]/url'
      * This replaces the balancers fictional name with the
@@ -430,6 +459,12 @@ static int proxy_balancer_pre_request(proxy_worker **worker,
     if (route) {
         apr_table_setn(r->notes, "session-sticky", (*balancer)->sticky);
         apr_table_setn(r->notes, "session-route", route);
+
+        /* Add session info to env. */
+        apr_table_setn(r->subprocess_env,
+                       "BALANCER_SESSION_STICKY", (*balancer)->sticky);
+        apr_table_setn(r->subprocess_env,
+                       "BALANCER_SESSION_ROUTE", route);
     }
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
                  "proxy: BALANCER (%s) worker (%s) rewritten to %s",