]> git.ipfire.org Git - thirdparty/squid.git/commit - src/Server.cc
Support adaptation sets and chains, including dynamic ICAP chains:
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 13 Jul 2009 01:20:26 +0000 (19:20 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 13 Jul 2009 01:20:26 +0000 (19:20 -0600)
commita22e6cd3b6e8889984d266816aaea8fcf27ee13d
treefdebf99a7c594d7806a7f937368a56166920d364
parent3ff6559699bc1852ae3a6f7be48824d13e2ebf90
Support adaptation sets and chains, including dynamic ICAP chains:

  - Support adaptation service sets and chains
    (adaptation_service_set and adaptation_service_chain)

  - Dynamically form chains based on ICAP X-Next-Services header
    (icap_service routing=on)

  - Support cross-transactional ICAP header exchange
    (adaptation_masterx_shared_names)

An adaptation service set contains similar, interchangeable services. No more
than one service is successfully applied. If one service is down or fails,
Squid can use another service. Think "hot standby" or "spare" ICAP servers.

Sets may seem similar to the existing "service bypass" feature, but they allow
the failed adaptation to be retried and succeed if a replacement service is
available. The services in a set may be all optional or all essential,
depending on whether ignoring the entire set is acceptable. The mixture of
optional and essential services in a set is supported, but yields results that
may be difficult for a human to anticipate or interpret. Squid warns when it
detects such a mixture.

When performing adaptations with a set, failures at a service (optional or
essential, does not matter) are retried with a different service if possible.
If there are no more replacement services left to try, the failure is treated
depending on whether the last service tried was optional or essential: Squid
either tries to ignore the failure and proceed or terminates the master
transaction.

An adaptation chain is a list of different services applied one after another,
forming an adaptation pipeline. Services in a chain may be optional or
essential. When performing adaptations, failures at an optional service are
ignored as if the service did not exist in the chain.

Request satisfaction terminates the adaptation chain.

When forming a set or chain for a given transaction, optional down services
are ignored as if they did not exist.

ICAP and eCAP services can be mixed and matched in an adaptation set or chain.

Merged from 3p1-plus branch at r9513.

* Implementation notes

The notes below focus on _changes_. Adaptation terminology and current layers
are now being documented in src/adaptation/notes.dox

Service sets and chains are implemented as ServiceGroup class kids. They are
very similar in most code aspects. The primary external difference is that
ServiceSet can "replace" a service and ServiceChain can find the "next"
service.  The internal search code is implemented in ServiceGroup parent and
is parametrized by the kids.

Before the adaptation starts, Squid calculates the adaptation "plan", which is
just an iterator into the ServiceGroup. The client- and server-side adaptation
initiators used to deal with Service pointers. They now deal with ServiceGroup
pointers. The only interesting difference is that a ServiceGroup does not have
a notion of being optional or essential. Thus, if adaptation start fails, we
do not know whether the failure can be bypassed. Fortunately, starting an
adaptation does not require anything that depends on the adaptation services,
so we now simply assert that the start succeeds.

If the entire adaptation fails, the callers are notified as before. They are
told whether they can ignore the failure as before. No changes there.

A new Adaptation::Iterator class has been added to execute the adaptation
plan. That class is responsible for iterating the services in a service group
until the plan is exhausted or cannot progress due to a final failure.

Dynamically form adaptation chains based on the ICAP X-Next-Services header.

If an ICAP service with the routing=1 option in squid.conf returns an ICAP
X-Next-Services response header during a successful REQMOD or RESPMOD
transaction, Squid abandons the original adaptation plan and forms a new
adaptation chain consisting of services identified in the X-Next-Services
header value (using a comma-separated list of adaptation service names from
squid.conf).  The dynamically created chain is destroyed once the new plan is
completed or replaced.

This feature is useful when a custom adaptation service knows which other
services are applicable to the message being adapted.

Limit adaptation iterations to adaptation_service_iteration_limit to protect
Squid from infinite adaptation loops caused by ICAP services constantly
including themselves in the dynamic adaptation chain they request. When the
limit is exceeded, the master transaction fails. The default limit of 16
should be large enough to not require an explicit configuration in most
environments yet may be small enough to limit side-effects of loops.

TODO: Add metadata support to eCAP API and honor X-Next-Services there as
well. Currently, only ICAP services can form dynamic chains but the formed
chains may contain eCAP services.

Other improvements:

Polished adaptation service configuration in squid.conf. Old format with an
anonymous bypass option is deprecated but still supported. Quit with a fatal
message if an adaptation service is misconfigured (debugging level-0 messages
do not seem to work at that stage, but that is probably another, general bug).

Polished HttpRequest::adaptHistory() interface so that the code that knows the
history is needed can force history creation without complex
configuration-time preparations and state. Currently, all adaptation history
users but the logging-related ones know runtime whether the history must be
created (e.g., when a certain ICAP header is received).

Fixed "canonical" Request URL maintenance when ICAP clones requests.
TODO: The urlCanonical() must become HttpRequest::canonical(), hiding the
often out-of-sync canonical data member.

Fixed ICAP request parsing (for ICAP logging). We used to parse Request-Line
as if it were the first header. TODO: optimize by parsing only when needed.

Fixed AccessCheck case where a service group disappears during a nb ACL check.
Replaced "done" member with an existing AsyncJob mustStop mechanism. Removed
extra async call as unneeded because ACL callbacks are already async.
44 files changed:
include/Array.h
src/ClientRequestContext.h
src/HttpHeader.cc
src/HttpHeader.h
src/HttpRequest.cc
src/HttpRequest.h
src/Server.cc
src/Server.h
src/adaptation/AccessCheck.cc
src/adaptation/AccessCheck.h
src/adaptation/AccessRule.cc
src/adaptation/AccessRule.h
src/adaptation/Config.cc
src/adaptation/Config.h
src/adaptation/History.cc
src/adaptation/History.h
src/adaptation/Initiate.cc
src/adaptation/Initiate.h
src/adaptation/Iterator.cc [new file with mode: 0644]
src/adaptation/Iterator.h [new file with mode: 0644]
src/adaptation/Makefile.am
src/adaptation/Service.cc
src/adaptation/Service.h
src/adaptation/ServiceConfig.cc
src/adaptation/ServiceConfig.h
src/adaptation/ServiceFilter.cc [new file with mode: 0644]
src/adaptation/ServiceFilter.h [new file with mode: 0644]
src/adaptation/ServiceGroups.cc
src/adaptation/ServiceGroups.h
src/adaptation/ecap/XactionRep.cc
src/adaptation/ecap/XactionRep.h
src/adaptation/forward.h
src/adaptation/icap/Launcher.cc
src/adaptation/icap/Launcher.h
src/adaptation/icap/ModXact.cc
src/adaptation/icap/ModXact.h
src/adaptation/icap/Xaction.cc
src/adaptation/icap/Xaction.h
src/adaptation/notes.dox [new file with mode: 0644]
src/cache_cf.cc
src/cf.data.depend
src/cf.data.pre
src/client_side_request.cc
src/client_side_request.h