mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
Merge pull request #39 from seaweedfs/k8s-alpha/pvc-metadata
csi: preserve PVC metadata for generated workloads
This commit is contained in:
commit
d10f81a0e4
23 files changed
+710
-96
No files matched your search
@@ -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{
|
||||
@@ -59,12 +67,17 @@ func TestG15d_K8sRunner_AppliesLauncherGeneratedManifest(t *testing.T) {
|
||||
body := g15dReadFile(t, "scripts", "run-g15d-k8s-dynamic.sh")
|
||||
for _, want := range []string{
|
||||
"generated-blockvolume.yaml",
|
||||
"SW_BLOCK_LAUNCHER_PVC_OWNER_REF",
|
||||
"BLOCKVOLUME_NAMESPACE=\"kube-system\"",
|
||||
"--kubernetes-pvc-uid-lookup",
|
||||
"--launcher-pvc-owner-ref",
|
||||
"kubectl apply -f \"$ARTIFACT_DIR/generated-blockvolume.yaml\"",
|
||||
"kubectl -n kube-system wait --for=condition=available deploy -l app=sw-blockvolume",
|
||||
"kubectl -n kube-system logs -l sw-block.seaweedfs.com/volume",
|
||||
"kubectl -n \"$BLOCKVOLUME_NAMESPACE\" wait --for=condition=available deploy -l app=sw-blockvolume",
|
||||
"kubectl -n \"$BLOCKVOLUME_NAMESPACE\" logs -l sw-block.seaweedfs.com/volume",
|
||||
"kubectl -n \"$NAMESPACE\" delete pvc sw-block-dynamic-v1",
|
||||
"wait for launcher manifest cleanup after DeleteVolume",
|
||||
"delete generated blockvolume Deployment after manifest cleanup",
|
||||
"wait for Kubernetes GC to delete PVC-owned blockvolume Deployment",
|
||||
"iscsi-sessions.after-delete.txt",
|
||||
"PASS: dynamic PVC create/delete completed checksum write/read and cleanup",
|
||||
} {
|
||||
@@ -74,6 +87,24 @@ func TestG15d_K8sRunner_AppliesLauncherGeneratedManifest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAlphaScripts_OwnerRefModeInjectsBothLauncherAndCSILookupFlags(t *testing.T) {
|
||||
for _, script := range []string{"run-g15d-k8s-dynamic.sh", "run-alpha-app-demo.sh"} {
|
||||
t.Run(script, func(t *testing.T) {
|
||||
body := g15dReadFile(t, "scripts", script)
|
||||
for _, want := range []string{
|
||||
"SW_BLOCK_LAUNCHER_PVC_OWNER_REF",
|
||||
"--launcher-pvc-owner-ref",
|
||||
"--kubernetes-pvc-uid-lookup",
|
||||
"BLOCKVOLUME_NAMESPACE=\"$NAMESPACE\"",
|
||||
} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Fatalf("%s missing %q", script, want)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func g15dReadFile(t *testing.T, parts ...string) string {
|
||||
t.Helper()
|
||||
root := g15bRepoRoot(t)
|
||||
|
||||
@@ -28,6 +28,7 @@ type flags struct {
|
||||
masterAddr string
|
||||
nodeID string
|
||||
iqnPrefix string
|
||||
pvcUIDLookup bool
|
||||
printReadyLine bool
|
||||
}
|
||||
|
||||
@@ -38,6 +39,7 @@ func parseFlags(args []string) (flags, error) {
|
||||
fs.StringVar(&f.masterAddr, "master", "", "blockmaster gRPC address for read-only publish-target lookup")
|
||||
fs.StringVar(&f.nodeID, "node-id", "", "CSI node ID; defaults to hostname")
|
||||
fs.StringVar(&f.iqnPrefix, "iqn-prefix", "iqn.2026-05.io.seaweedfs", "fallback IQN prefix for unstage after plugin restart")
|
||||
fs.BoolVar(&f.pvcUIDLookup, "kubernetes-pvc-uid-lookup", false, "opt-in: resolve PVC UID through the in-cluster Kubernetes API before CreateVolume is sent to blockmaster")
|
||||
fs.BoolVar(&f.printReadyLine, "t0-print-ready", false, "internal test-only: emit one structured JSON ready line after listener bind")
|
||||
fs.SetOutput(os.Stderr)
|
||||
if err := fs.Parse(args); err != nil {
|
||||
@@ -97,6 +99,7 @@ func run(f flags) int {
|
||||
masterConn *grpc.ClientConn
|
||||
lookup blockcsi.PublishTargetLookup
|
||||
provisioner blockcsi.VolumeProvisioner
|
||||
resolver blockcsi.KubernetesMetadataResolver
|
||||
)
|
||||
if f.masterAddr != "" {
|
||||
masterConn, err = grpc.NewClient(f.masterAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
@@ -108,10 +111,17 @@ func run(f flags) int {
|
||||
lookup = blockcsi.NewControlStatusLookup(control.NewEvidenceServiceClient(masterConn))
|
||||
provisioner = blockcsi.NewControlLifecycleProvisioner(control.NewLifecycleServiceClient(masterConn))
|
||||
}
|
||||
if f.pvcUIDLookup && provisioner != nil {
|
||||
resolver, err = blockcsi.NewInClusterPVCMetadataResolver()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "blockcsi: pvc uid lookup:", err)
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
srv := grpc.NewServer()
|
||||
csipb.RegisterIdentityServer(srv, blockcsi.NewIdentityServer())
|
||||
csipb.RegisterControllerServer(srv, blockcsi.NewControllerServerWithProvisioner(lookup, provisioner))
|
||||
csipb.RegisterControllerServer(srv, blockcsi.NewControllerServerWithProvisionerAndMetadataResolver(lookup, provisioner, resolver))
|
||||
csipb.RegisterNodeServer(srv, blockcsi.NewDefaultNodeServer(f.nodeID, f.iqnPrefix))
|
||||
|
||||
if f.printReadyLine {
|
||||
|
||||
@@ -36,6 +36,7 @@ type flags struct {
|
||||
launcherMasterAddr string
|
||||
launcherDurableRoot string
|
||||
launcherISCSIPortBase int
|
||||
launcherPVCOwnerRef bool
|
||||
// printReadyLine: test-only flag that emits a single
|
||||
// structured JSON line to stdout after the gRPC listener is
|
||||
// bound, so L2 subprocess tests can parse the ready event.
|
||||
@@ -63,6 +64,7 @@ func parseFlags(args []string) (flags, error) {
|
||||
fs.StringVar(&f.launcherMasterAddr, "launcher-master-addr", "", "G15d master address used in rendered blockvolume args; defaults to listener address after bind")
|
||||
fs.StringVar(&f.launcherDurableRoot, "launcher-durable-root", "/var/lib/sw-block", "G15d rendered blockvolume durable root base")
|
||||
fs.IntVar(&f.launcherISCSIPortBase, "launcher-iscsi-port-base", 3260, "G15d iSCSI port base for generated blockvolume workloads")
|
||||
fs.BoolVar(&f.launcherPVCOwnerRef, "launcher-pvc-owner-ref", false, "render generated blockvolume Deployments in the source PVC namespace with a PVC ownerReference; disabled by default for alpha harness compatibility")
|
||||
fs.BoolVar(&f.printReadyLine, "t0-print-ready", false, "internal test-only: emit one structured JSON line on stdout after listener bound")
|
||||
fs.SetOutput(os.Stderr)
|
||||
if err := fs.Parse(args); err != nil {
|
||||
@@ -280,10 +282,11 @@ func runLifecycleLauncherTick(h *master.Host, f flags) error {
|
||||
var rendered []launcher.RenderedManifest
|
||||
for _, plan := range result.Plans {
|
||||
manifests, err := launcher.RenderBlockVolumeDeployments(plan, launcher.K8sRenderConfig{
|
||||
Namespace: f.launcherNamespace,
|
||||
Image: f.launcherImage,
|
||||
MasterAddr: masterAddr,
|
||||
DurableRootBase: f.launcherDurableRoot,
|
||||
Namespace: f.launcherNamespace,
|
||||
Image: f.launcherImage,
|
||||
MasterAddr: masterAddr,
|
||||
DurableRootBase: f.launcherDurableRoot,
|
||||
OwnerReferenceToPVC: f.launcherPVCOwnerRef,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -43,10 +43,18 @@ type VolumeProvisioner interface {
|
||||
DeleteVolume(ctx context.Context, volumeID string) error
|
||||
}
|
||||
|
||||
type KubernetesMetadataResolver interface {
|
||||
ResolvePVCUID(ctx context.Context, name, namespace string) (string, error)
|
||||
}
|
||||
|
||||
type VolumeSpec struct {
|
||||
VolumeID string
|
||||
SizeBytes uint64
|
||||
ReplicationFactor int
|
||||
PVCName string
|
||||
PVCNamespace string
|
||||
PVCUID string
|
||||
PVName string
|
||||
}
|
||||
|
||||
func publishContext(t PublishTarget) map[string]string {
|
||||
|
||||
@@ -12,8 +12,9 @@ import (
|
||||
|
||||
type ControllerServer struct {
|
||||
csipb.UnimplementedControllerServer
|
||||
lookup PublishTargetLookup
|
||||
provisioner VolumeProvisioner
|
||||
lookup PublishTargetLookup
|
||||
provisioner VolumeProvisioner
|
||||
metadataResolver KubernetesMetadataResolver
|
||||
}
|
||||
|
||||
func NewControllerServer(lookup PublishTargetLookup) *ControllerServer {
|
||||
@@ -24,6 +25,10 @@ func NewControllerServerWithProvisioner(lookup PublishTargetLookup, provisioner
|
||||
return &ControllerServer{lookup: lookup, provisioner: provisioner}
|
||||
}
|
||||
|
||||
func NewControllerServerWithProvisionerAndMetadataResolver(lookup PublishTargetLookup, provisioner VolumeProvisioner, resolver KubernetesMetadataResolver) *ControllerServer {
|
||||
return &ControllerServer{lookup: lookup, provisioner: provisioner, metadataResolver: resolver}
|
||||
}
|
||||
|
||||
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")
|
||||
@@ -32,6 +37,9 @@ func (s *ControllerServer) CreateVolume(ctx context.Context, req *csipb.CreateVo
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.resolveKubernetesMetadata(ctx, &spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
created, err := s.provisioner.CreateVolume(ctx, spec)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrVolumeConflict) {
|
||||
@@ -50,6 +58,21 @@ func (s *ControllerServer) CreateVolume(ctx context.Context, req *csipb.CreateVo
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *ControllerServer) resolveKubernetesMetadata(ctx context.Context, spec *VolumeSpec) error {
|
||||
if s.metadataResolver == nil || spec == nil || spec.PVCUID != "" || spec.PVCName == "" || spec.PVCNamespace == "" {
|
||||
return nil
|
||||
}
|
||||
uid, err := s.metadataResolver.ResolvePVCUID(ctx, spec.PVCName, spec.PVCNamespace)
|
||||
if err != nil {
|
||||
return status.Errorf(codes.Internal, "lookup pvc uid: %v", err)
|
||||
}
|
||||
if uid == "" {
|
||||
return status.Errorf(codes.Internal, "lookup pvc uid: empty uid for %s/%s", spec.PVCNamespace, spec.PVCName)
|
||||
}
|
||||
spec.PVCUID = uid
|
||||
return 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")
|
||||
@@ -161,6 +184,10 @@ 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"],
|
||||
PVCUID: req.GetParameters()["csi.storage.k8s.io/pvc/uid"],
|
||||
PVName: req.GetParameters()["csi.storage.k8s.io/pv/name"],
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,17 @@ func (s *stubProvisioner) DeleteVolume(_ context.Context, volumeID string) error
|
||||
return s.err
|
||||
}
|
||||
|
||||
type stubMetadataResolver struct {
|
||||
uid string
|
||||
err error
|
||||
calls []string
|
||||
}
|
||||
|
||||
func (s *stubMetadataResolver) ResolvePVCUID(_ context.Context, name, namespace string) (string, error) {
|
||||
s.calls = append(s.calls, namespace+"/"+name)
|
||||
return s.uid, s.err
|
||||
}
|
||||
|
||||
func TestControllerPublish_ReturnsISCSIPublishContextFromTargetFact(t *testing.T) {
|
||||
lookup := &stubLookup{target: PublishTarget{
|
||||
VolumeID: "v1",
|
||||
@@ -173,7 +184,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-123",
|
||||
"csi.storage.k8s.io/serviceAccount.name": "ignored",
|
||||
},
|
||||
VolumeCapabilities: []*csipb.VolumeCapability{
|
||||
testVolumeCapability(),
|
||||
},
|
||||
@@ -187,6 +205,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.PVCUID != "uid-123" || 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)
|
||||
@@ -196,6 +217,67 @@ func TestG15c_ControllerCreateVolume_RecordsDesiredIntentOnly(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestG15c_ControllerCreateVolume_ResolvesPVCUIDWhenConfigured(t *testing.T) {
|
||||
prov := &stubProvisioner{}
|
||||
resolver := &stubMetadataResolver{uid: "uid-from-api"}
|
||||
s := NewControllerServerWithProvisionerAndMetadataResolver(&stubLookup{}, prov, resolver)
|
||||
|
||||
_, err := s.CreateVolume(context.Background(), &csipb.CreateVolumeRequest{
|
||||
Name: "pvc-a",
|
||||
CapacityRange: &csipb.CapacityRange{
|
||||
RequiredBytes: 1 << 30,
|
||||
},
|
||||
Parameters: map[string]string{
|
||||
"replicationFactor": "1",
|
||||
"csi.storage.k8s.io/pvc/name": "demo-pvc",
|
||||
"csi.storage.k8s.io/pvc/namespace": "demo-ns",
|
||||
"csi.storage.k8s.io/pv/name": "pvc-a",
|
||||
},
|
||||
VolumeCapabilities: []*csipb.VolumeCapability{
|
||||
testVolumeCapability(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateVolume: %v", err)
|
||||
}
|
||||
if len(resolver.calls) != 1 || resolver.calls[0] != "demo-ns/demo-pvc" {
|
||||
t.Fatalf("resolver calls=%v", resolver.calls)
|
||||
}
|
||||
if got := prov.calls[0]; got.PVCUID != "uid-from-api" {
|
||||
t.Fatalf("pvc uid=%q", got.PVCUID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestG15c_ControllerCreateVolume_FailsWhenConfiguredPVCUIDLookupFails(t *testing.T) {
|
||||
prov := &stubProvisioner{}
|
||||
s := NewControllerServerWithProvisionerAndMetadataResolver(&stubLookup{}, prov, &stubMetadataResolver{err: errors.New("boom")})
|
||||
|
||||
_, err := s.CreateVolume(context.Background(), &csipb.CreateVolumeRequest{
|
||||
Name: "pvc-a",
|
||||
CapacityRange: &csipb.CapacityRange{
|
||||
RequiredBytes: 1 << 30,
|
||||
},
|
||||
Parameters: map[string]string{
|
||||
"replicationFactor": "1",
|
||||
"csi.storage.k8s.io/pvc/name": "demo-pvc",
|
||||
"csi.storage.k8s.io/pvc/namespace": "demo-ns",
|
||||
},
|
||||
VolumeCapabilities: []*csipb.VolumeCapability{
|
||||
testVolumeCapability(),
|
||||
},
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected error")
|
||||
}
|
||||
st, _ := status.FromError(err)
|
||||
if st.Code() != codes.Internal {
|
||||
t.Fatalf("code=%v want Internal", st.Code())
|
||||
}
|
||||
if len(prov.calls) != 0 {
|
||||
t.Fatalf("provisioner must not be called after uid lookup failure: %+v", prov.calls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestG15c_ControllerCreateVolume_RejectsMissingCapacity(t *testing.T) {
|
||||
s := NewControllerServerWithProvisioner(&stubLookup{}, &stubProvisioner{})
|
||||
_, err := s.CreateVolume(context.Background(), &csipb.CreateVolumeRequest{
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package csi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
serviceAccountTokenPath = "/var/run/secrets/kubernetes.io/serviceaccount/token"
|
||||
serviceAccountCAPath = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
|
||||
)
|
||||
|
||||
type InClusterPVCMetadataResolver struct {
|
||||
client *http.Client
|
||||
host string
|
||||
token string
|
||||
}
|
||||
|
||||
func NewInClusterPVCMetadataResolver() (*InClusterPVCMetadataResolver, error) {
|
||||
host := os.Getenv("KUBERNETES_SERVICE_HOST")
|
||||
port := os.Getenv("KUBERNETES_SERVICE_PORT")
|
||||
if host == "" || port == "" {
|
||||
return nil, fmt.Errorf("KUBERNETES_SERVICE_HOST/PORT are not set")
|
||||
}
|
||||
tokenBytes, err := os.ReadFile(serviceAccountTokenPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read service account token: %w", err)
|
||||
}
|
||||
caBytes, err := os.ReadFile(serviceAccountCAPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read service account ca: %w", err)
|
||||
}
|
||||
roots := x509.NewCertPool()
|
||||
if !roots.AppendCertsFromPEM(caBytes) {
|
||||
return nil, fmt.Errorf("parse service account ca")
|
||||
}
|
||||
return &InClusterPVCMetadataResolver{
|
||||
client: &http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
Transport: &http.Transport{TLSClientConfig: &tls.Config{
|
||||
RootCAs: roots,
|
||||
MinVersion: tls.VersionTLS12,
|
||||
}},
|
||||
},
|
||||
host: "https://" + net.JoinHostPort(host, port),
|
||||
token: strings.TrimSpace(string(tokenBytes)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *InClusterPVCMetadataResolver) ResolvePVCUID(ctx context.Context, name, namespace string) (string, error) {
|
||||
if r == nil || r.client == nil {
|
||||
return "", fmt.Errorf("resolver not configured")
|
||||
}
|
||||
if name == "" || namespace == "" {
|
||||
return "", fmt.Errorf("pvc name and namespace are required")
|
||||
}
|
||||
endpoint := r.host + "/api/v1/namespaces/" + url.PathEscape(namespace) + "/persistentvolumeclaims/" + url.PathEscape(name)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+r.token)
|
||||
resp, err := r.client.Do(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
body, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))
|
||||
return "", fmt.Errorf("kubernetes api status %d: %s", resp.StatusCode, strings.TrimSpace(string(body)))
|
||||
}
|
||||
var out struct {
|
||||
Metadata struct {
|
||||
UID string `json:"uid"`
|
||||
} `json:"metadata"`
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if out.Metadata.UID == "" {
|
||||
return "", fmt.Errorf("kubernetes api response missing metadata.uid")
|
||||
}
|
||||
return out.Metadata.UID, nil
|
||||
}
|
||||
@@ -35,6 +35,10 @@ 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,
|
||||
PvcUid: spec.PVCUID,
|
||||
PvName: spec.PVName,
|
||||
})
|
||||
if err != nil {
|
||||
return VolumeSpec{}, err
|
||||
@@ -43,6 +47,10 @@ 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(),
|
||||
PVCUID: resp.GetPvcUid(),
|
||||
PVName: resp.GetPvName(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -104,6 +104,10 @@ func (f *fakeLifecycleClient) CreateVolume(_ context.Context, req *control.Creat
|
||||
VolumeId: req.GetVolumeId(),
|
||||
SizeBytes: req.GetSizeBytes(),
|
||||
ReplicationFactor: req.GetReplicationFactor(),
|
||||
PvcName: req.GetPvcName(),
|
||||
PvcNamespace: req.GetPvcNamespace(),
|
||||
PvcUid: req.GetPvcUid(),
|
||||
PvName: req.GetPvName(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -119,6 +123,10 @@ func TestG15c_ControlLifecycleProvisioner_CreateVolumeRoundTrip(t *testing.T) {
|
||||
VolumeID: "pvc-a",
|
||||
SizeBytes: 1 << 30,
|
||||
ReplicationFactor: 2,
|
||||
PVCName: "demo-pvc",
|
||||
PVCNamespace: "demo-ns",
|
||||
PVCUID: "uid-123",
|
||||
PVName: "pvc-a",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateVolume: %v", err)
|
||||
@@ -126,9 +134,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.GetPvcUid() != "uid-123" || 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.PVCUID != "uid-123" || got.PVName != "pvc-a" {
|
||||
t.Fatalf("kubernetes metadata spec=%+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestG15c_ControlLifecycleProvisioner_DeleteVolumeRoundTrip(t *testing.T) {
|
||||
|
||||
@@ -20,6 +20,10 @@ func TestG15c_LifecycleService_CreateVolumePersistsDesiredIntent(t *testing.T) {
|
||||
VolumeId: "pvc-a",
|
||||
SizeBytes: 1 << 30,
|
||||
ReplicationFactor: 2,
|
||||
PvcName: "demo-pvc",
|
||||
PvcNamespace: "demo-ns",
|
||||
PvcUid: "uid-123",
|
||||
PvName: "pvc-a",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateVolume: %v", err)
|
||||
@@ -27,6 +31,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.GetPvcUid() != "uid-123" || 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 +41,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.PVCUID != "uid-123" || 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")
|
||||
}
|
||||
|
||||
@@ -59,6 +59,10 @@ 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,
|
||||
PvcUid: rec.Spec.PVCUID,
|
||||
PvName: rec.Spec.PVName,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -105,6 +109,10 @@ func lifecycleSpecFromWire(req *control.CreateVolumeRequest) lifecycle.VolumeSpe
|
||||
VolumeID: req.GetVolumeId(),
|
||||
SizeBytes: req.GetSizeBytes(),
|
||||
ReplicationFactor: int(req.GetReplicationFactor()),
|
||||
PVCName: req.GetPvcName(),
|
||||
PVCNamespace: req.GetPvcNamespace(),
|
||||
PVCUID: req.GetPvcUid(),
|
||||
PVName: req.GetPvName(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,12 @@ import (
|
||||
)
|
||||
|
||||
type K8sRenderConfig struct {
|
||||
Namespace string
|
||||
Image string
|
||||
MasterAddr string
|
||||
DurableRootBase string
|
||||
RecoveryMode string
|
||||
Namespace string
|
||||
Image string
|
||||
MasterAddr string
|
||||
DurableRootBase string
|
||||
RecoveryMode string
|
||||
OwnerReferenceToPVC bool
|
||||
}
|
||||
|
||||
type RenderedManifest struct {
|
||||
@@ -38,6 +39,14 @@ func RenderBlockVolumeDeployments(plan lifecycle.BlockVolumeWorkloadPlan, cfg K8
|
||||
if cfg.MasterAddr == "" {
|
||||
return nil, fmt.Errorf("launcher: master addr is required")
|
||||
}
|
||||
namespace := cfg.Namespace
|
||||
ownerRefs, err := ownerReferences(plan, cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cfg.OwnerReferenceToPVC {
|
||||
namespace = plan.PVCNamespace
|
||||
}
|
||||
out := make([]RenderedManifest, 0, len(plan.Replicas))
|
||||
for _, replica := range plan.Replicas {
|
||||
name := workloadName(plan.VolumeID, replica.ReplicaID)
|
||||
@@ -46,12 +55,13 @@ func RenderBlockVolumeDeployments(plan lifecycle.BlockVolumeWorkloadPlan, cfg K8
|
||||
Kind: "Deployment",
|
||||
Metadata: metadata{
|
||||
Name: name,
|
||||
Namespace: cfg.Namespace,
|
||||
Namespace: namespace,
|
||||
Labels: map[string]string{
|
||||
"app": "sw-blockvolume",
|
||||
"sw-block.seaweedfs.com/volume": plan.VolumeID,
|
||||
"sw-block.seaweedfs.com/replica": replica.ReplicaID,
|
||||
},
|
||||
OwnerReferences: ownerRefs,
|
||||
},
|
||||
Spec: deploymentSpec{
|
||||
Replicas: intPtr(1),
|
||||
@@ -87,6 +97,22 @@ func RenderBlockVolumeDeployments(plan lifecycle.BlockVolumeWorkloadPlan, cfg K8
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func ownerReferences(plan lifecycle.BlockVolumeWorkloadPlan, cfg K8sRenderConfig) ([]ownerReference, error) {
|
||||
if !cfg.OwnerReferenceToPVC {
|
||||
return nil, nil
|
||||
}
|
||||
if plan.PVCName == "" || plan.PVCNamespace == "" || plan.PVCUID == "" {
|
||||
return nil, fmt.Errorf("launcher: pvc owner reference requires pvc name, namespace, and uid")
|
||||
}
|
||||
return []ownerReference{{
|
||||
APIVersion: "v1",
|
||||
Kind: "PersistentVolumeClaim",
|
||||
Name: plan.PVCName,
|
||||
UID: plan.PVCUID,
|
||||
Controller: boolPtr(true),
|
||||
}}, nil
|
||||
}
|
||||
|
||||
func blockVolumeArgs(plan lifecycle.BlockVolumeWorkloadPlan, replica lifecycle.BlockVolumeReplicaWorkload, cfg K8sRenderConfig) []string {
|
||||
return []string{
|
||||
"--master=" + cfg.MasterAddr,
|
||||
@@ -127,6 +153,8 @@ func dnsLabel(s string) string {
|
||||
|
||||
func intPtr(v int) *int { return &v }
|
||||
|
||||
func boolPtr(v bool) *bool { return &v }
|
||||
|
||||
type blockVolumeDeployment struct {
|
||||
APIVersion string `yaml:"apiVersion"`
|
||||
Kind string `yaml:"kind"`
|
||||
@@ -135,9 +163,18 @@ type blockVolumeDeployment struct {
|
||||
}
|
||||
|
||||
type metadata struct {
|
||||
Name string `yaml:"name,omitempty"`
|
||||
Namespace string `yaml:"namespace,omitempty"`
|
||||
Labels map[string]string `yaml:"labels,omitempty"`
|
||||
Name string `yaml:"name,omitempty"`
|
||||
Namespace string `yaml:"namespace,omitempty"`
|
||||
Labels map[string]string `yaml:"labels,omitempty"`
|
||||
OwnerReferences []ownerReference `yaml:"ownerReferences,omitempty"`
|
||||
}
|
||||
|
||||
type ownerReference struct {
|
||||
APIVersion string `yaml:"apiVersion"`
|
||||
Kind string `yaml:"kind"`
|
||||
Name string `yaml:"name"`
|
||||
UID string `yaml:"uid"`
|
||||
Controller *bool `yaml:"controller,omitempty"`
|
||||
}
|
||||
|
||||
type deploymentSpec struct {
|
||||
|
||||
@@ -66,6 +66,42 @@ func TestG15d_K8sRenderer_RequiresMasterAddr(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestG15d_K8sRenderer_CanAttachPVCOwnerReference(t *testing.T) {
|
||||
manifests, err := RenderBlockVolumeDeployments(sampleWorkloadPlan(), K8sRenderConfig{
|
||||
MasterAddr: "m:9333",
|
||||
OwnerReferenceToPVC: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("RenderBlockVolumeDeployments: %v", err)
|
||||
}
|
||||
raw := string(manifests[0].YAML)
|
||||
for _, want := range []string{
|
||||
"namespace: default",
|
||||
"ownerReferences:",
|
||||
"apiVersion: v1",
|
||||
"kind: PersistentVolumeClaim",
|
||||
"name: demo-pvc",
|
||||
"uid: uid-123",
|
||||
"controller: true",
|
||||
} {
|
||||
if !strings.Contains(raw, want) {
|
||||
t.Fatalf("manifest missing %q:\n%s", want, raw)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestG15d_K8sRenderer_PVCOwnerReferenceRequiresKubernetesMetadata(t *testing.T) {
|
||||
plan := sampleWorkloadPlan()
|
||||
plan.PVCUID = ""
|
||||
_, err := RenderBlockVolumeDeployments(plan, K8sRenderConfig{
|
||||
MasterAddr: "m:9333",
|
||||
OwnerReferenceToPVC: true,
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("expected error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestG15d_K8sRenderer_OutputIsNotAuthorityShaped(t *testing.T) {
|
||||
manifests, err := RenderBlockVolumeDeployments(sampleWorkloadPlan(), K8sRenderConfig{MasterAddr: "m:9333"})
|
||||
if err != nil {
|
||||
@@ -81,8 +117,11 @@ func TestG15d_K8sRenderer_OutputIsNotAuthorityShaped(t *testing.T) {
|
||||
|
||||
func sampleWorkloadPlan() lifecycle.BlockVolumeWorkloadPlan {
|
||||
return lifecycle.BlockVolumeWorkloadPlan{
|
||||
VolumeID: "pvc-a",
|
||||
SizeBytes: 1 << 20,
|
||||
VolumeID: "pvc-a",
|
||||
SizeBytes: 1 << 20,
|
||||
PVCName: "demo-pvc",
|
||||
PVCNamespace: "default",
|
||||
PVCUID: "uid-123",
|
||||
Replicas: []lifecycle.BlockVolumeReplicaWorkload{
|
||||
{
|
||||
ServerID: "m02",
|
||||
|
||||
@@ -33,6 +33,10 @@ 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"`
|
||||
PVCUID string `json:"pvc_uid,omitempty"`
|
||||
PVName string `json:"pv_name,omitempty"`
|
||||
}
|
||||
|
||||
// VolumeRecord is the durable lifecycle state for one volume.
|
||||
@@ -75,9 +79,18 @@ func (s *FileStore) CreateVolume(spec VolumeSpec) (VolumeRecord, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if existing, ok := s.records[spec.VolumeID]; ok {
|
||||
if existing.Spec != spec {
|
||||
if !volumeSpecsCompatible(existing.Spec, spec) {
|
||||
return VolumeRecord{}, ErrVolumeConflict
|
||||
}
|
||||
merged := existing
|
||||
merged.Spec = mergeVolumeSpecMetadata(existing.Spec, spec)
|
||||
if merged.Spec != existing.Spec {
|
||||
if err := s.putLocked(merged); err != nil {
|
||||
return VolumeRecord{}, err
|
||||
}
|
||||
s.records[spec.VolumeID] = merged
|
||||
return merged, nil
|
||||
}
|
||||
return existing, nil
|
||||
}
|
||||
rec := VolumeRecord{Spec: spec}
|
||||
@@ -88,6 +101,29 @@ func (s *FileStore) CreateVolume(spec VolumeSpec) (VolumeRecord, error) {
|
||||
return rec, nil
|
||||
}
|
||||
|
||||
func volumeSpecsCompatible(a, b VolumeSpec) bool {
|
||||
return a.VolumeID == b.VolumeID &&
|
||||
a.SizeBytes == b.SizeBytes &&
|
||||
a.ReplicationFactor == b.ReplicationFactor
|
||||
}
|
||||
|
||||
func mergeVolumeSpecMetadata(existing, incoming VolumeSpec) VolumeSpec {
|
||||
out := existing
|
||||
if out.PVCName == "" {
|
||||
out.PVCName = incoming.PVCName
|
||||
}
|
||||
if out.PVCNamespace == "" {
|
||||
out.PVCNamespace = incoming.PVCNamespace
|
||||
}
|
||||
if out.PVCUID == "" {
|
||||
out.PVCUID = incoming.PVCUID
|
||||
}
|
||||
if out.PVName == "" {
|
||||
out.PVName = incoming.PVName
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// DeleteVolume removes a desired volume record. Missing volumes are a
|
||||
// successful no-op so delete is safe to retry.
|
||||
func (s *FileStore) DeleteVolume(volumeID string) error {
|
||||
|
||||
@@ -16,7 +16,15 @@ 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",
|
||||
PVCUID: "uid-123",
|
||||
PVName: "pvc-a",
|
||||
}
|
||||
rec, err := s.CreateVolume(spec)
|
||||
if err != nil {
|
||||
t.Fatalf("create: %v", err)
|
||||
@@ -59,6 +67,45 @@ func TestFileStore_CreateVolumeRejectsConflictingSpec(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileStore_CreateVolumeMergesMissingKubernetesMetadata(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
s, err := OpenFileStore(dir)
|
||||
if err != nil {
|
||||
t.Fatalf("open: %v", err)
|
||||
}
|
||||
base := VolumeSpec{
|
||||
VolumeID: "vol-a",
|
||||
SizeBytes: 1 << 20,
|
||||
ReplicationFactor: 2,
|
||||
PVCName: "demo-pvc",
|
||||
PVCNamespace: "demo-ns",
|
||||
PVName: "pvc-a",
|
||||
}
|
||||
if _, err := s.CreateVolume(base); err != nil {
|
||||
t.Fatalf("create base: %v", err)
|
||||
}
|
||||
withUID := base
|
||||
withUID.PVCUID = "uid-123"
|
||||
rec, err := s.CreateVolume(withUID)
|
||||
if err != nil {
|
||||
t.Fatalf("create with uid: %v", err)
|
||||
}
|
||||
if rec.Spec.PVCUID != "uid-123" {
|
||||
t.Fatalf("pvc uid=%q", rec.Spec.PVCUID)
|
||||
}
|
||||
reopened, err := OpenFileStore(dir)
|
||||
if err != nil {
|
||||
t.Fatalf("reopen: %v", err)
|
||||
}
|
||||
got, ok := reopened.GetVolume("vol-a")
|
||||
if !ok {
|
||||
t.Fatal("reopened store missing volume")
|
||||
}
|
||||
if got.Spec.PVCUID != "uid-123" {
|
||||
t.Fatalf("persisted pvc uid=%q", got.Spec.PVCUID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileStore_AttachDetachAreIdempotent(t *testing.T) {
|
||||
s, err := OpenFileStore(t.TempDir())
|
||||
if err != nil {
|
||||
|
||||
@@ -9,9 +9,12 @@ import (
|
||||
// daemons should exist for one desired volume. It is deliberately not
|
||||
// authority-shaped: no epoch, endpoint_version, primary, ready, or healthy.
|
||||
type BlockVolumeWorkloadPlan struct {
|
||||
VolumeID string
|
||||
SizeBytes uint64
|
||||
Replicas []BlockVolumeReplicaWorkload
|
||||
VolumeID string
|
||||
SizeBytes uint64
|
||||
PVCName string
|
||||
PVCNamespace string
|
||||
PVCUID string
|
||||
Replicas []BlockVolumeReplicaWorkload
|
||||
}
|
||||
|
||||
type BlockVolumeReplicaWorkload struct {
|
||||
@@ -50,9 +53,12 @@ func PlanBlockVolumeWorkloads(volume VolumeRecord, placement PlacementIntent, no
|
||||
}
|
||||
|
||||
out := BlockVolumeWorkloadPlan{
|
||||
VolumeID: volume.Spec.VolumeID,
|
||||
SizeBytes: volume.Spec.SizeBytes,
|
||||
Replicas: make([]BlockVolumeReplicaWorkload, 0, len(placement.Slots)),
|
||||
VolumeID: volume.Spec.VolumeID,
|
||||
SizeBytes: volume.Spec.SizeBytes,
|
||||
PVCName: volume.Spec.PVCName,
|
||||
PVCNamespace: volume.Spec.PVCNamespace,
|
||||
PVCUID: volume.Spec.PVCUID,
|
||||
Replicas: make([]BlockVolumeReplicaWorkload, 0, len(placement.Slots)),
|
||||
}
|
||||
for i, slot := range placement.Slots {
|
||||
node, ok := nodeByID[slot.ServerID]
|
||||
|
||||
@@ -7,6 +7,9 @@ func TestG15d_WorkloadPlan_BlankPoolRF2CreatesReplicaWorkloads(t *testing.T) {
|
||||
VolumeID: "pvc-a",
|
||||
SizeBytes: 1 << 20,
|
||||
ReplicationFactor: 2,
|
||||
PVCName: "demo-pvc",
|
||||
PVCNamespace: "default",
|
||||
PVCUID: "uid-123",
|
||||
}}
|
||||
placement := PlacementIntent{
|
||||
VolumeID: "pvc-a",
|
||||
@@ -26,6 +29,9 @@ func TestG15d_WorkloadPlan_BlankPoolRF2CreatesReplicaWorkloads(t *testing.T) {
|
||||
if plan.VolumeID != "pvc-a" || plan.SizeBytes != 1<<20 || len(plan.Replicas) != 2 {
|
||||
t.Fatalf("plan=%+v", plan)
|
||||
}
|
||||
if plan.PVCName != "demo-pvc" || plan.PVCNamespace != "default" || plan.PVCUID != "uid-123" {
|
||||
t.Fatalf("pvc metadata=%+v", plan)
|
||||
}
|
||||
if plan.Replicas[0].ReplicaID != "r1" || plan.Replicas[1].ReplicaID != "r2" {
|
||||
t.Fatalf("replica ids=%q/%q want r1/r2", plan.Replicas[0].ReplicaID, plan.Replicas[1].ReplicaID)
|
||||
}
|
||||
|
||||
@@ -832,6 +832,10 @@ 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"`
|
||||
PvcUid string `protobuf:"bytes,7,opt,name=pvc_uid,json=pvcUid,proto3" json:"pvc_uid,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CreateVolumeRequest) Reset() {
|
||||
@@ -887,6 +891,34 @@ 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 ""
|
||||
}
|
||||
|
||||
func (x *CreateVolumeRequest) GetPvcUid() string {
|
||||
if x != nil {
|
||||
return x.PvcUid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CreateVolumeResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -895,6 +927,10 @@ 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"`
|
||||
PvcUid string `protobuf:"bytes,7,opt,name=pvc_uid,json=pvcUid,proto3" json:"pvc_uid,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CreateVolumeResponse) Reset() {
|
||||
@@ -950,6 +986,34 @@ 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 ""
|
||||
}
|
||||
|
||||
func (x *CreateVolumeResponse) GetPvcUid() string {
|
||||
if x != nil {
|
||||
return x.PvcUid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type DeleteVolumeRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -1161,7 +1225,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, 0xf2, 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 +1233,77 @@ 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,
|
||||
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,
|
||||
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,
|
||||
0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x06, 0x70, 0x76, 0x63, 0x55, 0x69, 0x64, 0x22, 0xf3, 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, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69,
|
||||
0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x63, 0x55, 0x69, 0x64, 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, 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,
|
||||
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, 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 (
|
||||
|
||||
@@ -194,12 +194,20 @@ 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;
|
||||
string pvc_uid = 7;
|
||||
}
|
||||
|
||||
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;
|
||||
string pvc_uid = 7;
|
||||
}
|
||||
|
||||
message DeleteVolumeRequest {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -7,6 +7,11 @@ ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-/tmp/sw-block-app-demo-$(date -u +%Y%m%dT
|
||||
POLL_LOG="$ARTIFACT_DIR/poll.log"
|
||||
IMAGE="${SW_BLOCK_IMAGE:-sw-block:local}"
|
||||
CSI_IMAGE="${SW_BLOCK_CSI_IMAGE:-sw-block-csi:local}"
|
||||
LAUNCHER_PVC_OWNER_REF="${SW_BLOCK_LAUNCHER_PVC_OWNER_REF:-0}"
|
||||
BLOCKVOLUME_NAMESPACE="kube-system"
|
||||
if [[ "$LAUNCHER_PVC_OWNER_REF" == "1" || "$LAUNCHER_PVC_OWNER_REF" == "true" ]]; then
|
||||
BLOCKVOLUME_NAMESPACE="$NAMESPACE"
|
||||
fi
|
||||
|
||||
mkdir -p "$ARTIFACT_DIR"
|
||||
|
||||
@@ -48,8 +53,9 @@ collect_logs() {
|
||||
capture_once "$ARTIFACT_DIR/blockcsi-controller.log" kubectl -n kube-system logs deploy/sw-block-csi-controller -c block-csi
|
||||
capture_once "$ARTIFACT_DIR/csi-provisioner.log" kubectl -n kube-system logs deploy/sw-block-csi-controller -c csi-provisioner
|
||||
capture_once "$ARTIFACT_DIR/csi-attacher.log" kubectl -n kube-system logs deploy/sw-block-csi-controller -c csi-attacher
|
||||
capture_once "$ARTIFACT_DIR/blockvolume-generated.log" kubectl -n kube-system logs -l sw-block.seaweedfs.com/volume -c blockvolume --tail=-1
|
||||
capture_once "$ARTIFACT_DIR/blockvolume-generated.log" kubectl -n "$BLOCKVOLUME_NAMESPACE" logs -l sw-block.seaweedfs.com/volume -c blockvolume --tail=-1
|
||||
capture_once "$ARTIFACT_DIR/kube-system-pods-deploys.txt" kubectl -n kube-system get pods,deploy -o wide
|
||||
capture_once "$ARTIFACT_DIR/blockvolume-namespace-pods-deploys.txt" kubectl -n "$BLOCKVOLUME_NAMESPACE" get pods,deploy -o wide
|
||||
capture_once "$ARTIFACT_DIR/app-storage.txt" kubectl -n "$NAMESPACE" get sc,pv,pvc,pod -o wide
|
||||
if [[ ! -s "$ARTIFACT_DIR/generated-blockvolume.yaml" ]]; then
|
||||
kubectl -n kube-system exec deploy/sw-blockmaster -c blockmaster -- sh -c 'cat /manifests/*.yaml' >"$ARTIFACT_DIR/generated-blockvolume.yaml" 2>"$ARTIFACT_DIR/generated-blockvolume.err" || true
|
||||
@@ -59,6 +65,7 @@ collect_logs() {
|
||||
collect_post_delete_state() {
|
||||
set +e
|
||||
kubectl -n kube-system get pods,deploy -o wide >"$ARTIFACT_DIR/kube-system-pods-deploys.after-delete.txt" 2>&1 || true
|
||||
kubectl -n "$BLOCKVOLUME_NAMESPACE" get pods,deploy -o wide >"$ARTIFACT_DIR/blockvolume-namespace-pods-deploys.after-delete.txt" 2>&1 || true
|
||||
kubectl -n "$NAMESPACE" get sc,pv,pvc,pod -o wide >"$ARTIFACT_DIR/app-storage.after-delete.txt" 2>&1 || true
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.after-delete.txt" 2>&1 || true
|
||||
@@ -77,6 +84,7 @@ cleanup() {
|
||||
kubectl -n "$NAMESPACE" delete pod sw-block-demo-reader sw-block-demo-writer --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
kubectl -n "$NAMESPACE" delete pvc sw-block-demo-pvc --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
kubectl -n kube-system delete deploy -l app=sw-blockvolume --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
kubectl -n "$NAMESPACE" delete deploy -l app=sw-blockvolume --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
kubectl delete -f "$CSI_NODE_RENDERED" --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
kubectl delete -f "$CSI_CONTROLLER_RENDERED" --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
kubectl delete -f "$ROOT/deploy/k8s/alpha/csi-driver.yaml" --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
@@ -115,9 +123,19 @@ sed -e "s/__NODE_NAME__/${NODE_NAME}/g" \
|
||||
-e "s/sw-block:local/${IMAGE_SED}/g" \
|
||||
-e "s/imagePullPolicy: Never/imagePullPolicy: IfNotPresent/g" \
|
||||
"$ROOT/deploy/k8s/alpha/block-stack.yaml" >"$STACK_RENDERED"
|
||||
if [[ "$BLOCKVOLUME_NAMESPACE" != "kube-system" ]]; then
|
||||
awk '/--launcher-namespace=/{print; print " - \"--launcher-pvc-owner-ref\""; next} {print}' "$STACK_RENDERED" >"$STACK_RENDERED.tmp"
|
||||
mv "$STACK_RENDERED.tmp" "$STACK_RENDERED"
|
||||
grep -q -- '--launcher-pvc-owner-ref' "$STACK_RENDERED" || { echo "failed to inject --launcher-pvc-owner-ref into $STACK_RENDERED" >&2; exit 1; }
|
||||
fi
|
||||
sed -e "s/sw-block-csi:local/${CSI_IMAGE_SED}/g" \
|
||||
-e "s/imagePullPolicy: Never/imagePullPolicy: IfNotPresent/g" \
|
||||
"$ROOT/deploy/k8s/alpha/csi-controller.yaml" >"$CSI_CONTROLLER_RENDERED"
|
||||
if [[ "$BLOCKVOLUME_NAMESPACE" != "kube-system" ]]; then
|
||||
awk '/--node-id=\$\(NODE_NAME\)/{print; print " - \"--kubernetes-pvc-uid-lookup\""; next} {print}' "$CSI_CONTROLLER_RENDERED" >"$CSI_CONTROLLER_RENDERED.tmp"
|
||||
mv "$CSI_CONTROLLER_RENDERED.tmp" "$CSI_CONTROLLER_RENDERED"
|
||||
grep -q -- '--kubernetes-pvc-uid-lookup' "$CSI_CONTROLLER_RENDERED" || { echo "failed to inject --kubernetes-pvc-uid-lookup into $CSI_CONTROLLER_RENDERED" >&2; exit 1; }
|
||||
fi
|
||||
sed -e "s/sw-block-csi:local/${CSI_IMAGE_SED}/g" \
|
||||
-e "s/imagePullPolicy: Never/imagePullPolicy: IfNotPresent/g" \
|
||||
"$ROOT/deploy/k8s/alpha/csi-node.yaml" >"$CSI_NODE_RENDERED"
|
||||
@@ -128,6 +146,8 @@ log "namespace=$NAMESPACE"
|
||||
log "node=$NODE_NAME"
|
||||
log "image=$IMAGE"
|
||||
log "csi_image=$CSI_IMAGE"
|
||||
log "blockvolume_namespace=$BLOCKVOLUME_NAMESPACE"
|
||||
log "launcher_pvc_owner_ref=$LAUNCHER_PVC_OWNER_REF"
|
||||
kubectl version --client=true >"$ARTIFACT_DIR/kubectl-version.txt" 2>&1 || true
|
||||
kubectl get nodes -o wide >"$ARTIFACT_DIR/nodes.before.txt"
|
||||
|
||||
@@ -164,7 +184,7 @@ kubectl -n kube-system exec deploy/sw-blockmaster -c blockmaster -- sh -c 'cat /
|
||||
|
||||
log "apply generated blockvolume workload"
|
||||
kubectl apply -f "$ARTIFACT_DIR/generated-blockvolume.yaml" | tee "$ARTIFACT_DIR/apply-generated-blockvolume.log"
|
||||
kubectl -n kube-system wait --for=condition=available deploy -l app=sw-blockvolume --timeout=120s
|
||||
kubectl -n "$BLOCKVOLUME_NAMESPACE" wait --for=condition=available deploy -l app=sw-blockvolume --timeout=120s
|
||||
|
||||
log "wait for app writer completion"
|
||||
wait_pod_succeeded sw-block-demo-writer 240
|
||||
@@ -196,12 +216,22 @@ if ! kubectl -n kube-system exec deploy/sw-blockmaster -c blockmaster -- sh -c '
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "delete generated blockvolume Deployment after manifest cleanup"
|
||||
kubectl -n kube-system delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=true --timeout=120s | tee "$ARTIFACT_DIR/delete-generated-blockvolume.log"
|
||||
if [[ "$BLOCKVOLUME_NAMESPACE" == "kube-system" ]]; then
|
||||
log "delete generated blockvolume Deployment after manifest cleanup"
|
||||
kubectl -n kube-system delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=true --timeout=120s | tee "$ARTIFACT_DIR/delete-generated-blockvolume.log"
|
||||
else
|
||||
log "wait for Kubernetes GC to delete PVC-owned blockvolume Deployment"
|
||||
for _ in $(seq 1 180); do
|
||||
if ! kubectl -n "$BLOCKVOLUME_NAMESPACE" get deploy -l app=sw-blockvolume --no-headers 2>/dev/null | grep -q .; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
||||
collect_post_delete_state
|
||||
|
||||
if kubectl -n kube-system get deploy -l app=sw-blockvolume --no-headers 2>/dev/null | grep -q .; then
|
||||
if kubectl -n "$BLOCKVOLUME_NAMESPACE" get deploy -l app=sw-blockvolume --no-headers 2>/dev/null | grep -q .; then
|
||||
echo "generated blockvolume deployment still present" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -8,6 +8,11 @@ RUN_LABEL="${SW_BLOCK_RUN_LABEL:-g15d}"
|
||||
DYNAMIC_PVC_MANIFEST="${SW_BLOCK_DYNAMIC_PVC_MANIFEST:-$ROOT/deploy/k8s/g15d/dynamic-pvc-pod.yaml}"
|
||||
IMAGE="${SW_BLOCK_IMAGE:-sw-block:local}"
|
||||
CSI_IMAGE="${SW_BLOCK_CSI_IMAGE:-sw-block-csi:local}"
|
||||
LAUNCHER_PVC_OWNER_REF="${SW_BLOCK_LAUNCHER_PVC_OWNER_REF:-0}"
|
||||
BLOCKVOLUME_NAMESPACE="kube-system"
|
||||
if [[ "$LAUNCHER_PVC_OWNER_REF" == "1" || "$LAUNCHER_PVC_OWNER_REF" == "true" ]]; then
|
||||
BLOCKVOLUME_NAMESPACE="$NAMESPACE"
|
||||
fi
|
||||
|
||||
mkdir -p "$ARTIFACT_DIR"
|
||||
POLL_LOG="$ARTIFACT_DIR/poll.log"
|
||||
@@ -39,9 +44,19 @@ sed -e "s/__NODE_NAME__/${NODE_NAME}/g" \
|
||||
-e "s/sw-block:local/${IMAGE_SED}/g" \
|
||||
-e "s/imagePullPolicy: Never/imagePullPolicy: IfNotPresent/g" \
|
||||
"$ROOT/deploy/k8s/g15d/block-stack.yaml" >"$STACK_RENDERED"
|
||||
if [[ "$BLOCKVOLUME_NAMESPACE" != "kube-system" ]]; then
|
||||
awk '/--launcher-namespace=/{print; print " - \"--launcher-pvc-owner-ref\""; next} {print}' "$STACK_RENDERED" >"$STACK_RENDERED.tmp"
|
||||
mv "$STACK_RENDERED.tmp" "$STACK_RENDERED"
|
||||
grep -q -- '--launcher-pvc-owner-ref' "$STACK_RENDERED" || { echo "failed to inject --launcher-pvc-owner-ref into $STACK_RENDERED" >&2; exit 1; }
|
||||
fi
|
||||
sed -e "s/sw-block-csi:local/${CSI_IMAGE_SED}/g" \
|
||||
-e "s/imagePullPolicy: Never/imagePullPolicy: IfNotPresent/g" \
|
||||
"$ROOT/deploy/k8s/g15d/csi-controller.yaml" >"$CSI_CONTROLLER_RENDERED"
|
||||
if [[ "$BLOCKVOLUME_NAMESPACE" != "kube-system" ]]; then
|
||||
awk '/--node-id=\$\(NODE_NAME\)/{print; print " - \"--kubernetes-pvc-uid-lookup\""; next} {print}' "$CSI_CONTROLLER_RENDERED" >"$CSI_CONTROLLER_RENDERED.tmp"
|
||||
mv "$CSI_CONTROLLER_RENDERED.tmp" "$CSI_CONTROLLER_RENDERED"
|
||||
grep -q -- '--kubernetes-pvc-uid-lookup' "$CSI_CONTROLLER_RENDERED" || { echo "failed to inject --kubernetes-pvc-uid-lookup into $CSI_CONTROLLER_RENDERED" >&2; exit 1; }
|
||||
fi
|
||||
sed -e "s/sw-block-csi:local/${CSI_IMAGE_SED}/g" \
|
||||
-e "s/imagePullPolicy: Never/imagePullPolicy: IfNotPresent/g" \
|
||||
"$ROOT/deploy/k8s/g15b/csi-node.yaml" >"$CSI_NODE_RENDERED"
|
||||
@@ -52,6 +67,8 @@ log "namespace=$NAMESPACE"
|
||||
log "node=$NODE_NAME"
|
||||
log "image=$IMAGE"
|
||||
log "csi_image=$CSI_IMAGE"
|
||||
log "blockvolume_namespace=$BLOCKVOLUME_NAMESPACE"
|
||||
log "launcher_pvc_owner_ref=$LAUNCHER_PVC_OWNER_REF"
|
||||
log "dynamic_pvc_manifest=$DYNAMIC_PVC_MANIFEST"
|
||||
kubectl version --client=true >"$ARTIFACT_DIR/kubectl-version.txt" 2>&1 || true
|
||||
kubectl get nodes -o wide >"$ARTIFACT_DIR/nodes.before.txt"
|
||||
@@ -60,6 +77,7 @@ cleanup() {
|
||||
(
|
||||
set +e
|
||||
kubectl -n kube-system delete deploy -l app=sw-blockvolume --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
kubectl -n "$NAMESPACE" delete deploy -l app=sw-blockvolume --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
kubectl -n kube-system delete deploy sw-blockvolume-r1 sw-blockvolume-r2 --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
kubectl -n "$NAMESPACE" delete -f "$DYNAMIC_PVC_MANIFEST" --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
kubectl delete -f "$CSI_NODE_RENDERED" --ignore-not-found=true >>"$ARTIFACT_DIR/cleanup.log" 2>&1
|
||||
@@ -78,8 +96,9 @@ collect_daemon_logs() {
|
||||
capture_once "$ARTIFACT_DIR/blockcsi-controller.log" kubectl -n kube-system logs deploy/sw-block-csi-controller -c block-csi
|
||||
capture_once "$ARTIFACT_DIR/csi-provisioner.log" kubectl -n kube-system logs deploy/sw-block-csi-controller -c csi-provisioner
|
||||
capture_once "$ARTIFACT_DIR/csi-attacher.log" kubectl -n kube-system logs deploy/sw-block-csi-controller -c csi-attacher
|
||||
capture_once "$ARTIFACT_DIR/blockvolume-generated.log" kubectl -n kube-system logs -l sw-block.seaweedfs.com/volume -c blockvolume --tail=-1
|
||||
capture_once "$ARTIFACT_DIR/blockvolume-generated.log" kubectl -n "$BLOCKVOLUME_NAMESPACE" logs -l sw-block.seaweedfs.com/volume -c blockvolume --tail=-1
|
||||
capture_once "$ARTIFACT_DIR/kube-system-pods-deploys.txt" kubectl -n kube-system get pods,deploy -o wide
|
||||
capture_once "$ARTIFACT_DIR/blockvolume-namespace-pods-deploys.txt" kubectl -n "$BLOCKVOLUME_NAMESPACE" get pods,deploy -o wide
|
||||
capture_once "$ARTIFACT_DIR/app-storage.txt" kubectl -n "$NAMESPACE" get sc,pv,pvc,pod -o wide
|
||||
if [[ ! -s "$ARTIFACT_DIR/generated-blockvolume.yaml" ]]; then
|
||||
kubectl -n kube-system exec deploy/sw-blockmaster -c blockmaster -- sh -c 'cat /manifests/*.yaml' >"$ARTIFACT_DIR/generated-blockvolume.yaml" 2>"$ARTIFACT_DIR/generated-blockvolume.err" || true
|
||||
@@ -98,6 +117,7 @@ capture_once() {
|
||||
collect_post_delete_state() {
|
||||
set +e
|
||||
kubectl -n kube-system get pods,deploy -o wide >"$ARTIFACT_DIR/kube-system-pods-deploys.after-delete.txt" 2>&1 || true
|
||||
kubectl -n "$BLOCKVOLUME_NAMESPACE" get pods,deploy -o wide >"$ARTIFACT_DIR/blockvolume-namespace-pods-deploys.after-delete.txt" 2>&1 || true
|
||||
kubectl -n "$NAMESPACE" get sc,pv,pvc,pod -o wide >"$ARTIFACT_DIR/app-storage.after-delete.txt" 2>&1 || true
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.after-delete.txt" 2>&1 || true
|
||||
@@ -141,7 +161,7 @@ kubectl -n kube-system exec deploy/sw-blockmaster -c blockmaster -- sh -c 'cat /
|
||||
|
||||
log "apply generated blockvolume manifests"
|
||||
kubectl apply -f "$ARTIFACT_DIR/generated-blockvolume.yaml" | tee "$ARTIFACT_DIR/apply-generated-blockvolume.log"
|
||||
kubectl -n kube-system wait --for=condition=available deploy -l app=sw-blockvolume --timeout=120s
|
||||
kubectl -n "$BLOCKVOLUME_NAMESPACE" wait --for=condition=available deploy -l app=sw-blockvolume --timeout=120s
|
||||
|
||||
log "wait for dynamic pod completion"
|
||||
for _ in $(seq 1 240); do
|
||||
@@ -182,12 +202,22 @@ if ! kubectl -n kube-system exec deploy/sw-blockmaster -c blockmaster -- sh -c '
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "delete generated blockvolume Deployment after manifest cleanup"
|
||||
kubectl -n kube-system delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=true --timeout=120s | tee "$ARTIFACT_DIR/delete-generated-blockvolume.log"
|
||||
if [[ "$BLOCKVOLUME_NAMESPACE" == "kube-system" ]]; then
|
||||
log "delete generated blockvolume Deployment after manifest cleanup"
|
||||
kubectl -n kube-system delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=true --timeout=120s | tee "$ARTIFACT_DIR/delete-generated-blockvolume.log"
|
||||
else
|
||||
log "wait for Kubernetes GC to delete PVC-owned blockvolume Deployment"
|
||||
for _ in $(seq 1 180); do
|
||||
if ! kubectl -n "$BLOCKVOLUME_NAMESPACE" get deploy -l app=sw-blockvolume --no-headers 2>/dev/null | grep -q .; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
||||
collect_post_delete_state
|
||||
|
||||
if kubectl -n kube-system get deploy -l app=sw-blockvolume --no-headers 2>/dev/null | grep -q .; then
|
||||
if kubectl -n "$BLOCKVOLUME_NAMESPACE" get deploy -l app=sw-blockvolume --no-headers 2>/dev/null | grep -q .; then
|
||||
echo "generated blockvolume deployment still present" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user