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