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 @@ -1206,19 +1206,15 @@ func (a *agent) Close() error {
1206
1206
close (a .closed )
1207
1207
a .closeCancel ()
1208
1208
1209
- rawMetadata := a .metadata .Load ()
1210
- if rawMetadata == nil {
1211
- return xerrors .Errorf ("no metadata was provided" )
1212
- }
1213
- metadata , valid := rawMetadata .(codersdk.WorkspaceAgentMetadata )
1214
- if ! valid {
1215
- return xerrors .Errorf ("metadata is the wrong type: %T" , metadata )
1216
- }
1217
-
1218
- ctx := context .Background ()
1219
- err := a .runShutdownScript (ctx , metadata .ShutdownScript )
1220
- if err != nil {
1221
- a .logger .Error (ctx , "shutdown script failed" , slog .Error (err ))
1209
+ if metadata , ok := a .metadata .Load ().(agentsdk.Metadata ); ok {
1210
+ ctx := context .Background ()
1211
+ err := a .runShutdownScript (ctx , metadata .ShutdownScript )
1212
+ if err != nil {
1213
+ a .logger .Error (ctx , "shutdown script failed" , slog .Error (err ))
1214
+ }
1215
+ } else {
1216
+ // No metadata.. halt?
1217
+ _ = false
1222
1218
}
1223
1219
1224
1220
if a .network != nil {
Original file line number Diff line number Diff line change @@ -794,12 +794,12 @@ func TestAgent_Lifecycle(t *testing.T) {
794
794
client := & client {
795
795
t : t ,
796
796
agentID : uuid .New (),
797
- metadata : codersdk. WorkspaceAgentMetadata {
797
+ metadata : agentsdk. Metadata {
798
798
DERPMap : tailnettest .RunDERPAndSTUN (t ),
799
799
StartupScript : "echo 1" ,
800
800
ShutdownScript : "echo " + expected ,
801
801
},
802
- statsChan : make (chan * codersdk. AgentStats ),
802
+ statsChan : make (chan * agentsdk. Stats ),
803
803
coordinator : tailnet .NewCoordinator (),
804
804
}
805
805
You can’t perform that action at this time.
0 commit comments