Skip to content

Commit

Permalink
Add workspapce ID annotation to VolumeSnapshot object for filter event
Browse files Browse the repository at this point in the history
Signed-off-by: JenTing Hsiao <[email protected]>
  • Loading branch information
jenting authored and roboquat committed Sep 15, 2022
1 parent 7c45c85 commit df91671
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions components/ws-manager/pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,9 @@ func (m *Manager) restoreVolumeSnapshotFromHandle(ctx context.Context, id, handl
snapshotContentName := "restored-" + id
volumeSnapshot := &volumesnapshotv1.VolumeSnapshot{
ObjectMeta: metav1.ObjectMeta{
Name: id,
Namespace: m.Config.Namespace,
Name: id,
Namespace: m.Config.Namespace,
Annotations: map[string]string{workspaceIDAnnotation: id},
},
Spec: volumesnapshotv1.VolumeSnapshotSpec{
Source: volumesnapshotv1.VolumeSnapshotSource{
Expand Down
7 changes: 4 additions & 3 deletions components/ws-manager/pkg/manager/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1128,9 +1128,10 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
// create snapshot object out of PVC
volumeSnapshot := &volumesnapshotv1.VolumeSnapshot{
ObjectMeta: metav1.ObjectMeta{
Name: pvcVolumeSnapshotName,
Namespace: m.manager.Config.Namespace,
Labels: wso.Pod.Labels,
Name: pvcVolumeSnapshotName,
Namespace: m.manager.Config.Namespace,
Annotations: map[string]string{workspaceIDAnnotation: workspaceID},
Labels: wso.Pod.Labels,
},
Spec: volumesnapshotv1.VolumeSnapshotSpec{
Source: volumesnapshotv1.VolumeSnapshotSource{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ func (r *VolumeSnapshotReconciler) Reconcile(ctx context.Context, req ctrl.Reque
return reconcile.Result{}, nil
}

queue := vs.Annotations[workspaceIDAnnotation]
if queue == "" {
return ctrl.Result{}, nil
}

r.Monitor.eventpool.Add(vs.Name, watch.Event{
Type: watch.Modified,
Object: &vs,
Expand Down

0 comments on commit df91671

Please sign in to comment.