Skip to content

Commit

Permalink
bug: always ensure the workspace is up to date on the thread
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Dec 18, 2024
1 parent 1b8ab47 commit 672dba5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pkg/controller/handlers/threads/threads.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,24 @@ func getWorkspace(ctx context.Context, c kclient.WithWatch, thread *v1.Thread) (
func CreateWorkspaces(req router.Request, _ router.Response) error {
thread := req.Object.(*v1.Thread)

if thread.Status.WorkspaceID != "" && thread.Status.WorkspaceName != "" {
return nil
}

ws, err := getWorkspace(req.Ctx, req.Client, thread)
if err != nil {
return err
}

thread.Status.WorkspaceID = ws.Status.WorkspaceID
thread.Status.WorkspaceName = ws.Name
return req.Client.Status().Update(req.Ctx, thread)
var update bool
if thread.Status.WorkspaceID != ws.Status.WorkspaceID {
update = true
thread.Status.WorkspaceID = ws.Status.WorkspaceID
}
if thread.Status.WorkspaceName != ws.Name {
update = true
thread.Status.WorkspaceName = ws.Name
}
if update {
return req.Client.Status().Update(req.Ctx, thread)
}
return nil
}

func CreateKnowledgeSet(req router.Request, _ router.Response) error {
Expand Down

0 comments on commit 672dba5

Please sign in to comment.