From e9828532be43eb0e839a51fbe8ca4effc1e308a8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 4 May 2026 13:09:54 -0700 Subject: [PATCH] csi: preserve Kubernetes volume metadata --- .../cmd/blockcsi/g15d_manifest_test.go | 8 + seaweed-block/core/csi/backend.go | 3 + seaweed-block/core/csi/controller.go | 3 + seaweed-block/core/csi/controller_test.go | 12 +- seaweed-block/core/csi/master_backend.go | 6 + seaweed-block/core/csi/master_backend_test.go | 12 ++ .../host/master/lifecycle_service_test.go | 9 + seaweed-block/core/host/master/services.go | 6 + seaweed-block/core/lifecycle/store.go | 3 + seaweed-block/core/lifecycle/store_test.go | 9 +- seaweed-block/core/rpc/control/control.pb.go | 169 ++++++++++++------ seaweed-block/core/rpc/proto/control.proto | 6 + .../deploy/k8s/alpha/csi-controller.yaml | 1 + .../deploy/k8s/g15d/csi-controller.yaml | 1 + 14 files changed, 191 insertions(+), 57 deletions(-) diff --git a/seaweed-block/cmd/blockcsi/g15d_manifest_test.go b/seaweed-block/cmd/blockcsi/g15d_manifest_test.go index 691f960876..f102715289 100644 --- a/seaweed-block/cmd/blockcsi/g15d_manifest_test.go +++ b/seaweed-block/cmd/blockcsi/g15d_manifest_test.go @@ -31,6 +31,7 @@ func TestG15d_K8sCSIController_IncludesExternalProvisioner(t *testing.T) { "registry.k8s.io/sig-storage/csi-provisioner:", "name: csi-attacher", "--csi-address=/csi/csi.sock", + "--extra-create-metadata=true", } { if !strings.Contains(body, want) { t.Fatalf("csi-controller missing %q", want) @@ -38,6 +39,13 @@ func TestG15d_K8sCSIController_IncludesExternalProvisioner(t *testing.T) { } } +func TestAlphaK8sCSIController_IncludesCreateMetadata(t *testing.T) { + body := g15dReadFile(t, "deploy", "k8s", "alpha", "csi-controller.yaml") + if !strings.Contains(body, "--extra-create-metadata=true") { + t.Fatalf("alpha csi-controller must enable PVC metadata propagation:\n%s", body) + } +} + func TestG15d_K8sDynamicPVC_UsesStorageClassNoPrecreatedPV(t *testing.T) { body := g15dReadFile(t, "deploy", "k8s", "g15d", "dynamic-pvc-pod.yaml") for _, want := range []string{ diff --git a/seaweed-block/core/csi/backend.go b/seaweed-block/core/csi/backend.go index b4cec00c40..e3c0e9bdfe 100644 --- a/seaweed-block/core/csi/backend.go +++ b/seaweed-block/core/csi/backend.go @@ -47,6 +47,9 @@ type VolumeSpec struct { VolumeID string SizeBytes uint64 ReplicationFactor int + PVCName string + PVCNamespace string + PVName string } func publishContext(t PublishTarget) map[string]string { diff --git a/seaweed-block/core/csi/controller.go b/seaweed-block/core/csi/controller.go index c7d9f98fb2..0c70c2b1c2 100644 --- a/seaweed-block/core/csi/controller.go +++ b/seaweed-block/core/csi/controller.go @@ -161,6 +161,9 @@ func volumeSpecFromCreateRequest(req *csipb.CreateVolumeRequest) (VolumeSpec, er VolumeID: req.GetName(), SizeBytes: uint64(size), ReplicationFactor: rf, + PVCName: req.GetParameters()["csi.storage.k8s.io/pvc/name"], + PVCNamespace: req.GetParameters()["csi.storage.k8s.io/pvc/namespace"], + PVName: req.GetParameters()["csi.storage.k8s.io/pv/name"], }, nil } diff --git a/seaweed-block/core/csi/controller_test.go b/seaweed-block/core/csi/controller_test.go index 53cd559387..f117a700e0 100644 --- a/seaweed-block/core/csi/controller_test.go +++ b/seaweed-block/core/csi/controller_test.go @@ -173,7 +173,14 @@ func TestG15c_ControllerCreateVolume_RecordsDesiredIntentOnly(t *testing.T) { CapacityRange: &csipb.CapacityRange{ RequiredBytes: 1 << 30, }, - Parameters: map[string]string{"replicationFactor": "2"}, + Parameters: map[string]string{ + "replicationFactor": "2", + "csi.storage.k8s.io/pvc/name": "demo-pvc", + "csi.storage.k8s.io/pvc/namespace": "demo-ns", + "csi.storage.k8s.io/pv/name": "pvc-a", + "csi.storage.k8s.io/pvc/uid": "uid-not-yet-persisted", + "csi.storage.k8s.io/serviceAccount.name": "ignored", + }, VolumeCapabilities: []*csipb.VolumeCapability{ testVolumeCapability(), }, @@ -187,6 +194,9 @@ func TestG15c_ControllerCreateVolume_RecordsDesiredIntentOnly(t *testing.T) { if got := prov.calls[0]; got.VolumeID != "pvc-a" || got.SizeBytes != 1<<30 || got.ReplicationFactor != 2 { t.Fatalf("spec=%+v", got) } + if got := prov.calls[0]; got.PVCName != "demo-pvc" || got.PVCNamespace != "demo-ns" || got.PVName != "pvc-a" { + t.Fatalf("kubernetes metadata not preserved: %+v", got) + } vol := resp.GetVolume() if vol.GetVolumeId() != "pvc-a" || vol.GetCapacityBytes() != 1<<30 { t.Fatalf("volume=%+v", vol) diff --git a/seaweed-block/core/csi/master_backend.go b/seaweed-block/core/csi/master_backend.go index 6619ac63d3..948924c3ff 100644 --- a/seaweed-block/core/csi/master_backend.go +++ b/seaweed-block/core/csi/master_backend.go @@ -35,6 +35,9 @@ func (p *ControlLifecycleProvisioner) CreateVolume(ctx context.Context, spec Vol VolumeId: spec.VolumeID, SizeBytes: spec.SizeBytes, ReplicationFactor: int32(spec.ReplicationFactor), + PvcName: spec.PVCName, + PvcNamespace: spec.PVCNamespace, + PvName: spec.PVName, }) if err != nil { return VolumeSpec{}, err @@ -43,6 +46,9 @@ func (p *ControlLifecycleProvisioner) CreateVolume(ctx context.Context, spec Vol VolumeID: resp.GetVolumeId(), SizeBytes: resp.GetSizeBytes(), ReplicationFactor: int(resp.GetReplicationFactor()), + PVCName: resp.GetPvcName(), + PVCNamespace: resp.GetPvcNamespace(), + PVName: resp.GetPvName(), }, nil } diff --git a/seaweed-block/core/csi/master_backend_test.go b/seaweed-block/core/csi/master_backend_test.go index d069015e79..55775e1539 100644 --- a/seaweed-block/core/csi/master_backend_test.go +++ b/seaweed-block/core/csi/master_backend_test.go @@ -104,6 +104,9 @@ func (f *fakeLifecycleClient) CreateVolume(_ context.Context, req *control.Creat VolumeId: req.GetVolumeId(), SizeBytes: req.GetSizeBytes(), ReplicationFactor: req.GetReplicationFactor(), + PvcName: req.GetPvcName(), + PvcNamespace: req.GetPvcNamespace(), + PvName: req.GetPvName(), }, nil } @@ -119,6 +122,9 @@ func TestG15c_ControlLifecycleProvisioner_CreateVolumeRoundTrip(t *testing.T) { VolumeID: "pvc-a", SizeBytes: 1 << 30, ReplicationFactor: 2, + PVCName: "demo-pvc", + PVCNamespace: "demo-ns", + PVName: "pvc-a", }) if err != nil { t.Fatalf("CreateVolume: %v", err) @@ -126,9 +132,15 @@ func TestG15c_ControlLifecycleProvisioner_CreateVolumeRoundTrip(t *testing.T) { if client.createReq.GetVolumeId() != "pvc-a" || client.createReq.GetSizeBytes() != 1<<30 || client.createReq.GetReplicationFactor() != 2 { t.Fatalf("request=%+v", client.createReq) } + if client.createReq.GetPvcName() != "demo-pvc" || client.createReq.GetPvcNamespace() != "demo-ns" || client.createReq.GetPvName() != "pvc-a" { + t.Fatalf("kubernetes metadata request=%+v", client.createReq) + } if got.VolumeID != "pvc-a" || got.SizeBytes != 1<<30 || got.ReplicationFactor != 2 { t.Fatalf("spec=%+v", got) } + if got.PVCName != "demo-pvc" || got.PVCNamespace != "demo-ns" || got.PVName != "pvc-a" { + t.Fatalf("kubernetes metadata spec=%+v", got) + } } func TestG15c_ControlLifecycleProvisioner_DeleteVolumeRoundTrip(t *testing.T) { diff --git a/seaweed-block/core/host/master/lifecycle_service_test.go b/seaweed-block/core/host/master/lifecycle_service_test.go index 4b7e1db7e5..6cd1d557fc 100644 --- a/seaweed-block/core/host/master/lifecycle_service_test.go +++ b/seaweed-block/core/host/master/lifecycle_service_test.go @@ -20,6 +20,9 @@ func TestG15c_LifecycleService_CreateVolumePersistsDesiredIntent(t *testing.T) { VolumeId: "pvc-a", SizeBytes: 1 << 30, ReplicationFactor: 2, + PvcName: "demo-pvc", + PvcNamespace: "demo-ns", + PvName: "pvc-a", }) if err != nil { t.Fatalf("CreateVolume: %v", err) @@ -27,6 +30,9 @@ func TestG15c_LifecycleService_CreateVolumePersistsDesiredIntent(t *testing.T) { if resp.GetVolumeId() != "pvc-a" || resp.GetSizeBytes() != 1<<30 || resp.GetReplicationFactor() != 2 { t.Fatalf("response=%+v", resp) } + if resp.GetPvcName() != "demo-pvc" || resp.GetPvcNamespace() != "demo-ns" || resp.GetPvName() != "pvc-a" { + t.Fatalf("kubernetes metadata response=%+v", resp) + } rec, ok := h.Lifecycle().Volumes.GetVolume("pvc-a") if !ok { t.Fatal("desired volume not persisted") @@ -34,6 +40,9 @@ func TestG15c_LifecycleService_CreateVolumePersistsDesiredIntent(t *testing.T) { if rec.Spec.VolumeID != "pvc-a" || rec.Spec.SizeBytes != 1<<30 || rec.Spec.ReplicationFactor != 2 { t.Fatalf("record=%+v", rec) } + if rec.Spec.PVCName != "demo-pvc" || rec.Spec.PVCNamespace != "demo-ns" || rec.Spec.PVName != "pvc-a" { + t.Fatalf("kubernetes metadata record=%+v", rec) + } if _, ok := h.Publisher().VolumeAuthorityLine("pvc-a"); ok { t.Fatal("CreateVolume must not mint authority") } diff --git a/seaweed-block/core/host/master/services.go b/seaweed-block/core/host/master/services.go index 8b40fdcda6..7262ccb5da 100644 --- a/seaweed-block/core/host/master/services.go +++ b/seaweed-block/core/host/master/services.go @@ -59,6 +59,9 @@ func (s *services) CreateVolume(ctx context.Context, req *control.CreateVolumeRe VolumeId: rec.Spec.VolumeID, SizeBytes: rec.Spec.SizeBytes, ReplicationFactor: int32(rec.Spec.ReplicationFactor), + PvcName: rec.Spec.PVCName, + PvcNamespace: rec.Spec.PVCNamespace, + PvName: rec.Spec.PVName, }, nil } @@ -105,6 +108,9 @@ func lifecycleSpecFromWire(req *control.CreateVolumeRequest) lifecycle.VolumeSpe VolumeID: req.GetVolumeId(), SizeBytes: req.GetSizeBytes(), ReplicationFactor: int(req.GetReplicationFactor()), + PVCName: req.GetPvcName(), + PVCNamespace: req.GetPvcNamespace(), + PVName: req.GetPvName(), } } diff --git a/seaweed-block/core/lifecycle/store.go b/seaweed-block/core/lifecycle/store.go index cde71af59e..93aae558fa 100644 --- a/seaweed-block/core/lifecycle/store.go +++ b/seaweed-block/core/lifecycle/store.go @@ -33,6 +33,9 @@ type VolumeSpec struct { VolumeID string `json:"volume_id"` SizeBytes uint64 `json:"size_bytes"` ReplicationFactor int `json:"replication_factor"` + PVCName string `json:"pvc_name,omitempty"` + PVCNamespace string `json:"pvc_namespace,omitempty"` + PVName string `json:"pv_name,omitempty"` } // VolumeRecord is the durable lifecycle state for one volume. diff --git a/seaweed-block/core/lifecycle/store_test.go b/seaweed-block/core/lifecycle/store_test.go index 6123d467a3..76fa22b386 100644 --- a/seaweed-block/core/lifecycle/store_test.go +++ b/seaweed-block/core/lifecycle/store_test.go @@ -16,7 +16,14 @@ func TestFileStore_CreateVolumePersistsAndIsIdempotent(t *testing.T) { if err != nil { t.Fatalf("open: %v", err) } - spec := VolumeSpec{VolumeID: "vol-a", SizeBytes: 1 << 20, ReplicationFactor: 2} + spec := VolumeSpec{ + VolumeID: "vol-a", + SizeBytes: 1 << 20, + ReplicationFactor: 2, + PVCName: "demo-pvc", + PVCNamespace: "demo-ns", + PVName: "pvc-a", + } rec, err := s.CreateVolume(spec) if err != nil { t.Fatalf("create: %v", err) diff --git a/seaweed-block/core/rpc/control/control.pb.go b/seaweed-block/core/rpc/control/control.pb.go index 141537e754..180a01b4ac 100644 --- a/seaweed-block/core/rpc/control/control.pb.go +++ b/seaweed-block/core/rpc/control/control.pb.go @@ -832,6 +832,9 @@ type CreateVolumeRequest struct { 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"` + PvcName string `protobuf:"bytes,4,opt,name=pvc_name,json=pvcName,proto3" json:"pvc_name,omitempty"` + PvcNamespace string `protobuf:"bytes,5,opt,name=pvc_namespace,json=pvcNamespace,proto3" json:"pvc_namespace,omitempty"` + PvName string `protobuf:"bytes,6,opt,name=pv_name,json=pvName,proto3" json:"pv_name,omitempty"` } func (x *CreateVolumeRequest) Reset() { @@ -887,6 +890,27 @@ func (x *CreateVolumeRequest) GetReplicationFactor() int32 { return 0 } +func (x *CreateVolumeRequest) GetPvcName() string { + if x != nil { + return x.PvcName + } + return "" +} + +func (x *CreateVolumeRequest) GetPvcNamespace() string { + if x != nil { + return x.PvcNamespace + } + return "" +} + +func (x *CreateVolumeRequest) GetPvName() string { + if x != nil { + return x.PvName + } + return "" +} + type CreateVolumeResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -895,6 +919,9 @@ type CreateVolumeResponse struct { 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"` + PvcName string `protobuf:"bytes,4,opt,name=pvc_name,json=pvcName,proto3" json:"pvc_name,omitempty"` + PvcNamespace string `protobuf:"bytes,5,opt,name=pvc_namespace,json=pvcNamespace,proto3" json:"pvc_namespace,omitempty"` + PvName string `protobuf:"bytes,6,opt,name=pv_name,json=pvName,proto3" json:"pv_name,omitempty"` } func (x *CreateVolumeResponse) Reset() { @@ -950,6 +977,27 @@ func (x *CreateVolumeResponse) GetReplicationFactor() int32 { return 0 } +func (x *CreateVolumeResponse) GetPvcName() string { + if x != nil { + return x.PvcName + } + return "" +} + +func (x *CreateVolumeResponse) GetPvcNamespace() string { + if x != nil { + return x.PvcNamespace + } + return "" +} + +func (x *CreateVolumeResponse) GetPvName() string { + if x != nil { + return x.PvName + } + return "" +} + type DeleteVolumeRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1161,7 +1209,7 @@ 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, 0x22, 0x80, 0x01, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, + 0x65, 0x6e, 0x64, 0x73, 0x22, 0xd9, 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, @@ -1169,63 +1217,74 @@ var file_control_proto_rawDesc = []byte{ 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, 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, + 0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, 0x61, + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, + 0x22, 0xda, 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, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x23, 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 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, 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, - 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, + 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, 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, + 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, 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, + 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 ( diff --git a/seaweed-block/core/rpc/proto/control.proto b/seaweed-block/core/rpc/proto/control.proto index 2c9a3ac3c7..2a559f1ebe 100644 --- a/seaweed-block/core/rpc/proto/control.proto +++ b/seaweed-block/core/rpc/proto/control.proto @@ -194,12 +194,18 @@ message CreateVolumeRequest { string volume_id = 1; uint64 size_bytes = 2; int32 replication_factor = 3; + string pvc_name = 4; + string pvc_namespace = 5; + string pv_name = 6; } message CreateVolumeResponse { string volume_id = 1; uint64 size_bytes = 2; int32 replication_factor = 3; + string pvc_name = 4; + string pvc_namespace = 5; + string pv_name = 6; } message DeleteVolumeRequest { diff --git a/seaweed-block/deploy/k8s/alpha/csi-controller.yaml b/seaweed-block/deploy/k8s/alpha/csi-controller.yaml index e09037fa6e..4efdd74a16 100644 --- a/seaweed-block/deploy/k8s/alpha/csi-controller.yaml +++ b/seaweed-block/deploy/k8s/alpha/csi-controller.yaml @@ -38,6 +38,7 @@ spec: - "--csi-address=/csi/csi.sock" - "--timeout=30s" - "--leader-election=true" + - "--extra-create-metadata=true" volumeMounts: - name: socket-dir mountPath: /csi diff --git a/seaweed-block/deploy/k8s/g15d/csi-controller.yaml b/seaweed-block/deploy/k8s/g15d/csi-controller.yaml index e09037fa6e..4efdd74a16 100644 --- a/seaweed-block/deploy/k8s/g15d/csi-controller.yaml +++ b/seaweed-block/deploy/k8s/g15d/csi-controller.yaml @@ -38,6 +38,7 @@ spec: - "--csi-address=/csi/csi.sock" - "--timeout=30s" - "--leader-election=true" + - "--extra-create-metadata=true" volumeMounts: - name: socket-dir mountPath: /csi