Skip to content

Commit 2efad02

Browse files
committed
Merge branch 'callautomation/release/beta7' of https://github.com/Azure/azure-sdk-for-python into callautomation/release/beta7
2 parents 43f8b99 + 2bca1ce commit 2efad02

File tree

3 files changed

+599
-0
lines changed

3 files changed

+599
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from contextlib import contextmanager
2+
import tempfile
3+
import subprocess
4+
import venv
5+
6+
7+
class ExtendedEnvBuilder(venv.EnvBuilder):
8+
"""An extended env builder which saves the context, to have access
9+
easily to bin path and such.
10+
"""
11+
12+
def __init__(self, *args, **kwargs):
13+
self.context = None
14+
super(ExtendedEnvBuilder, self).__init__(*args, **kwargs)
15+
16+
def ensure_directories(self, env_dir):
17+
self.context = super(ExtendedEnvBuilder, self).ensure_directories(env_dir)
18+
return self.context
19+
20+
21+
def create(
22+
env_dir,
23+
system_site_packages=False,
24+
clear=False,
25+
symlinks=False,
26+
with_pip=False,
27+
prompt=None,
28+
):
29+
"""Create a virtual environment in a directory."""
30+
builder = ExtendedEnvBuilder(
31+
system_site_packages=system_site_packages,
32+
clear=clear,
33+
symlinks=symlinks,
34+
with_pip=with_pip,
35+
prompt=prompt,
36+
)
37+
builder.create(env_dir)
38+
return builder.context
39+
40+
41+
@contextmanager
42+
def create_venv_with_package(packages):
43+
"""Create a venv with these packages in a temp dir and yielf the env.
44+
45+
packages should be an iterable of pip version instructio (e.g. package~=1.2.3)
46+
"""
47+
with tempfile.TemporaryDirectory() as tempdir:
48+
myenv = create(tempdir, with_pip=True)
49+
pip_call = [
50+
myenv.env_exe,
51+
"-m",
52+
"pip",
53+
"install",
54+
]
55+
subprocess.check_call(pip_call + ["-U", "pip"])
56+
if packages:
57+
subprocess.check_call(pip_call + packages)
58+
yield myenv
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!-- cspell:disable -->
2+
# Envoy Configuration Documentation
3+
4+
**Purpose:**
5+
This Envoy proxy configuration manages traffic routing to internal and external services, such as Azure Cosmos DB endpoints, while exposing local admin metrics. It enforces strict retry logic, TLS encryption, and structured access logging.
6+
7+
---
8+
9+
## Listeners
10+
11+
### 1. `admin-listener` (Port `8080`)
12+
13+
**Purpose:** Handles health checks and Prometheus metrics access for observability.
14+
15+
**Routes:**
16+
17+
| Path | Action |
18+
|------------|------------------------------------------|
19+
| `/ready` | Routed to `admin_port_cluster` |
20+
| `/metrics` | Routed to `admin_port_cluster` with `prefix_rewrite: /stats/prometheus` |
21+
| `*` | Returns HTTP 404 (direct response) |
22+
23+
**HTTP Filter Chain:**
24+
- Uses `envoy.filters.http.router`
25+
- Enables `respect_expected_rq_timeout: true` to support `x-envoy-expected-rq-timeout-ms` header.
26+
27+
---
28+
29+
### 2. `main-listener` (Port `5100`)
30+
31+
**Purpose:** Handles user/application traffic and routes to various external services including Azure Cosmos DB regions.
32+
33+
**Key Settings:**
34+
- **Stat Prefix:** `router_http`
35+
- **Scheme Overwrite:** Forces outgoing requests to use `https` (`scheme_header_transformation`)
36+
- **Strip Host Ports:** Enabled (`strip_any_host_port: true`)
37+
- **Node ID-based Proxy Status:** Enabled
38+
39+
**Timeouts and Limits:**
40+
41+
| Setting | Value |
42+
|----------------------------|---------|
43+
| Max Connection Duration | 900s |
44+
| Drain Timeout | 330s |
45+
| Stream Idle Timeout | 60s |
46+
| Max Request Header Size | 120 KB |
47+
48+
**Response Header Modification:**
49+
- Adds: `via: %ENVIRONMENT(POD_NAME)%` (for traceability)
50+
51+
**HTTP Filters:**
52+
- Only one: `envoy.filters.http.router`, with retry logic support.
53+
54+
**Routes:**
55+
56+
| Name | Domains | Cluster | Retry Policy |
57+
|---------------------------------------|-------------------------------|-----------|-----------------------------------------------|
58+
| `local_<account_name>` | `*` | `<>` | `connect-failure,refused-stream,reset`, 3 retries |
59+
| `local_<account_name>-<write_region>` | `<account_name>-<write_region>.documents.azure.com` | `<account_name>-<write_region>` | Same |
60+
| `local_<account_name>-<read_region>` | `<account_name>-<read_region>.documents.azure.com` | `<account_name>-<read_region>` | Same |
61+
| `local_heise` | `www.heise.de` | `heise` | Same |
62+
63+
---
64+
65+
## Request Routing Flow (Mermaid Diagram)
66+
67+
```mermaid
68+
graph TD
69+
A[Incoming Request] --> B{Listener}
70+
B -->|Port 8080| C[admin-listener]
71+
B -->|Port 5100| D[main-listener]
72+
73+
C --> E{Path}
74+
E -->|/ready| F[Route to admin_port_cluster]
75+
E -->|/metrics| G[Rewrite + Route to admin_port_cluster]
76+
E -->|other| H[Return 404]
77+
78+
D --> I{Domain/Prefix Match}
79+
I -->|\*| J[Route to Cluster account_name]
80+
I -->|account_name-write_region.documents.azure.com| K[Route to Cluster account_name-write_region]
81+
I -->|account_name-read_region.documents.azure.com| L[Route to Cluster account_name-read_region]
82+
I -->|www\.heise.de| M[Route to Cluster heise]
83+
```

0 commit comments

Comments
 (0)