Skip to content

ws-manager: fix event workers hang forever #12995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 6 additions & 6 deletions components/ws-manager/pkg/manager/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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{
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