Skip to content

Commit

Permalink
VAST Data CSI Plugin - v2.0.5
Browse files Browse the repository at this point in the history
  (from 5b30d7a)
  • Loading branch information
koreno committed Feb 14, 2023
1 parent aedc7aa commit 159899e
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
.merge-chain
/tests/*
.idea/*
.pytest_cache
__pycache__/*
16 changes: 16 additions & 0 deletions examples/csi-app-inline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: Pod
apiVersion: v1
metadata:
name: my-csi-app-inline
spec:
containers:
- name: my-frontend
image: busybox
volumeMounts:
- mountPath: "/data"
name: my-csi-volume
command: [ "sleep", "1000000" ]
volumes:
- name: my-csi-volume
csi:
driver: csi.vastdata.com
15 changes: 15 additions & 0 deletions examples/csi-clone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hp-pvc-clone
spec:
storageClassName: csi-vast-sc
dataSource:
name: src-hp-pvc
kind: PersistentVolumeClaim
apiGroup: ""
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
20 changes: 20 additions & 0 deletions examples/csi-pod-raw.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Pod
metadata:
name: pod-raw
labels:
name: busybox-test
spec:
restartPolicy: Always
containers:
- image: gcr.io/google_containers/busybox
command: ["/bin/sh", "-c"]
args: [ "tail -f /dev/null" ]
name: busybox
volumeDevices:
- name: vol
devicePath: /dev/loop3 # This device path needs to be replaced with the site specific
volumes:
- name: vol
persistentVolumeClaim:
claimName: pvc-raw
12 changes: 12 additions & 0 deletions examples/csi-pvc-raw.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pvc-raw
spec:
accessModes:
- ReadWriteOnce
storageClassName: csi-hostpath-sc
volumeMode: Block
resources:
requests:
storage: 1Gi
9 changes: 9 additions & 0 deletions examples/csi-raw-pv-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: snapshot.storage.k8s.io/v1alpha1
kind: VolumeSnapshot
metadata:
name: raw-pv-snapshot
spec:
snapshotClassName: csi-vast-snapclass
source:
name: pvc-raw
kind: PersistentVolumeClaim
15 changes: 15 additions & 0 deletions examples/csi-restore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hpvc-restore
spec:
storageClassName: csi-vast-sc
dataSource:
name: new-snapshot-demo
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
9 changes: 9 additions & 0 deletions examples/csi-snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: snapshot.storage.k8s.io/v1alpha1
kind: VolumeSnapshot
metadata:
name: new-snapshot-demo
spec:
snapshotClassName: csi-vast-snapclass
source:
name: csi-pvc
kind: PersistentVolumeClaim
54 changes: 54 additions & 0 deletions future/csi-vast-resizer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
kind: Service
apiVersion: v1
metadata:
name: csi-vast-resizer
labels:
app: csi-vast-resizer
spec:
selector:
app: csi-vast-resizer
ports:
- name: dummy
port: 12345

---
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: csi-vast-resizer
spec:
serviceName: "csi-vast-resizer"
replicas: 1
selector:
matchLabels:
app: csi-vast-resizer
template:
metadata:
labels:
app: csi-vast-resizer
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- csi-vastplugin
topologyKey: kubernetes.io/hostname
serviceAccountName: csi-resizer
containers:
- name: csi-resizer
image: quay.io/k8scsi/csi-resizer:v0.3.0
args:
- -v=5
- -csi-address=/csi/csi.sock
volumeMounts:
- mountPath: /csi
name: socket-dir
volumes:
- hostPath:
path: /var/lib/kubelet/plugins/csi-vast
type: DirectoryOrCreate
name: socket-dir
55 changes: 55 additions & 0 deletions future/csi-vast-snapshotter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
kind: Service
apiVersion: v1
metadata:
name: csi-vast-snapshotter
labels:
app: csi-vast-snapshotter
spec:
selector:
app: csi-vast-snapshotter
ports:
- name: dummy
port: 12345

---
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: csi-vast-snapshotter
spec:
serviceName: "csi-vast-snapshotter"
replicas: 1
selector:
matchLabels:
app: csi-vast-snapshotter
template:
metadata:
labels:
app: csi-vast-snapshotter
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- csi-vastplugin
topologyKey: kubernetes.io/hostname
serviceAccount: csi-snapshotter
containers:
- name: csi-snapshotter
image: quay.io/k8scsi/csi-snapshotter:v1.2.0
args:
- -v=5
- --csi-address=/csi/csi.sock
- --connection-timeout=15s
volumeMounts:
- mountPath: /csi
name: socket-dir
volumes:
- hostPath:
path: /var/lib/kubelet/plugins/csi-vast
type: DirectoryOrCreate
name: socket-dir
46 changes: 23 additions & 23 deletions vast_csi/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,40 +436,40 @@ def CreateVolume(self, name, volume_capabilities, capacity_range=None, parameter
volume_name = volume_name[:64] # crop to Vast's max-length

requested_capacity = capacity_range.required_bytes if capacity_range else 0
existing_capacity = 0
volume_context = {}

if CONF.mock_vast:
volume = self._to_volume(volume_id)
if volume:
existing_capacity = volume.capacity_bytes
if existing_capacity != requested_capacity:
raise Abort(
ALREADY_EXISTS,
"Volume already exists with different capacity than requested"
f"({existing_capacity})")
vol_dir = self.root_mount[volume_id]
vol_dir.mkdir(exist_ok=True)

else:
quota = self.get_quota(volume_id)
if quota:
if quota := self.get_quota(volume_id):
existing_capacity = quota.hard_limit
if existing_capacity and existing_capacity != requested_capacity:
raise Abort(
ALREADY_EXISTS,
"Volume already exists with different capacity than requested"
f"({existing_capacity})")

if not existing_capacity:
pass
elif existing_capacity != requested_capacity:
raise Abort(
ALREADY_EXISTS,
"Volume already exists with different capacity than requested"
f"({existing_capacity})")
else:
data = dict(
create_dir=True,
name=volume_name,
path=str(CONF.root_export[volume_id]),
)
if requested_capacity:
data.update(hard_limit=requested_capacity)
quota = self.vms_session.post("quotas", data=data)

if CONF.mock_vast:
vol_dir = self.root_mount[volume_id]
vol_dir.mkdir()
else:
data = dict(
create_dir=True,
name=volume_name,
path=str(CONF.root_export[volume_id]),
)
if requested_capacity:
data.update(hard_limit=requested_capacity)
quota = self.vms_session.post("quotas", data=data)
volume_context.update(quota_id=quota.id)

volume = types.Volume(
capacity_bytes=requested_capacity, volume_id=volume_id,
volume_context={k: str(v) for k, v in volume_context.items()})
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.0.4
v2.0.5

0 comments on commit 159899e

Please sign in to comment.