diff --git a/components/ws-manager/pkg/manager/manager.go b/components/ws-manager/pkg/manager/manager.go index 0637a1767bdd25..80f81114445116 100644 --- a/components/ws-manager/pkg/manager/manager.go +++ b/components/ws-manager/pkg/manager/manager.go @@ -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{ diff --git a/components/ws-manager/pkg/manager/monitor.go b/components/ws-manager/pkg/manager/monitor.go index 4548fdca0419e6..45714cdecf009e 100644 --- a/components/ws-manager/pkg/manager/monitor.go +++ b/components/ws-manager/pkg/manager/monitor.go @@ -200,11 +200,10 @@ func (m *Monitor) onVolumesnapshotEvent(evt watch.Event) error { } m.notifyPodMapLock.Lock() - if m.notifyPod[podName] == nil { - m.notifyPod[podName] = make(chan string) + if m.notifyPod[podName] != nil { + m.notifyPod[podName] <- vsc } m.notifyPodMapLock.Unlock() - m.notifyPod[podName] <- vsc return nil } @@ -1129,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{ diff --git a/components/ws-manager/pkg/manager/volume_snapshot_controller.go b/components/ws-manager/pkg/manager/volume_snapshot_controller.go index 2cd5cab463fae7..b512d5667274e5 100644 --- a/components/ws-manager/pkg/manager/volume_snapshot_controller.go +++ b/components/ws-manager/pkg/manager/volume_snapshot_controller.go @@ -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,