Skip to content

feat(workbench): add Kubernetes autoscaling and capacity probes (closes #304)#334

Merged
ian-flores merged 5 commits into
mainfrom
bot-implement-issue-304-c203b1f08db49d5d
Jun 2, 2026
Merged

feat(workbench): add Kubernetes autoscaling and capacity probes (closes #304)#334
ian-flores merged 5 commits into
mainfrom
bot-implement-issue-304-c203b1f08db49d5d

Conversation

@posit-vip-triage
Copy link
Copy Markdown
Contributor

Closes #304

Implements the plan from #311

What changed and why

This PR adds Kubernetes-specific session capacity and autoscaling tests to VIP's Workbench test suite, as requested in #304. A Posit customer running Kubernetes-backed Workbench flagged six scenarios around autoscaling boundaries, capacity limits, and resource profile enforcement that weren't covered by the existing test_session_capacity.feature.

New files

src/vip/clients/kubernetes.py
Read-only KubernetesClient using the kubernetes Python SDK. Credentials are inherited from the ambient environment (~/.kube/config, KUBECONFIG env var, or in-cluster service account) — no separate credential fields in vip.toml. The SDK import is lazy: if the package isn't installed, a RuntimeError with a clear install hint is raised, and the corresponding test scenarios skip via pytest.skip.

src/vip_tests/workbench/test_session_capacity_k8s.feature
Six Gherkin scenarios with the @workbench tag:

  1. Autoscaler adds a node when sessions fill current capacity
  2. New session lands on a node after scale-up
  3. Session count respects the configured maximum
  4. Sessions launched in quick succession all reach Active state
  5. Session is routed to the expected node pool for the resource profile
  6. Resource profile enforces CPU and memory limits

src/vip_tests/workbench/test_session_capacity_k8s.py
Step definitions for all six scenarios. Every scenario that needs cluster config gates on @given("the Kubernetes cluster is configured"), which skips cleanly when [workbench.kubernetes] is absent or enabled = false.

selftests/test_workbench_kubernetes_config.py
Config-layer selftests covering WorkbenchKubernetesConfig defaults, from_dict, load_config integration with a real TOML file, and the repr of WorkbenchConfig.

Modified files

src/vip/config.py
Adds WorkbenchKubernetesConfig dataclass with fields: enabled, namespace, node_pool_profiles (pool→profile mapping), max_sessions, profile_cpu_limit, profile_memory_limit_gib. Wired into WorkbenchConfig.from_dict under the [workbench.kubernetes] TOML key.

src/vip_tests/workbench/conftest.py
The shared @given("Workbench is accessible and I am logged in") step was moved here from test_session_capacity.py so both capacity feature files use it without duplicate step registration.

src/vip_tests/conftest.py
Adds a kubernetes_client session fixture (returns None when K8s is not configured).

vip.toml.example
Documents the new [workbench.kubernetes] block with all fields commented out.

Scope guards

All new scenarios skip when:

  • [workbench.kubernetes] is absent or enabled = false
  • The kubernetes Python package is not installed
  • A specific sub-config (e.g., node_pool_profiles, max_sessions) required by a scenario is not set

Out of scope (per plan)

  • No cluster mutation — VIP remains a read-only observer
  • Non-Kubernetes launchers not covered
  • Autoscaler installation/configuration not handled
  • Performance benchmarking excluded

Generated by Implement an approved plan PR for issue #311 · ● 77.9M ·

#304)

- Add WorkbenchKubernetesConfig dataclass to config.py with fields for
  namespace, node_pool_profiles, max_sessions, profile_cpu_limit, and
  profile_memory_limit_gib; wire it into WorkbenchConfig.from_dict
- Add src/vip/clients/kubernetes.py: read-only KubernetesClient using
  the kubernetes SDK with lazy import (RuntimeError on missing package);
  exposes node_count, running_session_pods, pod_node_pool, resource_quota,
  and pod_resource_limits
- Add test_session_capacity_k8s.feature with six Gherkin scenarios:
  autoscaler adds a node, session lands after scale-up, session count
  respects max, quick-succession sessions reach Active, profile routes
  to correct node pool, and profile enforces CPU/memory limits
- Add step definitions test_session_capacity_k8s.py for all six scenarios;
  each scenario skips cleanly when [workbench.kubernetes] is absent
- Move shared '@given("Workbench is accessible and I am logged in")' step
  to workbench/conftest.py so both capacity feature files use it without
  duplicate registration
- Add kubernetes_client session fixture to src/vip_tests/conftest.py
- Add selftests/test_workbench_kubernetes_config.py covering defaults,
  from_dict, load_config integration, and repr
- Document new [workbench.kubernetes] block in vip.toml.example

Implements the plan from #311

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: ian-flores <18703558+ian-flores@users.noreply.github.com>
Co-authored-by: ian-flores <18703558+ian-flores@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@ian-flores ian-flores left a comment

Choose a reason for hiding this comment

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

CI green. Conflict resolved by keeping both job_timeout (from #336) and kubernetes fields in WorkbenchConfig.

@ian-flores ian-flores merged commit b0c846d into main Jun 2, 2026
28 checks passed
@ian-flores ian-flores deleted the bot-implement-issue-304-c203b1f08db49d5d branch June 2, 2026 17:27
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-02 17:28 UTC

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.

feat(workbench): add Kubernetes autoscaling and capacity probes

2 participants