G15c: add CSI dynamic volume intent RPC

This commit is contained in:
pingqiu committed 2026-05-03 10:48:45 -07:00
1 parent 3a792b4114
commit 78290192fe
14 files changed
+1046 -63

No files matched your search

+5 -3
View File
@@ -94,8 +94,9 @@ func run(f flags) int {
defer ln.Close()
var (
masterConn *grpc.ClientConn
lookup blockcsi.PublishTargetLookup
masterConn *grpc.ClientConn
lookup blockcsi.PublishTargetLookup
provisioner blockcsi.VolumeProvisioner
)
if f.masterAddr != "" {
masterConn, err = grpc.NewClient(f.masterAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
@@ -105,11 +106,12 @@ func run(f flags) int {
}
defer masterConn.Close()
lookup = blockcsi.NewControlStatusLookup(control.NewEvidenceServiceClient(masterConn))
provisioner = blockcsi.NewControlLifecycleProvisioner(control.NewLifecycleServiceClient(masterConn))
}
srv := grpc.NewServer()
csipb.RegisterIdentityServer(srv, blockcsi.NewIdentityServer())
csipb.RegisterControllerServer(srv, blockcsi.NewControllerServer(lookup))
csipb.RegisterControllerServer(srv, blockcsi.NewControllerServerWithProvisioner(lookup, provisioner))
csipb.RegisterNodeServer(srv, blockcsi.NewDefaultNodeServer(f.nodeID, f.iqnPrefix))
if f.printReadyLine {
+14
View File
@@ -6,6 +6,7 @@ import (
)
var ErrPublishTargetNotFound = errors.New("csi: publish target not found")
var ErrVolumeConflict = errors.New("csi: volume already exists with different spec")
type Protocol string
@@ -35,6 +36,19 @@ type PublishTargetLookup interface {
LookupPublishTarget(ctx context.Context, volumeID, nodeID string) (PublishTarget, error)
}
// VolumeProvisioner records product-level desired volume intent. It must not
// mint assignment, epoch, endpoint_version, readiness, or frontend facts.
type VolumeProvisioner interface {
CreateVolume(ctx context.Context, spec VolumeSpec) (VolumeSpec, error)
DeleteVolume(ctx context.Context, volumeID string) error
}
type VolumeSpec struct {
VolumeID string
SizeBytes uint64
ReplicationFactor int
}
func publishContext(t PublishTarget) map[string]string {
ctx := map[string]string{}
if t.ISCSIAddr != "" && t.IQN != "" {
+100 -1
View File
@@ -3,6 +3,7 @@ package csi
import (
"context"
"errors"
"strconv"
csipb "github.com/container-storage-interface/spec/lib/go/csi"
"google.golang.org/grpc/codes"
@@ -11,13 +12,57 @@ import (
type ControllerServer struct {
csipb.UnimplementedControllerServer
lookup PublishTargetLookup
lookup PublishTargetLookup
provisioner VolumeProvisioner
}
func NewControllerServer(lookup PublishTargetLookup) *ControllerServer {
return &ControllerServer{lookup: lookup}
}
func NewControllerServerWithProvisioner(lookup PublishTargetLookup, provisioner VolumeProvisioner) *ControllerServer {
return &ControllerServer{lookup: lookup, provisioner: provisioner}
}
func (s *ControllerServer) CreateVolume(ctx context.Context, req *csipb.CreateVolumeRequest) (*csipb.CreateVolumeResponse, error) {
if s.provisioner == nil {
return nil, status.Error(codes.Unimplemented, "dynamic provisioning is not configured")
}
spec, err := volumeSpecFromCreateRequest(req)
if err != nil {
return nil, err
}
created, err := s.provisioner.CreateVolume(ctx, spec)
if err != nil {
if errors.Is(err, ErrVolumeConflict) {
return nil, status.Errorf(codes.AlreadyExists, "volume %q already exists with different spec", spec.VolumeID)
}
return nil, status.Errorf(codes.Internal, "create volume intent: %v", err)
}
return &csipb.CreateVolumeResponse{
Volume: &csipb.Volume{
VolumeId: created.VolumeID,
CapacityBytes: int64(created.SizeBytes),
VolumeContext: map[string]string{
"replicationFactor": strconv.Itoa(created.ReplicationFactor),
},
},
}, nil
}
func (s *ControllerServer) DeleteVolume(ctx context.Context, req *csipb.DeleteVolumeRequest) (*csipb.DeleteVolumeResponse, error) {
if req.GetVolumeId() == "" {
return nil, status.Error(codes.InvalidArgument, "volume ID is required")
}
if s.provisioner == nil {
return nil, status.Error(codes.Unimplemented, "dynamic provisioning is not configured")
}
if err := s.provisioner.DeleteVolume(ctx, req.GetVolumeId()); err != nil {
return nil, status.Errorf(codes.Internal, "delete volume intent: %v", err)
}
return &csipb.DeleteVolumeResponse{}, nil
}
func (s *ControllerServer) ControllerPublishVolume(ctx context.Context, req *csipb.ControllerPublishVolumeRequest) (*csipb.ControllerPublishVolumeResponse, error) {
if req.GetVolumeId() == "" {
return nil, status.Error(codes.InvalidArgument, "volume ID is required")
@@ -50,6 +95,9 @@ func (s *ControllerServer) ControllerGetCapabilities(context.Context, *csipb.Con
caps := []csipb.ControllerServiceCapability_RPC_Type{
csipb.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME,
}
if s.provisioner != nil {
caps = append(caps, csipb.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME)
}
out := make([]*csipb.ControllerServiceCapability, 0, len(caps))
for _, capType := range caps {
out = append(out, &csipb.ControllerServiceCapability{
@@ -83,3 +131,54 @@ func (s *ControllerServer) ValidateVolumeCapabilities(ctx context.Context, req *
},
}, nil
}
func volumeSpecFromCreateRequest(req *csipb.CreateVolumeRequest) (VolumeSpec, error) {
if req.GetName() == "" {
return VolumeSpec{}, status.Error(codes.InvalidArgument, "volume name is required")
}
size := req.GetCapacityRange().GetRequiredBytes()
if size <= 0 {
size = req.GetCapacityRange().GetLimitBytes()
}
if size <= 0 {
return VolumeSpec{}, status.Error(codes.InvalidArgument, "capacity is required")
}
if len(req.GetVolumeCapabilities()) == 0 {
return VolumeSpec{}, status.Error(codes.InvalidArgument, "volume capabilities are required")
}
if !supportsVolumeCapabilities(req.GetVolumeCapabilities()) {
return VolumeSpec{}, status.Error(codes.InvalidArgument, "unsupported volume capability")
}
rf := 1
if raw := req.GetParameters()["replicationFactor"]; raw != "" {
v, err := strconv.Atoi(raw)
if err != nil || v <= 0 {
return VolumeSpec{}, status.Errorf(codes.InvalidArgument, "invalid replicationFactor %q", raw)
}
rf = v
}
return VolumeSpec{
VolumeID: req.GetName(),
SizeBytes: uint64(size),
ReplicationFactor: rf,
}, nil
}
func supportsVolumeCapabilities(caps []*csipb.VolumeCapability) bool {
for _, cap := range caps {
if cap == nil {
return false
}
switch cap.GetAccessType().(type) {
case *csipb.VolumeCapability_Mount:
case *csipb.VolumeCapability_Block:
default:
return false
}
mode := cap.GetAccessMode()
if mode == nil || mode.GetMode() != csipb.VolumeCapability_AccessMode_SINGLE_NODE_WRITER {
return false
}
}
return true
}
+110
View File
@@ -3,6 +3,7 @@ package csi
import (
"context"
"errors"
"fmt"
"testing"
csipb "github.com/container-storage-interface/spec/lib/go/csi"
@@ -24,6 +25,29 @@ func (s *stubLookup) LookupPublishTarget(_ context.Context, volumeID, nodeID str
return s.target, nil
}
type stubProvisioner struct {
created VolumeSpec
err error
calls []VolumeSpec
deletes []string
}
func (s *stubProvisioner) CreateVolume(_ context.Context, spec VolumeSpec) (VolumeSpec, error) {
s.calls = append(s.calls, spec)
if s.err != nil {
return VolumeSpec{}, s.err
}
if s.created.VolumeID != "" {
return s.created, nil
}
return spec, nil
}
func (s *stubProvisioner) DeleteVolume(_ context.Context, volumeID string) error {
s.deletes = append(s.deletes, volumeID)
return s.err
}
func TestControllerPublish_ReturnsISCSIPublishContextFromTargetFact(t *testing.T) {
lookup := &stubLookup{target: PublishTarget{
VolumeID: "v1",
@@ -123,6 +147,83 @@ func TestControllerCapabilities_G15aDoesNotAdvertiseDynamicProvisioning(t *testi
}
}
func TestG15c_ControllerCapabilities_AdvertiseDynamicProvisioningWhenConfigured(t *testing.T) {
s := NewControllerServerWithProvisioner(&stubLookup{}, &stubProvisioner{})
resp, err := s.ControllerGetCapabilities(context.Background(), &csipb.ControllerGetCapabilitiesRequest{})
if err != nil {
t.Fatalf("ControllerGetCapabilities: %v", err)
}
got := map[csipb.ControllerServiceCapability_RPC_Type]bool{}
for _, cap := range resp.GetCapabilities() {
if rpc := cap.GetRpc(); rpc != nil {
got[rpc.Type] = true
}
}
if !got[csipb.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME] {
t.Fatal("missing CREATE_DELETE_VOLUME")
}
}
func TestG15c_ControllerCreateVolume_RecordsDesiredIntentOnly(t *testing.T) {
prov := &stubProvisioner{}
s := NewControllerServerWithProvisioner(&stubLookup{}, prov)
resp, err := s.CreateVolume(context.Background(), &csipb.CreateVolumeRequest{
Name: "pvc-a",
CapacityRange: &csipb.CapacityRange{
RequiredBytes: 1 << 30,
},
Parameters: map[string]string{"replicationFactor": "2"},
VolumeCapabilities: []*csipb.VolumeCapability{
testVolumeCapability(),
},
})
if err != nil {
t.Fatalf("CreateVolume: %v", err)
}
if len(prov.calls) != 1 {
t.Fatalf("provisioner calls=%d want 1", len(prov.calls))
}
if got := prov.calls[0]; got.VolumeID != "pvc-a" || got.SizeBytes != 1<<30 || got.ReplicationFactor != 2 {
t.Fatalf("spec=%+v", got)
}
vol := resp.GetVolume()
if vol.GetVolumeId() != "pvc-a" || vol.GetCapacityBytes() != 1<<30 {
t.Fatalf("volume=%+v", vol)
}
if err := authorityContextGuard(vol.GetVolumeContext()); err != nil {
t.Fatal(err)
}
}
func TestG15c_ControllerCreateVolume_RejectsMissingCapacity(t *testing.T) {
s := NewControllerServerWithProvisioner(&stubLookup{}, &stubProvisioner{})
_, err := s.CreateVolume(context.Background(), &csipb.CreateVolumeRequest{
Name: "pvc-a",
VolumeCapabilities: []*csipb.VolumeCapability{
testVolumeCapability(),
},
})
if err == nil {
t.Fatal("expected error")
}
st, _ := status.FromError(err)
if st.Code() != codes.InvalidArgument {
t.Fatalf("code=%v want InvalidArgument", st.Code())
}
}
func TestG15c_ControllerDeleteVolume_DelegatesToProvisioner(t *testing.T) {
prov := &stubProvisioner{}
s := NewControllerServerWithProvisioner(&stubLookup{}, prov)
if _, err := s.DeleteVolume(context.Background(), &csipb.DeleteVolumeRequest{VolumeId: "pvc-a"}); err != nil {
t.Fatalf("DeleteVolume: %v", err)
}
if len(prov.deletes) != 1 || prov.deletes[0] != "pvc-a" {
t.Fatalf("deletes=%v", prov.deletes)
}
}
func TestValidateVolumeCapabilities_ConfirmsExistingTarget(t *testing.T) {
s := NewControllerServer(&stubLookup{target: PublishTarget{VolumeID: "v1", ISCSIAddr: "127.0.0.1:3260", IQN: "iqn.x:v1"}})
caps := []*csipb.VolumeCapability{testVolumeCapability()}
@@ -137,3 +238,12 @@ func TestValidateVolumeCapabilities_ConfirmsExistingTarget(t *testing.T) {
t.Fatalf("confirmed caps=%d", len(resp.GetConfirmed().GetVolumeCapabilities()))
}
}
func authorityContextGuard(ctx map[string]string) error {
for _, k := range []string{"epoch", "endpointVersion", "assignment", "primary", "ready", "healthy"} {
if _, ok := ctx[k]; ok {
return fmt.Errorf("volume context must not carry authority-shaped field %q", k)
}
}
return nil
}
+35
View File
@@ -19,6 +19,41 @@ func NewControlStatusLookup(client control.EvidenceServiceClient) *ControlStatus
return &ControlStatusLookup{client: client}
}
type ControlLifecycleProvisioner struct {
client control.LifecycleServiceClient
}
func NewControlLifecycleProvisioner(client control.LifecycleServiceClient) *ControlLifecycleProvisioner {
return &ControlLifecycleProvisioner{client: client}
}
func (p *ControlLifecycleProvisioner) CreateVolume(ctx context.Context, spec VolumeSpec) (VolumeSpec, error) {
if p == nil || p.client == nil {
return VolumeSpec{}, fmt.Errorf("csi: lifecycle provisioner not configured")
}
resp, err := p.client.CreateVolume(ctx, &control.CreateVolumeRequest{
VolumeId: spec.VolumeID,
SizeBytes: spec.SizeBytes,
ReplicationFactor: int32(spec.ReplicationFactor),
})
if err != nil {
return VolumeSpec{}, err
}
return VolumeSpec{
VolumeID: resp.GetVolumeId(),
SizeBytes: resp.GetSizeBytes(),
ReplicationFactor: int(resp.GetReplicationFactor()),
}, nil
}
func (p *ControlLifecycleProvisioner) DeleteVolume(ctx context.Context, volumeID string) error {
if p == nil || p.client == nil {
return fmt.Errorf("csi: lifecycle provisioner not configured")
}
_, err := p.client.DeleteVolume(ctx, &control.DeleteVolumeRequest{VolumeId: volumeID})
return err
}
func (l *ControlStatusLookup) LookupPublishTarget(ctx context.Context, volumeID, nodeID string) (PublishTarget, error) {
if l == nil || l.client == nil {
return PublishTarget{}, fmt.Errorf("csi: control status lookup not configured")
@@ -91,3 +91,53 @@ func TestControlStatusLookup_MapsNVMeStatusFrontend(t *testing.T) {
t.Fatalf("target=%+v", got)
}
}
type fakeLifecycleClient struct {
control.LifecycleServiceClient
createReq *control.CreateVolumeRequest
deleteReq *control.DeleteVolumeRequest
}
func (f *fakeLifecycleClient) CreateVolume(_ context.Context, req *control.CreateVolumeRequest, _ ...grpc.CallOption) (*control.CreateVolumeResponse, error) {
f.createReq = req
return &control.CreateVolumeResponse{
VolumeId: req.GetVolumeId(),
SizeBytes: req.GetSizeBytes(),
ReplicationFactor: req.GetReplicationFactor(),
}, nil
}
func (f *fakeLifecycleClient) DeleteVolume(_ context.Context, req *control.DeleteVolumeRequest, _ ...grpc.CallOption) (*control.DeleteVolumeResponse, error) {
f.deleteReq = req
return &control.DeleteVolumeResponse{}, nil
}
func TestG15c_ControlLifecycleProvisioner_CreateVolumeRoundTrip(t *testing.T) {
client := &fakeLifecycleClient{}
prov := NewControlLifecycleProvisioner(client)
got, err := prov.CreateVolume(context.Background(), VolumeSpec{
VolumeID: "pvc-a",
SizeBytes: 1 << 30,
ReplicationFactor: 2,
})
if err != nil {
t.Fatalf("CreateVolume: %v", err)
}
if client.createReq.GetVolumeId() != "pvc-a" || client.createReq.GetSizeBytes() != 1<<30 || client.createReq.GetReplicationFactor() != 2 {
t.Fatalf("request=%+v", client.createReq)
}
if got.VolumeID != "pvc-a" || got.SizeBytes != 1<<30 || got.ReplicationFactor != 2 {
t.Fatalf("spec=%+v", got)
}
}
func TestG15c_ControlLifecycleProvisioner_DeleteVolumeRoundTrip(t *testing.T) {
client := &fakeLifecycleClient{}
prov := NewControlLifecycleProvisioner(client)
if err := prov.DeleteVolume(context.Background(), "pvc-a"); err != nil {
t.Fatalf("DeleteVolume: %v", err)
}
if client.deleteReq.GetVolumeId() != "pvc-a" {
t.Fatalf("delete request=%+v", client.deleteReq)
}
}
+1
View File
@@ -196,6 +196,7 @@ func New(cfg Config) (*Host, error) {
control.RegisterObservationServiceServer(grpcSrv, svc)
control.RegisterAssignmentServiceServer(grpcSrv, svc)
control.RegisterEvidenceServiceServer(grpcSrv, svc)
control.RegisterLifecycleServiceServer(grpcSrv, svc)
h.grpc = grpcSrv
lg.Printf("blockmaster: lock acquired, reloaded=%d, listen=%s",
@@ -0,0 +1,98 @@
package master
import (
"context"
"reflect"
"testing"
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func TestG15c_LifecycleService_CreateVolumePersistsDesiredIntent(t *testing.T) {
h := newTestMaster(t, t.TempDir())
defer closeTestMaster(t, h)
svc := newServices(h)
resp, err := svc.CreateVolume(context.Background(), &control.CreateVolumeRequest{
VolumeId: "pvc-a",
SizeBytes: 1 << 30,
ReplicationFactor: 2,
})
if err != nil {
t.Fatalf("CreateVolume: %v", err)
}
if resp.GetVolumeId() != "pvc-a" || resp.GetSizeBytes() != 1<<30 || resp.GetReplicationFactor() != 2 {
t.Fatalf("response=%+v", resp)
}
rec, ok := h.Lifecycle().Volumes.GetVolume("pvc-a")
if !ok {
t.Fatal("desired volume not persisted")
}
if rec.Spec.VolumeID != "pvc-a" || rec.Spec.SizeBytes != 1<<30 || rec.Spec.ReplicationFactor != 2 {
t.Fatalf("record=%+v", rec)
}
if _, ok := h.Publisher().VolumeAuthorityLine("pvc-a"); ok {
t.Fatal("CreateVolume must not mint authority")
}
}
func TestG15c_LifecycleService_CreateVolumeIdempotentAndConflictRejected(t *testing.T) {
h := newTestMaster(t, t.TempDir())
defer closeTestMaster(t, h)
svc := newServices(h)
req := &control.CreateVolumeRequest{VolumeId: "pvc-a", SizeBytes: 1 << 20, ReplicationFactor: 1}
if _, err := svc.CreateVolume(context.Background(), req); err != nil {
t.Fatalf("first CreateVolume: %v", err)
}
if _, err := svc.CreateVolume(context.Background(), req); err != nil {
t.Fatalf("idempotent CreateVolume: %v", err)
}
_, err := svc.CreateVolume(context.Background(), &control.CreateVolumeRequest{
VolumeId: "pvc-a",
SizeBytes: 2 << 20,
ReplicationFactor: 1,
})
if err == nil {
t.Fatal("expected conflict")
}
st, _ := status.FromError(err)
if st.Code() != codes.AlreadyExists {
t.Fatalf("code=%v want AlreadyExists", st.Code())
}
}
func TestG15c_LifecycleService_DeleteVolumeRemovesDesiredIntent(t *testing.T) {
h := newTestMaster(t, t.TempDir())
defer closeTestMaster(t, h)
svc := newServices(h)
if _, err := svc.CreateVolume(context.Background(), &control.CreateVolumeRequest{
VolumeId: "pvc-a",
SizeBytes: 1 << 20,
ReplicationFactor: 1,
}); err != nil {
t.Fatalf("CreateVolume: %v", err)
}
if _, err := svc.DeleteVolume(context.Background(), &control.DeleteVolumeRequest{VolumeId: "pvc-a"}); err != nil {
t.Fatalf("DeleteVolume: %v", err)
}
if _, ok := h.Lifecycle().Volumes.GetVolume("pvc-a"); ok {
t.Fatal("desired volume still present after delete")
}
}
func TestG15c_LifecycleWireMessagesAreNotAuthorityShaped(t *testing.T) {
for _, typ := range []reflect.Type{
reflect.TypeOf(control.CreateVolumeRequest{}),
reflect.TypeOf(control.CreateVolumeResponse{}),
reflect.TypeOf(control.DeleteVolumeRequest{}),
reflect.TypeOf(control.DeleteVolumeResponse{}),
} {
for _, forbidden := range []string{"Epoch", "EndpointVersion", "Assignment", "Ready", "Healthy", "Primary"} {
if _, ok := typ.FieldByName(forbidden); ok {
t.Fatalf("%s must not carry %s", typ.Name(), forbidden)
}
}
}
}
@@ -1,7 +1,10 @@
package master
import "github.com/seaweedfs/seaweed-block/core/lifecycle"
// LifecycleProductTickResult summarizes one explicit product-loop tick.
type LifecycleProductTickResult struct {
ReconciledVolumes int
VerifiedPlacements int
PublishedAsks int
SkippedCurrent int
@@ -18,9 +21,11 @@ func (h *Host) RunLifecycleProductTick() (LifecycleProductTickResult, error) {
return LifecycleProductTickResult{}, nil
}
nodes := stores.Nodes.ListNodes()
reconciled := lifecycle.ReconcilePlacement(stores.Volumes.ListVolumes(), nodes, stores.Placements)
placements := stores.Placements.ListPlacements()
verified := h.verifyPlacements(placements, nodes)
result := LifecycleProductTickResult{
ReconciledVolumes: len(reconciled),
VerifiedPlacements: len(verified),
}
for _, placement := range verified {
@@ -97,6 +97,60 @@ func TestG9G_BlockvolumeSubscriptionReceivesProductLoopAssignment(t *testing.T)
}
}
func TestG15c_ProductLoopReconcilesCreatedVolumeBeforePublishing(t *testing.T) {
h := newTestMaster(t, t.TempDir())
defer closeTestMaster(t, h)
stores := h.Lifecycle()
if _, err := stores.Volumes.CreateVolume(lifecycle.VolumeSpec{
VolumeID: "pvc-a",
SizeBytes: 1 << 20,
ReplicationFactor: 1,
}); err != nil {
t.Fatalf("create desired volume: %v", err)
}
if _, err := stores.Nodes.RegisterNode(lifecycle.NodeRegistration{
ServerID: "node-a",
DataAddr: "127.0.0.1:9202",
CtrlAddr: "127.0.0.1:9102",
Replicas: []lifecycle.ReplicaInventory{{
VolumeID: "pvc-a",
ReplicaID: "r2",
StoreUUID: "store-r2",
SizeBytes: 1 << 20,
State: "existing",
}},
}); err != nil {
t.Fatalf("register node: %v", err)
}
if err := h.ObservationHost().Ingest(authority.Observation{
ServerID: "node-a",
ObservedAt: time.Now().UTC(),
Slots: []authority.SlotFact{{
VolumeID: "pvc-a",
ReplicaID: "r2",
DataAddr: "127.0.0.1:9202",
CtrlAddr: "127.0.0.1:9102",
}},
}); err != nil {
t.Fatalf("ingest observation: %v", err)
}
result, err := h.RunLifecycleProductTick()
if err != nil {
t.Fatalf("product tick: %v", err)
}
if result.ReconciledVolumes != 1 || result.PublishedAsks != 1 {
t.Fatalf("result=%+v want reconciled+published", result)
}
if _, ok := stores.Placements.GetPlacement("pvc-a"); !ok {
t.Fatal("placement intent not written from desired volume")
}
line := waitAuthorityLine(t, h.Publisher(), "pvc-a")
if line.ReplicaID != "r2" {
t.Fatalf("line=%+v want r2", line)
}
}
func seedVerifiedExistingReplicaPlacement(t *testing.T, h *Host) {
t.Helper()
stores := h.Lifecycle()
+56 -1
View File
@@ -9,7 +9,10 @@ import (
"github.com/seaweedfs/seaweed-block/core/adapter"
"github.com/seaweedfs/seaweed-block/core/authority"
"github.com/seaweedfs/seaweed-block/core/lifecycle"
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
)
@@ -19,7 +22,7 @@ import (
// adapter.AssignmentInfo is constructed on the master side —
// values flow through unchanged from publisher state.
// services is the master-side implementation of the three
// services is the master-side implementation of the control-plane
// gRPC services defined in core/rpc/proto/v3_control.proto.
//
// Boundary (T0 sketch §3): every handler here converts wire
@@ -30,6 +33,7 @@ type services struct {
control.UnimplementedObservationServiceServer
control.UnimplementedAssignmentServiceServer
control.UnimplementedEvidenceServiceServer
control.UnimplementedLifecycleServiceServer
host *Host
// seq is incremented per ReportHeartbeat handler invocation.
@@ -44,6 +48,36 @@ func newServices(h *Host) *services {
return &services{host: h}
}
func (s *services) CreateVolume(ctx context.Context, req *control.CreateVolumeRequest) (*control.CreateVolumeResponse, error) {
stores := s.host.Lifecycle()
if stores == nil {
return nil, status.Error(codes.FailedPrecondition, "lifecycle store is not configured")
}
rec, err := stores.Volumes.CreateVolume(lifecycleSpecFromWire(req))
if err != nil {
return nil, lifecycleError("create volume", err)
}
return &control.CreateVolumeResponse{
VolumeId: rec.Spec.VolumeID,
SizeBytes: rec.Spec.SizeBytes,
ReplicationFactor: int32(rec.Spec.ReplicationFactor),
}, nil
}
func (s *services) DeleteVolume(ctx context.Context, req *control.DeleteVolumeRequest) (*control.DeleteVolumeResponse, error) {
stores := s.host.Lifecycle()
if stores == nil {
return nil, status.Error(codes.FailedPrecondition, "lifecycle store is not configured")
}
if req.GetVolumeId() == "" {
return nil, status.Error(codes.InvalidArgument, "volume_id is required")
}
if err := stores.Volumes.DeleteVolume(req.GetVolumeId()); err != nil {
return nil, lifecycleError("delete volume", err)
}
return &control.DeleteVolumeResponse{}, nil
}
// ReportHeartbeat receives a volume's observation. It validates
// field presence (rejects malformed reports per T0 sketch §8.2.1
// rule 8), translates to authority.HeartbeatMessage, and calls
@@ -62,6 +96,27 @@ func (s *services) ReportHeartbeat(ctx context.Context, r *control.HeartbeatRepo
}, nil
}
func lifecycleSpecFromWire(req *control.CreateVolumeRequest) lifecycle.VolumeSpec {
if req == nil {
return lifecycle.VolumeSpec{}
}
return lifecycle.VolumeSpec{
VolumeID: req.GetVolumeId(),
SizeBytes: req.GetSizeBytes(),
ReplicationFactor: int(req.GetReplicationFactor()),
}
}
func lifecycleError(op string, err error) error {
if errors.Is(err, lifecycle.ErrInvalidVolumeSpec) {
return status.Errorf(codes.InvalidArgument, "%s: %v", op, err)
}
if errors.Is(err, lifecycle.ErrVolumeConflict) {
return status.Errorf(codes.AlreadyExists, "%s: %v", op, err)
}
return status.Errorf(codes.Internal, "%s: %v", op, err)
}
// SubscribeAssignments is VOLUME-SCOPED, not replica-slot-scoped
// (round-4 architect high-1 fix). On subscribe, master opens a
// publisher subscription on EVERY accepted-topology replica slot
+362 -58
View File
@@ -4,6 +4,7 @@
// volume -> master: ObservationService.ReportHeartbeat (unary)
// volume -> master: AssignmentService.SubscribeAssignments (server-streaming)
// operator -> master: EvidenceService.QueryVolumeStatus (unary, read-only)
// CSI/operator -> master: LifecycleService.CreateVolume/DeleteVolume (desired intent only)
//
// Boundary (T0 sketch §3 load-bearing):
// - no message carries an AssignmentAsk
@@ -823,6 +824,217 @@ func (x *StatusResponse) GetFrontends() []*FrontendTarget {
return nil
}
type CreateVolumeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
VolumeId string `protobuf:"bytes,1,opt,name=volume_id,json=volumeId,proto3" json:"volume_id,omitempty"`
SizeBytes uint64 `protobuf:"varint,2,opt,name=size_bytes,json=sizeBytes,proto3" json:"size_bytes,omitempty"`
ReplicationFactor int32 `protobuf:"varint,3,opt,name=replication_factor,json=replicationFactor,proto3" json:"replication_factor,omitempty"`
}
func (x *CreateVolumeRequest) Reset() {
*x = CreateVolumeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_control_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateVolumeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateVolumeRequest) ProtoMessage() {}
func (x *CreateVolumeRequest) ProtoReflect() protoreflect.Message {
mi := &file_control_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateVolumeRequest.ProtoReflect.Descriptor instead.
func (*CreateVolumeRequest) Descriptor() ([]byte, []int) {
return file_control_proto_rawDescGZIP(), []int{9}
}
func (x *CreateVolumeRequest) GetVolumeId() string {
if x != nil {
return x.VolumeId
}
return ""
}
func (x *CreateVolumeRequest) GetSizeBytes() uint64 {
if x != nil {
return x.SizeBytes
}
return 0
}
func (x *CreateVolumeRequest) GetReplicationFactor() int32 {
if x != nil {
return x.ReplicationFactor
}
return 0
}
type CreateVolumeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
VolumeId string `protobuf:"bytes,1,opt,name=volume_id,json=volumeId,proto3" json:"volume_id,omitempty"`
SizeBytes uint64 `protobuf:"varint,2,opt,name=size_bytes,json=sizeBytes,proto3" json:"size_bytes,omitempty"`
ReplicationFactor int32 `protobuf:"varint,3,opt,name=replication_factor,json=replicationFactor,proto3" json:"replication_factor,omitempty"`
}
func (x *CreateVolumeResponse) Reset() {
*x = CreateVolumeResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_control_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateVolumeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateVolumeResponse) ProtoMessage() {}
func (x *CreateVolumeResponse) ProtoReflect() protoreflect.Message {
mi := &file_control_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateVolumeResponse.ProtoReflect.Descriptor instead.
func (*CreateVolumeResponse) Descriptor() ([]byte, []int) {
return file_control_proto_rawDescGZIP(), []int{10}
}
func (x *CreateVolumeResponse) GetVolumeId() string {
if x != nil {
return x.VolumeId
}
return ""
}
func (x *CreateVolumeResponse) GetSizeBytes() uint64 {
if x != nil {
return x.SizeBytes
}
return 0
}
func (x *CreateVolumeResponse) GetReplicationFactor() int32 {
if x != nil {
return x.ReplicationFactor
}
return 0
}
type DeleteVolumeRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
VolumeId string `protobuf:"bytes,1,opt,name=volume_id,json=volumeId,proto3" json:"volume_id,omitempty"`
}
func (x *DeleteVolumeRequest) Reset() {
*x = DeleteVolumeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_control_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteVolumeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteVolumeRequest) ProtoMessage() {}
func (x *DeleteVolumeRequest) ProtoReflect() protoreflect.Message {
mi := &file_control_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeleteVolumeRequest.ProtoReflect.Descriptor instead.
func (*DeleteVolumeRequest) Descriptor() ([]byte, []int) {
return file_control_proto_rawDescGZIP(), []int{11}
}
func (x *DeleteVolumeRequest) GetVolumeId() string {
if x != nil {
return x.VolumeId
}
return ""
}
type DeleteVolumeResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *DeleteVolumeResponse) Reset() {
*x = DeleteVolumeResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_control_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DeleteVolumeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DeleteVolumeResponse) ProtoMessage() {}
func (x *DeleteVolumeResponse) ProtoReflect() protoreflect.Message {
mi := &file_control_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DeleteVolumeResponse.ProtoReflect.Descriptor instead.
func (*DeleteVolumeResponse) Descriptor() ([]byte, []int) {
return file_control_proto_rawDescGZIP(), []int{12}
}
var File_control_proto protoreflect.FileDescriptor
var file_control_proto_rawDesc = []byte{
@@ -949,35 +1161,71 @@ var file_control_proto_rawDesc = []byte{
0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f,
0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x72, 0x6f, 0x6e, 0x74,
0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74,
0x65, 0x6e, 0x64, 0x73, 0x32, 0x78, 0x0a, 0x12, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x62, 0x0a, 0x0f, 0x52, 0x65,
0x70, 0x6f, 0x72, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x12, 0x28, 0x2e,
0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e,
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61,
0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65,
0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
0x6c, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x41, 0x63, 0x6b, 0x32, 0x81,
0x01, 0x0a, 0x11, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x12, 0x6c, 0x0a, 0x14, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62,
0x65, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x29, 0x2e, 0x73,
0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63,
0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65,
0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
0x6c, 0x2e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x63, 0x74,
0x30, 0x01, 0x32, 0x77, 0x0a, 0x0f, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x6f,
0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x26, 0x2e, 0x73, 0x65, 0x61,
0x65, 0x6e, 0x64, 0x73, 0x22, 0x80, 0x01, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56,
0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09,
0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a,
0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73,
0x69, 0x7a, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c,
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03,
0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x81, 0x01, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61,
0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a,
0x0a, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28,
0x04, 0x52, 0x09, 0x73, 0x69, 0x7a, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12,
0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74,
0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x32, 0x0a, 0x13, 0x44,
0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22,
0x16, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x78, 0x0a, 0x12, 0x4f, 0x62, 0x73, 0x65, 0x72,
0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x62, 0x0a,
0x0f, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74,
0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f,
0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74,
0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x61,
0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e,
0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62,
0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61,
0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65,
0x64, 0x66, 0x73, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x2d, 0x62, 0x6c, 0x6f, 0x63,
0x6b, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72,
0x6f, 0x6c, 0x3b, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x41, 0x63,
0x6b, 0x32, 0x81, 0x01, 0x0a, 0x11, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6c, 0x0a, 0x14, 0x53, 0x75, 0x62, 0x73, 0x63,
0x72, 0x69, 0x62, 0x65, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12,
0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63,
0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72,
0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61,
0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e,
0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46,
0x61, 0x63, 0x74, 0x30, 0x01, 0x32, 0x77, 0x0a, 0x0f, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63,
0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72,
0x79, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x26, 0x2e,
0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e,
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66,
0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e,
0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xec,
0x01, 0x0a, 0x10, 0x4c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76,
0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c,
0x75, 0x6d, 0x65, 0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e,
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c,
0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61,
0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x6b, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65,
0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f,
0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74,
0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d,
0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56,
0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a,
0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x65, 0x61, 0x77,
0x65, 0x65, 0x64, 0x66, 0x73, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x2d, 0x62, 0x6c,
0x6f, 0x63, 0x6b, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e,
0x74, 0x72, 0x6f, 0x6c, 0x3b, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -992,37 +1240,45 @@ func file_control_proto_rawDescGZIP() []byte {
return file_control_proto_rawDescData
}
var file_control_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_control_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_control_proto_goTypes = []interface{}{
(*HeartbeatReport)(nil), // 0: seaweedfs.block.control.HeartbeatReport
(*HeartbeatSlot)(nil), // 1: seaweedfs.block.control.HeartbeatSlot
(*FrontendTarget)(nil), // 2: seaweedfs.block.control.FrontendTarget
(*HeartbeatAck)(nil), // 3: seaweedfs.block.control.HeartbeatAck
(*SubscribeRequest)(nil), // 4: seaweedfs.block.control.SubscribeRequest
(*ReplicaDescriptor)(nil), // 5: seaweedfs.block.control.ReplicaDescriptor
(*AssignmentFact)(nil), // 6: seaweedfs.block.control.AssignmentFact
(*StatusRequest)(nil), // 7: seaweedfs.block.control.StatusRequest
(*StatusResponse)(nil), // 8: seaweedfs.block.control.StatusResponse
(*timestamp.Timestamp)(nil), // 9: google.protobuf.Timestamp
(*HeartbeatReport)(nil), // 0: seaweedfs.block.control.HeartbeatReport
(*HeartbeatSlot)(nil), // 1: seaweedfs.block.control.HeartbeatSlot
(*FrontendTarget)(nil), // 2: seaweedfs.block.control.FrontendTarget
(*HeartbeatAck)(nil), // 3: seaweedfs.block.control.HeartbeatAck
(*SubscribeRequest)(nil), // 4: seaweedfs.block.control.SubscribeRequest
(*ReplicaDescriptor)(nil), // 5: seaweedfs.block.control.ReplicaDescriptor
(*AssignmentFact)(nil), // 6: seaweedfs.block.control.AssignmentFact
(*StatusRequest)(nil), // 7: seaweedfs.block.control.StatusRequest
(*StatusResponse)(nil), // 8: seaweedfs.block.control.StatusResponse
(*CreateVolumeRequest)(nil), // 9: seaweedfs.block.control.CreateVolumeRequest
(*CreateVolumeResponse)(nil), // 10: seaweedfs.block.control.CreateVolumeResponse
(*DeleteVolumeRequest)(nil), // 11: seaweedfs.block.control.DeleteVolumeRequest
(*DeleteVolumeResponse)(nil), // 12: seaweedfs.block.control.DeleteVolumeResponse
(*timestamp.Timestamp)(nil), // 13: google.protobuf.Timestamp
}
var file_control_proto_depIdxs = []int32{
9, // 0: seaweedfs.block.control.HeartbeatReport.sent_at:type_name -> google.protobuf.Timestamp
1, // 1: seaweedfs.block.control.HeartbeatReport.slots:type_name -> seaweedfs.block.control.HeartbeatSlot
2, // 2: seaweedfs.block.control.HeartbeatSlot.frontends:type_name -> seaweedfs.block.control.FrontendTarget
9, // 3: seaweedfs.block.control.HeartbeatAck.accepted_at:type_name -> google.protobuf.Timestamp
5, // 4: seaweedfs.block.control.AssignmentFact.peers:type_name -> seaweedfs.block.control.ReplicaDescriptor
2, // 5: seaweedfs.block.control.StatusResponse.frontends:type_name -> seaweedfs.block.control.FrontendTarget
0, // 6: seaweedfs.block.control.ObservationService.ReportHeartbeat:input_type -> seaweedfs.block.control.HeartbeatReport
4, // 7: seaweedfs.block.control.AssignmentService.SubscribeAssignments:input_type -> seaweedfs.block.control.SubscribeRequest
7, // 8: seaweedfs.block.control.EvidenceService.QueryVolumeStatus:input_type -> seaweedfs.block.control.StatusRequest
3, // 9: seaweedfs.block.control.ObservationService.ReportHeartbeat:output_type -> seaweedfs.block.control.HeartbeatAck
6, // 10: seaweedfs.block.control.AssignmentService.SubscribeAssignments:output_type -> seaweedfs.block.control.AssignmentFact
8, // 11: seaweedfs.block.control.EvidenceService.QueryVolumeStatus:output_type -> seaweedfs.block.control.StatusResponse
9, // [9:12] is the sub-list for method output_type
6, // [6:9] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
13, // 0: seaweedfs.block.control.HeartbeatReport.sent_at:type_name -> google.protobuf.Timestamp
1, // 1: seaweedfs.block.control.HeartbeatReport.slots:type_name -> seaweedfs.block.control.HeartbeatSlot
2, // 2: seaweedfs.block.control.HeartbeatSlot.frontends:type_name -> seaweedfs.block.control.FrontendTarget
13, // 3: seaweedfs.block.control.HeartbeatAck.accepted_at:type_name -> google.protobuf.Timestamp
5, // 4: seaweedfs.block.control.AssignmentFact.peers:type_name -> seaweedfs.block.control.ReplicaDescriptor
2, // 5: seaweedfs.block.control.StatusResponse.frontends:type_name -> seaweedfs.block.control.FrontendTarget
0, // 6: seaweedfs.block.control.ObservationService.ReportHeartbeat:input_type -> seaweedfs.block.control.HeartbeatReport
4, // 7: seaweedfs.block.control.AssignmentService.SubscribeAssignments:input_type -> seaweedfs.block.control.SubscribeRequest
7, // 8: seaweedfs.block.control.EvidenceService.QueryVolumeStatus:input_type -> seaweedfs.block.control.StatusRequest
9, // 9: seaweedfs.block.control.LifecycleService.CreateVolume:input_type -> seaweedfs.block.control.CreateVolumeRequest
11, // 10: seaweedfs.block.control.LifecycleService.DeleteVolume:input_type -> seaweedfs.block.control.DeleteVolumeRequest
3, // 11: seaweedfs.block.control.ObservationService.ReportHeartbeat:output_type -> seaweedfs.block.control.HeartbeatAck
6, // 12: seaweedfs.block.control.AssignmentService.SubscribeAssignments:output_type -> seaweedfs.block.control.AssignmentFact
8, // 13: seaweedfs.block.control.EvidenceService.QueryVolumeStatus:output_type -> seaweedfs.block.control.StatusResponse
10, // 14: seaweedfs.block.control.LifecycleService.CreateVolume:output_type -> seaweedfs.block.control.CreateVolumeResponse
12, // 15: seaweedfs.block.control.LifecycleService.DeleteVolume:output_type -> seaweedfs.block.control.DeleteVolumeResponse
11, // [11:16] is the sub-list for method output_type
6, // [6:11] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
}
func init() { file_control_proto_init() }
@@ -1139,6 +1395,54 @@ func file_control_proto_init() {
return nil
}
}
file_control_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateVolumeRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_control_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateVolumeResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_control_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteVolumeRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_control_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteVolumeResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -1146,9 +1450,9 @@ func file_control_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_control_proto_rawDesc,
NumEnums: 0,
NumMessages: 9,
NumMessages: 13,
NumExtensions: 0,
NumServices: 3,
NumServices: 4,
},
GoTypes: file_control_proto_goTypes,
DependencyIndexes: file_control_proto_depIdxs,
@@ -4,6 +4,7 @@
// volume -> master: ObservationService.ReportHeartbeat (unary)
// volume -> master: AssignmentService.SubscribeAssignments (server-streaming)
// operator -> master: EvidenceService.QueryVolumeStatus (unary, read-only)
// CSI/operator -> master: LifecycleService.CreateVolume/DeleteVolume (desired intent only)
//
// Boundary (T0 sketch §3 load-bearing):
// - no message carries an AssignmentAsk
@@ -351,3 +352,130 @@ var EvidenceService_ServiceDesc = grpc.ServiceDesc{
Streams: []grpc.StreamDesc{},
Metadata: "control.proto",
}
const (
LifecycleService_CreateVolume_FullMethodName = "/seaweedfs.block.control.LifecycleService/CreateVolume"
LifecycleService_DeleteVolume_FullMethodName = "/seaweedfs.block.control.LifecycleService/DeleteVolume"
)
// LifecycleServiceClient is the client API for LifecycleService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type LifecycleServiceClient interface {
CreateVolume(ctx context.Context, in *CreateVolumeRequest, opts ...grpc.CallOption) (*CreateVolumeResponse, error)
DeleteVolume(ctx context.Context, in *DeleteVolumeRequest, opts ...grpc.CallOption) (*DeleteVolumeResponse, error)
}
type lifecycleServiceClient struct {
cc grpc.ClientConnInterface
}
func NewLifecycleServiceClient(cc grpc.ClientConnInterface) LifecycleServiceClient {
return &lifecycleServiceClient{cc}
}
func (c *lifecycleServiceClient) CreateVolume(ctx context.Context, in *CreateVolumeRequest, opts ...grpc.CallOption) (*CreateVolumeResponse, error) {
out := new(CreateVolumeResponse)
err := c.cc.Invoke(ctx, LifecycleService_CreateVolume_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *lifecycleServiceClient) DeleteVolume(ctx context.Context, in *DeleteVolumeRequest, opts ...grpc.CallOption) (*DeleteVolumeResponse, error) {
out := new(DeleteVolumeResponse)
err := c.cc.Invoke(ctx, LifecycleService_DeleteVolume_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// LifecycleServiceServer is the server API for LifecycleService service.
// All implementations must embed UnimplementedLifecycleServiceServer
// for forward compatibility
type LifecycleServiceServer interface {
CreateVolume(context.Context, *CreateVolumeRequest) (*CreateVolumeResponse, error)
DeleteVolume(context.Context, *DeleteVolumeRequest) (*DeleteVolumeResponse, error)
mustEmbedUnimplementedLifecycleServiceServer()
}
// UnimplementedLifecycleServiceServer must be embedded to have forward compatible implementations.
type UnimplementedLifecycleServiceServer struct {
}
func (UnimplementedLifecycleServiceServer) CreateVolume(context.Context, *CreateVolumeRequest) (*CreateVolumeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateVolume not implemented")
}
func (UnimplementedLifecycleServiceServer) DeleteVolume(context.Context, *DeleteVolumeRequest) (*DeleteVolumeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteVolume not implemented")
}
func (UnimplementedLifecycleServiceServer) mustEmbedUnimplementedLifecycleServiceServer() {}
// UnsafeLifecycleServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to LifecycleServiceServer will
// result in compilation errors.
type UnsafeLifecycleServiceServer interface {
mustEmbedUnimplementedLifecycleServiceServer()
}
func RegisterLifecycleServiceServer(s grpc.ServiceRegistrar, srv LifecycleServiceServer) {
s.RegisterService(&LifecycleService_ServiceDesc, srv)
}
func _LifecycleService_CreateVolume_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateVolumeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LifecycleServiceServer).CreateVolume(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LifecycleService_CreateVolume_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LifecycleServiceServer).CreateVolume(ctx, req.(*CreateVolumeRequest))
}
return interceptor(ctx, in, info, handler)
}
func _LifecycleService_DeleteVolume_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteVolumeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LifecycleServiceServer).DeleteVolume(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LifecycleService_DeleteVolume_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LifecycleServiceServer).DeleteVolume(ctx, req.(*DeleteVolumeRequest))
}
return interceptor(ctx, in, info, handler)
}
// LifecycleService_ServiceDesc is the grpc.ServiceDesc for LifecycleService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var LifecycleService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "seaweedfs.block.control.LifecycleService",
HandlerType: (*LifecycleServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateVolume",
Handler: _LifecycleService_CreateVolume_Handler,
},
{
MethodName: "DeleteVolume",
Handler: _LifecycleService_DeleteVolume_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "control.proto",
}
@@ -4,6 +4,7 @@
// volume -> master: ObservationService.ReportHeartbeat (unary)
// volume -> master: AssignmentService.SubscribeAssignments (server-streaming)
// operator -> master: EvidenceService.QueryVolumeStatus (unary, read-only)
// CSI/operator -> master: LifecycleService.CreateVolume/DeleteVolume (desired intent only)
//
// Boundary (T0 sketch §3 load-bearing):
// - no message carries an AssignmentAsk
@@ -59,6 +60,14 @@ service EvidenceService {
rpc QueryVolumeStatus(StatusRequest) returns (StatusResponse);
}
// LifecycleService — product lifecycle intent. This surface is for CSI /
// operators to record desired volume state. It MUST NOT carry assignment,
// epoch, endpoint_version, readiness, or primary facts.
service LifecycleService {
rpc CreateVolume(CreateVolumeRequest) returns (CreateVolumeResponse);
rpc DeleteVolume(DeleteVolumeRequest) returns (DeleteVolumeResponse);
}
// HeartbeatReport — volume -> master observation fact. Field set
// field-compatible with authority.HeartbeatMessage (P14 S4 wire).
// No authority-mutation fields of any kind.
@@ -180,3 +189,22 @@ message StatusResponse {
string last_convergence_stuck_at = 7;
repeated FrontendTarget frontends = 8;
}
message CreateVolumeRequest {
string volume_id = 1;
uint64 size_bytes = 2;
int32 replication_factor = 3;
}
message CreateVolumeResponse {
string volume_id = 1;
uint64 size_bytes = 2;
int32 replication_factor = 3;
}
message DeleteVolumeRequest {
string volume_id = 1;
}
message DeleteVolumeResponse {
}