@@ -1986,9 +1986,9 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
1986
1986
}
1987
1987
}
1988
1988
1989
- var sidebarAppID uuid.NullUUID
1989
+ var taskAppID uuid.NullUUID
1990
1990
var hasAITask bool
1991
- var warnUnknownSidebarAppID bool
1991
+ var warnUnknownTaskAppID bool
1992
1992
if tasks := jobType .WorkspaceBuild .GetAiTasks ();len (tasks )> 0 {
1993
1993
hasAITask = true
1994
1994
task := tasks [0 ]
@@ -2005,15 +2005,15 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
2005
2005
}
2006
2006
2007
2007
if ! slices .Contains (appIDs ,appID ) {
2008
- warnUnknownSidebarAppID = true
2008
+ warnUnknownTaskAppID = true
2009
2009
}
2010
2010
2011
2011
id ,err := uuid .Parse (appID )
2012
2012
if err != nil {
2013
- return xerrors .Errorf ("parsesidebar app id: %w" ,err )
2013
+ return xerrors .Errorf ("parse app id: %w" ,err )
2014
2014
}
2015
2015
2016
- sidebarAppID = uuid.NullUUID {UUID :id ,Valid :true }
2016
+ taskAppID = uuid.NullUUID {UUID :id ,Valid :true }
2017
2017
}
2018
2018
2019
2019
// This is a hacky workaround for the issue with tasks 'disappearing' on stop:
@@ -2025,19 +2025,19 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
2025
2025
BuildNumber :workspaceBuild .BuildNumber - 1 ,
2026
2026
});err == nil {
2027
2027
hasAITask = prevBuild .HasAITask .Bool
2028
- sidebarAppID = prevBuild .AITaskSidebarAppID
2029
- warnUnknownSidebarAppID = false
2030
- s .Logger .Debug (ctx ,"task workaround: reused has_ai_task andsidebar_app_id from previous build to keep track of task" ,
2028
+ taskAppID = prevBuild .AITaskSidebarAppID
2029
+ warnUnknownTaskAppID = false
2030
+ s .Logger .Debug (ctx ,"task workaround: reused has_ai_task andapp_id from previous build to keep track of task" ,
2031
2031
slog .F ("job_id" ,job .ID .String ()),
2032
2032
slog .F ("build_number" ,prevBuild .BuildNumber ),
2033
2033
slog .F ("workspace_id" ,workspace .ID ),
2034
2034
slog .F ("workspace_build_id" ,workspaceBuild .ID ),
2035
2035
slog .F ("transition" ,string (workspaceBuild .Transition )),
2036
- slog .F ("sidebar_app_id" ,sidebarAppID .UUID ),
2036
+ slog .F ("sidebar_app_id" ,taskAppID .UUID ),
2037
2037
slog .F ("has_ai_task" ,hasAITask ),
2038
2038
)
2039
2039
}else {
2040
- s .Logger .Error (ctx ,"task workaround: tracking via has_ai_task andsidebar_app from previous build failed" ,
2040
+ s .Logger .Error (ctx ,"task workaround: tracking via has_ai_task andapp_id from previous build failed" ,
2041
2041
slog .Error (err ),
2042
2042
slog .F ("job_id" ,job .ID .String ()),
2043
2043
slog .F ("workspace_id" ,workspace .ID ),
@@ -2047,14 +2047,14 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
2047
2047
}
2048
2048
}
2049
2049
2050
- if warnUnknownSidebarAppID {
2050
+ if warnUnknownTaskAppID {
2051
2051
// Ref: https://github.com/coder/coder/issues/18776
2052
2052
// This can happen for a number of reasons:
2053
2053
// 1. Misconfigured template
2054
2054
// 2. Count=0 on the agent due to stop transition, meaning the associated coder_app was not inserted.
2055
2055
// Failing the build at this point is not ideal, so log a warning instead.
2056
- s .Logger .Warn (ctx ,"unknownai_task_sidebar_app_id " ,
2057
- slog .F ("ai_task_sidebar_app_id " ,sidebarAppID .UUID .String ()),
2056
+ s .Logger .Warn (ctx ,"unknownai_task_app_id " ,
2057
+ slog .F ("ai_task_app_id " ,taskAppID .UUID .String ()),
2058
2058
slog .F ("job_id" ,job .ID .String ()),
2059
2059
slog .F ("workspace_id" ,workspace .ID ),
2060
2060
slog .F ("workspace_build_id" ,workspaceBuild .ID ),
@@ -2068,13 +2068,13 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
2068
2068
Level : []database.LogLevel {database .LogLevelWarn ,database .LogLevelWarn ,database .LogLevelWarn ,database .LogLevelWarn },
2069
2069
Stage : []string {"Cleaning Up" ,"Cleaning Up" ,"Cleaning Up" ,"Cleaning Up" },
2070
2070
Output : []string {
2071
- fmt .Sprintf ("Unknownai_task_sidebar_app_id %q. This workspace will be unable to run AI tasks. This may be due to a template configuration issue, please check with the template author." ,sidebarAppID .UUID .String ()),
2071
+ fmt .Sprintf ("Unknownai_task_app_id %q. This workspace will be unable to run AI tasks. This may be due to a template configuration issue, please check with the template author." ,taskAppID .UUID .String ()),
2072
2072
"Template author: double-check the following:" ,
2073
2073
" - You have associated the coder_ai_task with a valid coder_app in your template (ref: https://registry.terraform.io/providers/coder/coder/latest/docs/resources/ai_task)." ,
2074
2074
" - You have associated the coder_agent with at least one other compute resource. Agents with no other associated resources are not inserted into the database." ,
2075
2075
},
2076
2076
});err != nil {
2077
- s .Logger .Error (ctx ,"insert provisioner job log for ai tasksidebar app id warning" ,
2077
+ s .Logger .Error (ctx ,"insert provisioner job log for ai task app id warning" ,
2078
2078
slog .F ("job_id" ,jobID ),
2079
2079
slog .F ("workspace_id" ,workspace .ID ),
2080
2080
slog .F ("workspace_build_id" ,workspaceBuild .ID ),
@@ -2083,7 +2083,7 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
2083
2083
}
2084
2084
// Important: reset hasAITask and sidebarAppID so that we don't run into a fk constraint violation.
2085
2085
hasAITask = false
2086
- sidebarAppID = uuid.NullUUID {}
2086
+ taskAppID = uuid.NullUUID {}
2087
2087
}
2088
2088
2089
2089
if hasAITask && workspaceBuild .Transition == database .WorkspaceTransitionStart {
@@ -2120,7 +2120,7 @@ func (s *server) completeWorkspaceBuildJob(ctx context.Context, job database.Pro
2120
2120
Bool :hasExternalAgent ,
2121
2121
Valid :true ,
2122
2122
},
2123
- SidebarAppID :sidebarAppID ,
2123
+ SidebarAppID :taskAppID ,
2124
2124
UpdatedAt :now ,
2125
2125
});err != nil {
2126
2126
return xerrors .Errorf ("update workspace build ai tasks and external agent flag: %w" ,err )