File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -1301,19 +1301,15 @@ func (a *agent) Close() error {
1301
1301
close (a .closed )
1302
1302
a .closeCancel ()
1303
1303
1304
- rawMetadata := a .metadata .Load ()
1305
- if rawMetadata == nil {
1306
- return xerrors .Errorf ("no metadata was provided" )
1307
- }
1308
- metadata , valid := rawMetadata .(codersdk.WorkspaceAgentMetadata )
1309
- if ! valid {
1310
- return xerrors .Errorf ("metadata is the wrong type: %T" , metadata )
1311
- }
1312
-
1313
- ctx := context .Background ()
1314
- err := a .runShutdownScript (ctx , metadata .ShutdownScript )
1315
- if err != nil {
1316
- a .logger .Error (ctx , "shutdown script failed" , slog .Error (err ))
1304
+ if metadata , ok := a .metadata .Load ().(agentsdk.Metadata ); ok {
1305
+ ctx := context .Background ()
1306
+ err := a .runShutdownScript (ctx , metadata .ShutdownScript )
1307
+ if err != nil {
1308
+ a .logger .Error (ctx , "shutdown script failed" , slog .Error (err ))
1309
+ }
1310
+ } else {
1311
+ // No metadata.. halt?
1312
+ _ = false
1317
1313
}
1318
1314
1319
1315
if a .network != nil {
Original file line number Diff line number Diff line change @@ -834,12 +834,12 @@ func TestAgent_Lifecycle(t *testing.T) {
834
834
client := & client {
835
835
t : t ,
836
836
agentID : uuid .New (),
837
- metadata : codersdk. WorkspaceAgentMetadata {
837
+ metadata : agentsdk. Metadata {
838
838
DERPMap : tailnettest .RunDERPAndSTUN (t ),
839
839
StartupScript : "echo 1" ,
840
840
ShutdownScript : "echo " + expected ,
841
841
},
842
- statsChan : make (chan * codersdk. AgentStats ),
842
+ statsChan : make (chan * agentsdk. Stats ),
843
843
coordinator : tailnet .NewCoordinator (),
844
844
}
845
845
You can’t perform that action at this time.
0 commit comments