Skip to content

Commit 62ba66d

Browse files
committed
WIP - take vol group snap in RS and RD
- RS does all sorts of lookups to create PVS from the vol group snapshot that will hopefully not be necessary - see issue: kubernetes-csi/external-snapshotter#969 Signed-off-by: Tesshu Flower <[email protected]>
1 parent 1bf2cb5 commit 62ba66d

18 files changed

+1043
-115
lines changed

api/v1alpha1/common_types.go

+22
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,17 @@ type CustomCASpec struct {
122122
}
123123

124124
type SourcePVCGroup struct {
125+
//TODO: possibly instead of selector use source volumesnapshotsource
126+
//TODO: See: https://github.com/kubernetes-csi/external-snapshotter/blob/cdbbb78ff88de2d72bdeb2e3bb30f81e12128a55/client/apis/volumegroupsnapshot/v1alpha1/types.go#L31
125127
Selector metav1.LabelSelector `json:"selector,omitempty"`
128+
129+
// VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass
130+
// requested by the VolumeGroupSnapshot.
131+
// VolumeGroupSnapshotClassName may be left nil to indicate that the default
132+
// class will be used.
133+
// Empty string is not allowed for this field.
134+
// +optional
135+
VolumeGroupSnapshotClassName *string `json:"volumeGroupSnapshotClassName,omitempty"`
126136
}
127137

128138
// TODO: rename, perhaps move somewhere?
@@ -139,3 +149,15 @@ type DestinationPVCGroupMember struct {
139149
TempPVCName string `json:"tempPVCName,omitempty"` //TODO: rename field?
140150
//TODO: size, spec stuff
141151
}
152+
153+
func (m DestinationPVCGroupMember) GetOriginalPVCName() string {
154+
return m.Name
155+
}
156+
157+
func (m DestinationPVCGroupMember) GetDestinationPVCName() string {
158+
// If TempPVCName is specified - this name should be used as the pvc to replicate into at the destination
159+
if m.TempPVCName != "" {
160+
return m.TempPVCName
161+
}
162+
return m.Name
163+
}

api/v1alpha1/events.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const (
2525
EvRTransferStarted = "TransferStarted"
2626
EvRTransferFailed = "TransferFailed" // Warning
2727
EvRSnapCreated = "VolumeSnapshotCreated"
28-
EvRSnapNotBound = "VolumeSnapshotNotBound" // Warning
28+
EvRSnapNotBound = "VolumeSnapshotNotBound" // Warning
29+
EvRVGSnapNotBound = "VolumeGroupSnapshotNotBound" // Warning
2930
EvRPVCCreated = "PersistentVolumeClaimCreated"
3031
EvRPVCNotBound = "PersistentVolumeClaimNotBound" // Warning
3132
EvRSvcAddress = "ServiceAddressAssigned"
@@ -34,11 +35,12 @@ const (
3435

3536
// ReplicationSource/ReplicationDestination Event "action" strings: Things the controller "does"
3637
const (
37-
EvANone = "" // No action
38-
EvACreateMover = "CreateMover"
39-
EvADeleteMover = "DeleteMover"
40-
EvACreatePVC = "CreatePersistentVolumeClaim"
41-
EvACreateSnap = "CreateVolumeSnapshot"
38+
EvANone = "" // No action
39+
EvACreateMover = "CreateMover"
40+
EvADeleteMover = "DeleteMover"
41+
EvACreatePVC = "CreatePersistentVolumeClaim"
42+
EvACreateSnap = "CreateVolumeSnapshot"
43+
EvACreateVGSnap = "CreateVolumeGroupSnapshot"
4244
)
4345

4446
// Volume Populator Event "reason" strings

api/v1alpha1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/volsync.backube_replicationsources.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -940,10 +940,8 @@ spec:
940940
description: sourcePVCGroup
941941
properties:
942942
selector:
943-
description: A label selector is a label query over a set of resources.
944-
The result of matchLabels and matchExpressions are ANDed. An
945-
empty label selector matches all objects. A null label selector
946-
matches no objects.
943+
description: 'TODO: possibly instead of selector use source volumesnapshotsource
944+
TODO: See: https://github.com/kubernetes-csi/external-snapshotter/blob/cdbbb78ff88de2d72bdeb2e3bb30f81e12128a55/client/apis/volumegroupsnapshot/v1alpha1/types.go#L31'
947945
properties:
948946
matchExpressions:
949947
description: matchExpressions is a list of label selector
@@ -987,6 +985,12 @@ spec:
987985
type: object
988986
type: object
989987
x-kubernetes-map-type: atomic
988+
volumeGroupSnapshotClassName:
989+
description: VolumeGroupSnapshotClassName is the name of the VolumeGroupSnapshotClass
990+
requested by the VolumeGroupSnapshot. VolumeGroupSnapshotClassName
991+
may be left nil to indicate that the default class will be used.
992+
Empty string is not allowed for this field.
993+
type: string
990994
type: object
991995
syncthing:
992996
description: syncthing defines the configuration when using Syncthing-based

config/rbac/role.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,19 @@ rules:
156156
- create
157157
- patch
158158
- update
159+
- apiGroups:
160+
- groupsnapshot.storage.k8s.io
161+
resources:
162+
- volumegroupsnapshots
163+
verbs:
164+
- create
165+
- delete
166+
- deletecollection
167+
- get
168+
- list
169+
- patch
170+
- update
171+
- watch
159172
- apiGroups:
160173
- populator.storage.k8s.io
161174
resources:

controllers/mover/rclone/mover.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (m *Mover) ensureDestinationPVC(ctx context.Context) (*corev1.PersistentVol
180180
return m.vh.UseProvidedPVC(ctx, dataPVCName)
181181
}
182182
// Need to allocate the incoming data volume
183-
return m.vh.EnsureNewPVC(ctx, m.logger, dataPVCName)
183+
return m.vh.EnsureNewPVC(ctx, m.logger, dataPVCName, nil)
184184
}
185185

186186
func (m *Mover) getDestinationPVCName() (bool, string) {

controllers/mover/restic/mover.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func (m *Mover) ensureCache(ctx context.Context,
211211
// Allocate cache volume
212212
cacheName := mover.VolSyncPrefix + m.owner.GetName() + "-cache"
213213
m.logger.Info("allocating cache volume", "PVC", cacheName)
214-
return cacheVh.EnsureNewPVC(ctx, m.logger, cacheName)
214+
return cacheVh.EnsureNewPVC(ctx, m.logger, cacheName, nil)
215215
}
216216

217217
func (m *Mover) ensureSourcePVC(ctx context.Context) (*corev1.PersistentVolumeClaim, error) {
@@ -234,7 +234,7 @@ func (m *Mover) ensureDestinationPVC(ctx context.Context) (*corev1.PersistentVol
234234
return m.vh.UseProvidedPVC(ctx, dataPVCName)
235235
}
236236
// Need to allocate the incoming data volume
237-
return m.vh.EnsureNewPVC(ctx, m.logger, dataPVCName)
237+
return m.vh.EnsureNewPVC(ctx, m.logger, dataPVCName, nil)
238238
}
239239

240240
func (m *Mover) getDestinationPVCName() (bool, string) {

controllers/mover/rsync/mover.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func (m *Mover) ensureDestinationPVC(ctx context.Context) (*corev1.PersistentVol
319319
return m.vh.UseProvidedPVC(ctx, dataPVCName)
320320
}
321321
// Need to allocate the incoming data volume
322-
return m.vh.EnsureNewPVC(ctx, m.logger, dataPVCName)
322+
return m.vh.EnsureNewPVC(ctx, m.logger, dataPVCName, nil)
323323
}
324324

325325
func (m *Mover) getDestinationPVCName() (bool, string) {

0 commit comments

Comments
 (0)