Skip to content

Add control plane connectivity control for offline mode#305

Merged
omer9564 merged 3 commits intomainfrom
omer/control-plane-connectivity-control
Apr 5, 2026
Merged

Add control plane connectivity control for offline mode#305
omer9564 merged 3 commits intomainfrom
omer/control-plane-connectivity-control

Conversation

@omer9564
Copy link
Copy Markdown
Contributor

Summary

  • PDP_CONTROL_PLANE_CONNECTIVITY_DISABLED env var — When set with PDP_ENABLE_OFFLINE_MODE=true, the PDP starts disconnected from the control plane and serves from a local backup. Falls back to control plane connection if no valid backup exists.
  • Runtime HTTP APIs (PDP API key authenticated):
    • GET /control-plane/connectivity — Current connectivity status
    • POST /control-plane/connectivity/enable — Reconnects to control plane, triggers full rehydration
    • POST /control-plane/connectivity/disable — Disconnects, continues serving from cached state
  • Upgrades opal-common and opal-client to 0.9.4rc6 — picks up the underlying OPAL server connectivity feature (permitio/opal#889)

Why PDP-level endpoints?

OPAL's built-in /opal-server/connectivity endpoints require OPAL JWT tokens (PeerType.listener). Permit customers use PDP API keys exclusively, so we expose equivalent endpoints under /control-plane/ authenticated with enforce_pdp_token.

Test plan

  • Start PDP with PDP_ENABLE_OFFLINE_MODE=true PDP_CONTROL_PLANE_CONNECTIVITY_DISABLED=true and verify it serves from backup
  • GET /control-plane/connectivity returns control_plane_connectivity_disabled: true
  • POST /control-plane/connectivity/enable reconnects and triggers rehydration
  • POST /control-plane/connectivity/disable disconnects and saves backup
  • Verify endpoints reject requests without valid PDP API key
  • Verify endpoints return 400 when offline mode is not enabled

🤖 Generated with Claude Code

Adds PDP-level bindings for OPAL's new server connectivity feature,
allowing the PDP to start disconnected from the control plane and
serve from a local backup. Includes runtime HTTP endpoints
(/control-plane/connectivity) authenticated with the PDP API key.

- Add PDP_CONTROL_PLANE_CONNECTIVITY_DISABLED config option
- Create /control-plane/connectivity GET/enable/disable endpoints
- Upgrade opal-common and opal-client to 0.9.4rc6

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

🔍 Vulnerabilities of permitio/pdp-v2:next

📦 Image Reference permitio/pdp-v2:next
digestsha256:6e2df1fc8573010eba4405805cea800ed33e56aacbdfac07f00f72cd14cf665e
vulnerabilitiescritical: 0 high: 0 medium: 2 low: 1
platformlinux/amd64
size214 MB
packages252
📦 Base Image oisupport/staging-amd64:b259d89e26fbe01d956a4834260c0e5a7c7b305ecda39ae3b59e208e5a03a2aa
digestsha256:a7b85667f5c4e8db146b494344e4a3826e695185c7260bddab7ec9667a2406e3
vulnerabilities
critical: 0 high: 0 medium: 1 low: 0 sqlparse 0.5.0 (pypi)

pkg:pypi/sqlparse@0.5.0

medium 6.9: GHSA--27jp--wm6q--gp25 Allocation of Resources Without Limits or Throttling

Affected range<=0.5.3
Fixed version0.5.4
CVSS Score6.9
CVSS VectorCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N
Description

Summary

The below gist hangs while attempting to format a long list of tuples.

This was found while drafting a regression test for Dja
ngo 5.2's composite primary key feature
, which allows querying composite fields with tuples.

critical: 0 high: 0 medium: 1 low: 0 busybox 1.37.0-r20 (apk)

pkg:apk/alpine/busybox@1.37.0-r20?os_name=alpine&os_version=3.22

medium : CVE--2025--60876

Affected range<=1.37.0-r20
Fixed versionNot Fixed
EPSS Score0.064%
EPSS Percentile20th percentile
Description
critical: 0 high: 0 medium: 0 low: 1 zlib 1.3.1-r2 (apk)

pkg:apk/alpine/zlib@1.3.1-r2?os_name=alpine&os_version=3.22

low : CVE--2026--27171

Affected range<=1.3.1-r2
Fixed versionNot Fixed
EPSS Score0.007%
EPSS Percentile1st percentile
Description

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 26, 2026

🔍 Vulnerabilities of permitio/pdp-v2:next

📦 Image Reference permitio/pdp-v2:next
digestsha256:6e2df1fc8573010eba4405805cea800ed33e56aacbdfac07f00f72cd14cf665e
vulnerabilitiescritical: 0 high: 0 medium: 0 low: 0
platformlinux/amd64
size214 MB
packages252
📦 Base Image oisupport/staging-amd64:b259d89e26fbe01d956a4834260c0e5a7c7b305ecda39ae3b59e208e5a03a2aa
digestsha256:a7b85667f5c4e8db146b494344e4a3826e695185c7260bddab7ec9667a2406e3
vulnerabilities

Copy link
Copy Markdown
Contributor

@zeevmoney zeevmoney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds PDP-level control-plane connectivity controls to support “offline mode” operation and runtime toggling of OPAL server connectivity via authenticated HTTP endpoints.

Changes:

  • Upgrade opal-common / opal-client to 0.9.4rc6 to pick up OPAL connectivity support.
  • Introduce /control-plane/connectivity GET + enable/disable POST endpoints authenticated with enforce_pdp_token.
  • Add PDP_CONTROL_PLANE_CONNECTIVITY_DISABLED config and wire it into OPAL client config at startup when offline mode is enabled.

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
requirements.txt Bumps OPAL dependencies to a version that includes connectivity toggling support.
horizon/pdp.py Initializes OPAL connectivity default and mounts the new connectivity router.
horizon/connectivity/api.py Implements the new /control-plane/connectivity endpoints.
horizon/config.py Adds the CONTROL_PLANE_CONNECTIVITY_DISABLED env-config entry (prefixed as PDP_...).
horizon/connectivity/__init__.py Introduces the new connectivity module/package.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…pes, OpenAPI responses, and tests

- Add asyncio.Lock to serialize enable/disable operations (fixes TOCTOU race)
- Add try/except with proper error logging and HTTP 500 responses
- Use Literal type for ConnectivityActionResult.status field
- Add responses parameter to route decorators for OpenAPI docs
- Add test_connectivity_api.py with 10 tests covering all endpoints

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@omer9564 omer9564 requested a review from zeevmoney March 31, 2026 11:35
Copy link
Copy Markdown
Contributor

@zeevmoney zeevmoney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, minor comments

…update OPAL to stable

- Only mount connectivity router when ENABLE_OFFLINE_MODE is enabled to reduce attack surface
- Update opal-common and opal-client from 0.9.4rc6 to stable 0.9.4

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@omer9564 omer9564 merged commit 74451bd into main Apr 5, 2026
8 checks passed
@omer9564 omer9564 deleted the omer/control-plane-connectivity-control branch April 5, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants