Skip to content

Commit 50137b5

Browse files
committed
fix(agent): correct serial log comment and add shutdown timeout to API server
1 parent c04d810 commit 50137b5

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

internal/agent/api/server.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ func (s *APIServer) Start(ctx context.Context) error {
3434
srv := &http.Server{Addr: ":9091", Handler: mux, ReadHeaderTimeout: 10 * time.Second}
3535
go func() {
3636
<-ctx.Done()
37-
_ = srv.Shutdown(context.Background()) //nolint:errcheck
37+
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
38+
defer cancel()
39+
_ = srv.Shutdown(shutdownCtx) //nolint:errcheck
3840
}()
3941
if err := srv.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) {
4042
return err

internal/agent/firecracker_driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func (d *FirecrackerDriver) Start(ctx context.Context, vm *impdevv1alpha1.ImpVM)
220220
return 0, fmt.Errorf("open serial log %s: %w", serialLogPath, err)
221221
}
222222
cmd.Stdout = serialLogFile
223-
defer serialLogFile.Close() //nolint:errcheck // file stays open via cmd until process exits
223+
defer serialLogFile.Close() //nolint:errcheck // child inherits fd; parent closing its copy is safe
224224

225225
// 7. Create and start the machine.
226226
m, err := firecracker.NewMachine(ctx, cfg, firecracker.WithProcessRunner(cmd))

0 commit comments

Comments
 (0)