Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **`ContainerizedPluginLoader<T>` brought up to the 2.1 `IPluginLoader<T>` contract** — the Containerized projects had not compiled since the base 2.1.0 interface changes; added `ListPluginsByVersionRangeAsync`/`ListPluginsByModuleAsync`, `PluginLoadingFailed`/`SecurityValidationFailed` events, `Dispose`, and fixed `UnloadPlugin` nullability
- `KubernetesOrchestrator.ListContainersAsync`: `V1ObjectMeta.CreationTimestamp` is a `DateTime?` in KubernetesClient 17 — removed the invalid `.DateTime` member access
- Nullable-annotation fixes in `HybridPluginFactory` and `ContainerizedPluginProxy` (CS8601/CS8619/CS0067 clean)
- **Issue #56: `KubernetesOrchestrator.ExecuteAsync` performs a real Kubernetes exec** (`IKubernetes.NamespacedPodExecAsync`, SPDY multiplexed stream) instead of throwing `NotImplementedException` from the removed `SimulateExecution` placeholder — `InputData` is written to the process stdin (default command `/app/plugin-executor`, overridable per request via `ContainerExecutionRequest.ExecutionConfiguration["command"]`), and `ContainerExecutionResult` now carries the real exit code, stdout, stderr and measured `ExecutionTime`; `ContainerExecutionRequest.Timeout` kills the exec on deadline via a linked cancellation token and reports `Success = false, ExitCode = -1, Error = "Execution timed out after ..."` (caller cancellation still throws `OperationCanceledException`)
- **Issue #56: `KubernetesOrchestrator.ExecuteAsync` performs a real Kubernetes exec** (`IKubernetes.NamespacedPodExecAsync`, WebSocket transport with the `v4.channel.k8s.io` channel-multiplexed subprotocol — note the upgrade is an HTTP GET, so the orchestrator ServiceAccount needs `pods/exec` with both `create` and `get`, see #61) instead of throwing `NotImplementedException` from the removed `SimulateExecution` placeholder — `InputData` is written to the process stdin (default command `/app/plugin-executor`, overridable per request via `ContainerExecutionRequest.ExecutionConfiguration["command"]`), and `ContainerExecutionResult` now carries the real exit code, stdout, stderr and measured `ExecutionTime`; `ContainerExecutionRequest.Timeout` kills the exec on deadline via a linked cancellation token and reports `Success = false, ExitCode = -1, Error = "Execution timed out after ..."` (caller cancellation still throws `OperationCanceledException`)
- **Issue #57: `CreateContainerAsync` no longer assumes long-running pods** — a completing (batch-style) pod reaches `Succeeded` and returns `ContainerInstanceStatus.Stopped` instead of timing out on the `Ready` condition; creation failures (`Failed` phase, `Pending` + `Status.Reason`, container `waiting` reasons such as `CreateContainerError`/`ImagePullBackOff`/`CrashLoopBackOff`, non-zero `terminated` exit codes) fail fast on the first poll that shows them, with the kubelet reason in the `ContainerOrchestrationException`; `ContainerSpec` gains `Command`/`Args` entrypoint overrides and `ContainerSecurity.RunAsUser` (wired into the container security context); pod-ready polling is configurable via `KubernetesOrchestratorOptions.PodReadyMaxAttempts` / `PodReadyPollIntervalMs`; additionally `GeneratePodName` no longer throws `ArgumentOutOfRangeException` for short plugin names (the `[..63]` truncation assumed a ≥63-char name, so `CreateContainerAsync` crashed before creating the pod for any plugin name shorter than ~30 chars)
- **Issue #61: deployment-guide RBAC for `pods/exec` now grants `["create", "get"]`** (with an explanatory comment in `k8s/02-rbac.yaml` and both `kubectl auth can-i` checks in the troubleshooting section): WebSocket exec clients — KubernetesClient's `NamespacedPodExecAsync` (used by `KubernetesOrchestrator.ExecuteAsync`) and kubectl >= 1.30 — authorize the HTTP GET WebSocket upgrade with the **`get`** verb on `pods/exec`, so a create-only grant fails the exec handshake with `403 ... when status code '101' was expected`; `create` remains required for legacy SPDY/POST clients and is additionally verified on the WebSocket path from k8s >= 1.35. The §8.3 exec bullet now also documents the transport (WebSocket, not SPDY) and the RBAC requirement
- **Issue #59: pod-name generation hardened** — `GeneratePodName` now sanitizes the `crpcf.plugin-name` label into a DNS-1123 subdomain (lowercase alphanumerics, `-`, `.`; invalid characters become `-`; the prefix is capped at 30 chars so the 32-char GUID suffix always fits the 63-char pod-name limit), and `CreateContainerAsync` runs name/pod-definition generation inside its try block so spec failures surface as `ContainerOrchestrationException` (raw exception preserved as `InnerException`) instead of escaping unwrapped; unit tests pin short, >63-char, invalid-character and absent plugin-name labels

## [2.1.1] - 2026-11-01
Expand Down
16 changes: 14 additions & 2 deletions CRPCF_DEPLOYMENT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ rules:
verbs: ["create", "delete", "get", "list", "watch", "update", "patch"]
- apiGroups: [""]
resources: ["pods/exec"]
verbs: ["create"]
# "get" is required for WebSocket exec clients (KubernetesClient's
# NamespacedPodExecAsync, kubectl >= 1.30): the WebSocket upgrade is an HTTP
# GET and the API server authorizes it with the "get" verb on pods/exec.
# "create" stays required for legacy SPDY/POST exec clients, and k8s >= 1.35
# additionally verifies "create" on the WebSocket path (issue #61).
verbs: ["create", "get"]
- apiGroups: [""]
resources: ["pods/log"]
verbs: ["get", "list"]
Expand Down Expand Up @@ -1169,6 +1174,13 @@ kubectl logs -l app=crpcf-orchestrator -n crpcf-system --tail=100
# Check RBAC permissions
kubectl auth can-i create pods --as=system:serviceaccount:crpcf-system:crpcf-orchestrator -n crpcf-plugins

# Exec needs BOTH verbs on pods/exec (issue #61): WebSocket exec clients
# (KubernetesClient NamespacedPodExecAsync) authorize the GET handshake with
# "get" - a create-only grant fails with "403 ... when status code '101' was
# expected" - and legacy SPDY/POST clients use "create".
kubectl auth can-i create pods/exec --as=system:serviceaccount:crpcf-system:crpcf-orchestrator -n crpcf-plugins
kubectl auth can-i get pods/exec --as=system:serviceaccount:crpcf-system:crpcf-orchestrator -n crpcf-plugins

# Check resource quotas
kubectl describe resourcequota -n crpcf-plugins

Expand Down Expand Up @@ -1352,7 +1364,7 @@ result.ExecutionId // string → correlates orchestrator logs

- `CreateContainerAsync` waits for the pod to become **Ready** *or* reach a **terminal phase**: a batch-style plugin pod (image entrypoint, or `ContainerSpec.Command`/`Args`, that exits) completes as `Succeeded` and the returned `ContainerInstance.Status` is `Stopped` — no more Ready-timeout for completing pods. Creation failures are detected fast and reported with the kubelet reason: `Failed` phase, `Pending` + `Status.Reason` (e.g. `CreateContainerError`, `ErrImagePull`), container `waiting` reasons (`ImagePullBackOff`, `CreateContainerConfigError`, `CrashLoopBackOff`, ...) and non-zero `terminated` exit codes all surface as `ContainerOrchestrationException` carrying the reason, on the first poll that shows them. Poll budget: `KubernetesOrchestratorOptions.PodReadyMaxAttempts` (default 30) x `PodReadyPollIntervalMs` (default 2000). Pod names are generated as `plugin-<crpcf.plugin-name label>-<guid>`: the label is sanitized to a DNS-1123 subdomain (lowercase alphanumerics, `-`, `.`) and the full name is capped at 63 chars, so any plugin name yields a valid pod name. Failures during name/pod-definition generation surface as `ContainerOrchestrationException` (raw exception as `InnerException`).
- `ContainerSpec` gains `Command` / `Args` (entrypoint override; empty = the image entrypoint runs unchanged) and `ContainerSecurity.RunAsUser` (`long?`, wired into the container security context next to the existing `RunAsNonRoot` / `ReadOnlyRootFilesystem` / `AllowPrivilegeEscalation` / capabilities).
- `ExecuteAsync` performs a **real Kubernetes exec** (`IKubernetes.NamespacedPodExecAsync`, SPDY multiplexed stream): the command defaults to `/app/plugin-executor` and can be overridden per request via `ContainerExecutionRequest.ExecutionConfiguration["command"]` (a `List<string>`); `InputData` is written to the process **stdin**, stdout/stderr are captured. `ContainerExecutionResult` carries the real `ExitCode`, `Output` (stdout), `Error` (stderr, or an exit-code message when stderr is empty), `Success = ExitCode == 0`, and the measured `ExecutionTime`. `ContainerExecutionRequest.Timeout` is enforced with a linked cancellation token: on deadline the exec is killed and the result is `Success = false, ExitCode = -1, Error = "Execution timed out after ..."` (caller cancellation still propagates as `OperationCanceledException`, it is not swallowed into a result).
- `ExecuteAsync` performs a **real Kubernetes exec** (`IKubernetes.NamespacedPodExecAsync`, WebSocket transport with the `v4.channel.k8s.io` channel-multiplexed subprotocol — the upgrade is an HTTP GET, so the orchestrator ServiceAccount needs `pods/exec` with **both `create` and `get`**, see §3.1): the command defaults to `/app/plugin-executor` and can be overridden per request via `ContainerExecutionRequest.ExecutionConfiguration["command"]` (a `List<string>`); `InputData` is written to the process **stdin**, stdout/stderr are captured. `ContainerExecutionResult` carries the real `ExitCode`, `Output` (stdout), `Error` (stderr, or an exit-code message when stderr is empty), `Success = ExitCode == 0`, and the measured `ExecutionTime`. `ContainerExecutionRequest.Timeout` is enforced with a linked cancellation token: on deadline the exec is killed and the result is `Success = false, ExitCode = -1, Error = "Execution timed out after ..."` (caller cancellation still propagates as `OperationCanceledException`, it is not swallowed into a result).
- The K8s transport sits behind `protected virtual` wrappers (`CreatePodAsync`, `ReadPodAsync`, `DeletePodAsync`, `ListPodsAsync`, `ExecInPodAsync`), so tests and local harnesses (k8s-testkit-style, issue #52) can fake the cluster without stream plumbing. The repo ships hermetic tests over a mocked `NamespacedPodExecAsync` plus live-cluster contract tests gated on `CRPCF_K8S_LIVE_TESTS=1` (`KubernetesLiveContractTests`).

3. **`HybridPluginFactory<T>`** — mixes a traditional `PluginClassFactory<T>` with an `IContainerizedPluginOrchestrator` behind one `GetPluginAsync(module, name, version, mode, ct)` call (`PluginExecutionMode.Traditional | Containerized | Auto`, `PreferContainerized` option). The returned containerized plugin is a `ContainerizedPluginProxy<T>`: an `IPluginClass`/`ITypedPluginClass` adapter whose `ExecuteAsync(context, input)` serializes input to JSON, calls `ExecutePluginAsync`, and returns `PluginExecutionResult<object>` — so containerized plugins flow through existing `TypedPluginClassFactory<T,TIn,TOut>` call sites unchanged.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ private static IList<string> BuildExecutionCommand(ContainerExecutionRequest req

/// <summary>
/// Executes a command in the plugin container over the Kubernetes exec API
/// (SPDY multiplexed stream). <paramref name="inputData"/> is written to the
/// (WebSocket transport, v4.channel.k8s.io channel-multiplexed subprotocol).
/// <paramref name="inputData"/> is written to the
/// process stdin; stdout/stderr are captured and the process exit code is
/// returned. Virtual so tests and local harnesses can substitute a fake
/// transport without a cluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace RuntimePluggableClassFactory.Containerized.Tests
/// <summary>
/// Hermetic tests for the shipped KubernetesOrchestrator (issues #56/#57):
/// real exec wiring is verified by mocking IKubernetes.NamespacedPodExecAsync
/// (the SPDY exec entry point), pod lifecycle by a fake cluster behind the
/// (the WebSocket exec entry point), pod lifecycle by a fake cluster behind the
/// orchestrator's virtual transport wrappers. No cluster, no network.
/// </summary>
[TestClass]
Expand Down
Loading