@@ -79,15 +79,14 @@ type API struct {
79
79
containersErr error // Error from the last list operation.
80
80
devcontainerNames map [string ]bool // By devcontainer name.
81
81
knownDevcontainers map [string ]codersdk.WorkspaceAgentDevcontainer // By workspace folder.
82
+ devcontainerLogSourceIDs map [string ]uuid.UUID // By workspace folder.
82
83
configFileModifiedTimes map [string ]time.Time // By config file path.
83
84
recreateSuccessTimes map [string ]time.Time // By workspace folder.
84
85
recreateErrorTimes map [string ]time.Time // By workspace folder.
85
86
injectedSubAgentProcs map [string ]subAgentProcess // By workspace folder.
86
87
usingWorkspaceFolderName map [string ]bool // By workspace folder.
87
88
ignoredDevcontainers map [string ]bool // By workspace folder. Tracks three states (true, false and not checked).
88
89
asyncWg sync.WaitGroup
89
-
90
- devcontainerLogSourceIDs map [string ]uuid.UUID // By workspace folder.
91
90
}
92
91
93
92
type subAgentProcess struct {
@@ -935,12 +934,7 @@ func (api *API) CreateDevcontainer(workspaceFolder, configPath string, opts ...D
935
934
return xerrors .Errorf ("devcontainer not found" )
936
935
}
937
936
938
- api .asyncWg .Add (1 )
939
- defer api .asyncWg .Done ()
940
- api .mu .Unlock ()
941
-
942
937
var (
943
- err error
944
938
ctx = api .ctx
945
939
logger = api .logger .With (
946
940
slog .F ("devcontainer_id" , dc .ID ),
@@ -950,19 +944,23 @@ func (api *API) CreateDevcontainer(workspaceFolder, configPath string, opts ...D
950
944
)
951
945
)
952
946
953
- if dc .ConfigPath != configPath {
954
- logger .Warn (ctx , "devcontainer config path mismatch" ,
955
- slog .F ("config_path_param" , configPath ),
956
- )
957
- }
958
-
959
947
// Send logs via agent logging facilities.
960
948
logSourceID := api .devcontainerLogSourceIDs [dc .WorkspaceFolder ]
961
949
if logSourceID == uuid .Nil {
962
- // Fallback to the external log source ID if not found.
950
+ api . logger . Debug ( api . ctx , "devcontainer log source ID not found, falling back to external log source ID" )
963
951
logSourceID = agentsdk .ExternalLogSourceID
964
952
}
965
953
954
+ api .asyncWg .Add (1 )
955
+ defer api .asyncWg .Done ()
956
+ api .mu .Unlock ()
957
+
958
+ if dc .ConfigPath != configPath {
959
+ logger .Warn (ctx , "devcontainer config path mismatch" ,
960
+ slog .F ("config_path_param" , configPath ),
961
+ )
962
+ }
963
+
966
964
scriptLogger := api .scriptLogger (logSourceID )
967
965
defer func () {
968
966
flushCtx , cancel := context .WithTimeout (api .ctx , 5 * time .Second )
@@ -981,7 +979,7 @@ func (api *API) CreateDevcontainer(workspaceFolder, configPath string, opts ...D
981
979
upOptions := []DevcontainerCLIUpOptions {WithUpOutput (infoW , errW )}
982
980
upOptions = append (upOptions , opts ... )
983
981
984
- _ , err = api .dccli .Up (ctx , dc .WorkspaceFolder , configPath , upOptions ... )
982
+ _ , err : = api .dccli .Up (ctx , dc .WorkspaceFolder , configPath , upOptions ... )
985
983
if err != nil {
986
984
// No need to log if the API is closing (context canceled), as this
987
985
// is expected behavior when the API is shutting down.
0 commit comments