mirror of
https://github.com/coder/coder.git
synced 2025-07-30 22:19:53 +00:00
fix: upsert coder_app
resources in case they are persistent (#18509)
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
protobuf "google.golang.org/protobuf/proto"
|
||||
|
||||
"cdr.dev/slog"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/util/slice"
|
||||
|
||||
"github.com/coder/coder/v2/codersdk/drpcsdk"
|
||||
@@ -2606,7 +2607,8 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
|
||||
return xerrors.Errorf("parse app uuid: %w", err)
|
||||
}
|
||||
|
||||
dbApp, err := db.InsertWorkspaceApp(ctx, database.InsertWorkspaceAppParams{
|
||||
// If workspace apps are "persistent", the ID will not be regenerated across workspace builds, so we have to upsert.
|
||||
dbApp, err := db.UpsertWorkspaceApp(ctx, database.UpsertWorkspaceAppParams{
|
||||
ID: id,
|
||||
CreatedAt: dbtime.Now(),
|
||||
AgentID: dbAgent.ID,
|
||||
@@ -2635,7 +2637,7 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
|
||||
OpenIn: openIn,
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("insert app: %w", err)
|
||||
return xerrors.Errorf("upsert app: %w", err)
|
||||
}
|
||||
snapshot.WorkspaceApps = append(snapshot.WorkspaceApps, telemetry.ConvertWorkspaceApp(dbApp))
|
||||
}
|
||||
|
Reference in New Issue
Block a user