← Back to Pull requests

Add CSI Plugin skeleton #1

Closed
hajiler closed this pull request without merging on Aug 10, 2026 17:23 UTC
View on GitHub
hajiler hajiler commented on Jul 09, 2026 18:21 UTC
Author

Fixes #<issue_number_goes_here>

It's a good idea to open an issue first for discussion.

  • Tests pass

  • Appropriate changes to documentation are included in the PR
  • Diff: 20050 lines (+17182 / -2868) across 109 files Reviewer: hajiler Review duration: 46021m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.86) × (1 − Review Confidence (0.69)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.86 · 20050 lines diff across 109 files
    0.86
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.36 · 5 substantive comment(s)
    0.36
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    69%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Self Review self_review
    0.140
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    8 items
    hajiler hajiler commented on code on Jul 09, 2026 23:31 UTC
    Code Review
    cmd/ateapi/internal/controlapi/workflow_resume.go:1
    @@ -209,14 +210,15 @@ func (s *AssignWorkerStep) RetryBackoff() *wait.Backoff {
     }
     
     type AttachVolumesStep struct {
    -	store store.Interface
    +	store        store.Interface
    +	volumePlugin volume.VolumePlugin
     }
     
     func (s *AttachVolumesStep) Name() string { return "AttachVolumes" }
     
     func (s *AttachVolumesStep) IsComplete(ctx context.Context, input *ResumeInput, state *ResumeState) (bool, error) {
     	// TODO: check if all volumes are attached
    -	return true, nil
    +	return state.Actor.GetStatus() == ateapipb.Actor_STATUS_RUNNING, nil

    How to check volume attached state?

    hajiler hajiler commented on code on Jul 09, 2026 23:32 UTC
    Code Review
    cmd/ateapi/main.go:1
    @@ -73,6 +75,9 @@ var (
     	showVersion     = pflag.Bool("version", false, "Print version and exit.")
     	authMode        = pflag.String("auth-mode", "mtls", "Auth mode for incoming gRPC: mtls|jwt. 'mtls' (default) relies on transport-level mTLS for client identity. 'jwt' additionally requires a Kubernetes ServiceAccount Bearer token on every RPC. Substrate will drop support for JWT auth mode once the Pod Certificates feature is enabled by default in the minimum supported Kubernetes version.")
     	clientJWTCAFile = pflag.String("client-jwt-ca-cert", ateapiauth.DefaultServiceAccountCAFile, "CA cert file used to verify TLS when fetching the OIDC discovery document and JWKS for JWT authentication. Defaults to the in-cluster service account CA.")
    +
    +	volumePlugin = pflag.String("volume-plugin", "csi", "The volume plugin to use: mock|csi")
    +	csiEndpoint  = pflag.String("csi-endpoint", "unix:///tmp/dummy-csi.sock", "The UDS endpoint path for the CSI driver (required if volume-plugin is csi)")

    Should be empty, and fail if unspecified?

    hajiler hajiler commented on code on Jul 09, 2026 23:32 UTC
    Code Review
    cmd/ateapi/main.go:1
    @@ -150,8 +155,25 @@ func main() {
     	ateletPodInformerFactory.WaitForCacheSync(stopCh)
     	ateFactory.WaitForCacheSync(stopCh)
     
    +	var volPlugin volume.VolumePlugin
    +	switch *volumePlugin {
    +	case "csi":
    +		if *csiEndpoint == "" {

    See above comment above about flag.

    hajiler hajiler commented on code on Jul 09, 2026 23:33 UTC
    Code Review
    demos/counter/counter.yaml.tmpl:1
    @@ -57,12 +57,12 @@ spec:
           workload: counter
       snapshotsConfig:
         onPause: Full
    -    onCommit: Data
    +    onCommit: Full

    What does this do?

    msau42 msau42 commented on code on Jul 10, 2026 18:09 UTC
    Code Review
    cmd/ateapi/internal/controlapi/volumes.go:1
    @@ -19,22 +19,12 @@ import (
     	"fmt"
     	"log/slog"
     
    -	"github.com/agent-substrate/substrate/internal/volume"
     	atev1alpha1 "github.com/agent-substrate/substrate/pkg/api/v1alpha1"
     	"github.com/agent-substrate/substrate/pkg/proto/ateapipb"
     	"google.golang.org/grpc/codes"
     	"google.golang.org/grpc/status"
     )
     
    -var (

    fine for poc, but for the actual feature we'll want to be able to support multiple plugins simultaneously. So we'll need some sort of plugin registration system.

    And we'll extract the plugin to use from the StorageClass that's specified in the ActorTemplate.

    msau42 msau42 commented on code on Jul 10, 2026 18:10 UTC
    Code Review
    demos/counter/counter.yaml.tmpl:1
    @@ -57,12 +57,12 @@ spec:
           workload: counter
       snapshotsConfig:
         onPause: Full
    -    onCommit: Data
    +    onCommit: Full

    it shouldn't be relevant to our test. But this controls whether memory snapshot is taken or not

    msau42 msau42 commented on code on Jul 10, 2026 18:12 UTC
    Code Review
    pkg/csi/plugin.go:1
    @@ -0,0 +1,231 @@
    +// Copyright 2026 Google LLC
    +//
    +// Licensed under the Apache License, Version 2.0 (the "License");
    +// you may not use this file except in compliance with the License.
    +// You may obtain a copy of the License at
    +//
    +//     http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing, software
    +// distributed under the License is distributed on an "AS IS" BASIS,
    +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +// See the License for the specific language governing permissions and
    +// limitations under the License.
    +
    +package csi
    +
    +import (
    +	"context"
    +	"fmt"
    +	"log/slog"
    +	"os"
    +	"path/filepath"
    +
    +	"github.com/agent-substrate/substrate/internal/volume"
    +	"github.com/container-storage-interface/spec/lib/go/csi"
    +	"google.golang.org/grpc/codes"
    +	"google.golang.org/grpc/status"
    +	"k8s.io/apimachinery/pkg/api/resource"
    +)
    +
    +// Plugin implements volume.VolumePlugin using the CSI Client.
    +type Plugin struct {
    +	client           *Client
    +	stagingDirPrefix string
    +}
    +
    +// Ensure Plugin implements volume.VolumePlugin
    +var _ volume.VolumePlugin = (*Plugin)(nil)
    +
    +// NewPlugin creates a new Plugin adapter.
    +func NewPlugin(client *Client) *Plugin {
    +	return &Plugin{
    +		client:           client,
    +		stagingDirPrefix: "/var/lib/ateom-gvisor/staging",
    +	}
    +}
    +
    +// CreateVolume maps to CSI Controller CreateVolume.
    +func (p *Plugin) CreateVolume(ctx context.Context, name string, capacity string, storageClass string) (string, error) {

    ah this is a problem with the interface, but we'll need logic to read the StorageClass and extract the parameters.

    Reviewers
    Assignees
    hajiler hajiler
    Labels
    risk: low confidence: 69.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 85.5% (HIGH) · Higher = larger blast radius
    85.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 69.4% · Lower = rushed or shallow review
    69.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.2% · Safe to merge
    26.2%