Skip to content

Add graceful shutdown of RHP4 server with defer rhp4.Close()#944

Merged
ChrisSchinnerl merged 13 commits intomasterfrom
matt/graceful-shutdown
Apr 2, 2026
Merged

Add graceful shutdown of RHP4 server with defer rhp4.Close()#944
ChrisSchinnerl merged 13 commits intomasterfrom
matt/graceful-shutdown

Conversation

@Alrighttt
Copy link
Copy Markdown
Contributor

Fixes SiaFoundation/coreutils#412

Relies on SiaFoundation/coreutils#413

Must edit go.mod once coreutils and core have tagged releases for these changes.

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

Tip: disable this comment in your organization's Code Review settings.

@github-project-automation github-project-automation bot moved this to In Progress in Sia Mar 23, 2026
@socket-security
Copy link
Copy Markdown

socket-security bot commented Mar 23, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgo.sia.tech/​coreutils@​v0.21.1 ⏵ v0.21.2-0.20260324142241-8e1a1b8d0f4a98 +1100100100100
Updatedgo.sia.tech/​core@​v0.19.1-0.20260319092221-2e8e497f76c9 ⏵ v0.19.1-0.20260323200052-1bfa3facc40899 +1100100100100

View full report

@Alrighttt
Copy link
Copy Markdown
Contributor Author

The TestRPCFreeSectors test is failing, and it seems unrelated to these changes. The test is NDF. Taking a look at it now.

Copy link
Copy Markdown
Member

@ChrisSchinnerl ChrisSchinnerl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go.mod will require an update after merging the coreutils PR to a commit that actually exists on master.

cmd/hostd/run.go Outdated
log.Error("failed to stop listener", zap.Error(err))
}
}
rhp4.Close()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still running after stopListenerFuncs. Should be called before the loop.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you rename stopListenerFuncs to closeFns and have rhp4.Close be the first you add it might be slightly cleaner.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in aec7c80

@ChrisSchinnerl ChrisSchinnerl requested a review from peterjan March 24, 2026 15:21
cmd/hostd/run.go Outdated
log.Error("failed to stop listener", zap.Error(err))
}
}
rhp4.Close()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you rename stopListenerFuncs to closeFns and have rhp4.Close be the first you add it might be slightly cleaner.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds RHP4 server shutdown hooks to prevent lingering goroutines/resources, and adjusts integration tests to reflect updated client-side behavior.

Changes:

  • Ensure RHP4 server instances are closed during shutdown/cleanup (hostd run path + integration tests).
  • Fix TestRPCFreeSectors expected-root computation by matching the client’s index sorting behavior.
  • Bump go.sia.tech/core / go.sia.tech/coreutils dependency versions and add a changeset entry.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cmd/hostd/run.go Adds RHP4 server close to shutdown path and refactors shutdown closure handling.
internal/integration/rhp/v4/rhp4_test.go Adds cleanup for test RHP4 servers; updates FreeSectors expectation logic.
go.mod Updates core and coreutils versions required for the behavior change.
go.sum Syncs module checksums with updated dependencies.
.changeset/graceful_shutdown_of_rhp4_server_via_defer_close.md Documents the change via a new changeset entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ChrisSchinnerl ChrisSchinnerl merged commit 28f06aa into master Apr 2, 2026
12 checks passed
@ChrisSchinnerl ChrisSchinnerl deleted the matt/graceful-shutdown branch April 2, 2026 13:03
@github-project-automation github-project-automation bot moved this from In Progress to Done in Sia Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Graceful shutdown for rhp server

4 participants