Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit12dc05e

Browse files
committed
fix: only use predetermined agent ID sometimes
1 parent3f416e4 commit12dc05e

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

‎coderd/provisionerdserver/provisionerdserver.go‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
19581958
agentTimeouts:=make(map[time.Duration]bool)// A set of agent timeouts.
19591959
// This could be a bulk insert to improve performance.
19601960
for_,protoResource:=rangejobType.WorkspaceBuild.Resources {
1961-
forai,protoAgent:=rangeprotoResource.Agents {
1961+
for_,protoAgent:=rangeprotoResource.GetAgents() {
19621962
ifprotoAgent==nil {
19631963
continue
19641964
}
@@ -1967,8 +1967,7 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
19671967
// the agent to a task. For now we overwrite the
19681968
// protoAgent.Id because that matches old behavior.
19691969
agentID:=uuid.New()
1970-
protoAgent.Id=agentID.String()
1971-
protoResource.Agents[ai]=protoAgent
1970+
protoAgent.Id=makePredeterminedAgentID(agentID)
19721971

19731972
dur:=time.Duration(protoAgent.GetConnectionTimeoutSeconds())*time.Second
19741973
agentTimeouts[dur]=true
@@ -2697,13 +2696,13 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
26972696
}
26982697

26992698
varagentID uuid.UUID
2700-
ifprAgent.GetId()=="" {
2701-
agentID=uuid.New()
2702-
}else {
2703-
agentID,err=uuid.Parse(prAgent.GetId())
2699+
ifid,ok:=predeterminedAgentID(prAgent.GetId());ok {
2700+
agentID,err=uuid.Parse(id)
27042701
iferr!=nil {
27052702
returnxerrors.Errorf("invalid agent ID format; must be uuid: %w",err)
27062703
}
2704+
}else {
2705+
agentID=uuid.New()
27072706
}
27082707
dbAgent,err:=db.InsertWorkspaceAgent(ctx, database.InsertWorkspaceAgentParams{
27092708
ID:agentID,
@@ -3280,3 +3279,14 @@ func convertDisplayApps(apps *sdkproto.DisplayApps) []database.DisplayApp {
32803279
}
32813280
returndapps
32823281
}
3282+
3283+
funcmakePredeterminedAgentID(id uuid.UUID)string {
3284+
return"keep:"+id.String()
3285+
}
3286+
3287+
funcpredeterminedAgentID(agentIDstring) (string,bool) {
3288+
if!strings.HasPrefix(agentID,"keep:") {
3289+
return"",false
3290+
}
3291+
returnstrings.TrimPrefix(agentID,"keep:"),true
3292+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp