Browse Source

fix: use actual bind IP for service health checks

- Previously health checks were hardcoded to localhost (127.0.0.1)
- This caused failures when services bind to actual IP (e.g., 10.21.153.8)
- Now health checks use the same IP that services are binding to
- Fixes Volume and other service health check failures on non-localhost IPs
pull/7838/head
Chris Lu 2 months ago
parent
commit
888e71ec9b
  1. 20
      weed/command/mini.go

20
weed/command/mini.go

@ -767,13 +767,19 @@ func runMini(cmd *Command, args []string) bool {
// startMiniServices starts all mini services with proper dependency coordination // startMiniServices starts all mini services with proper dependency coordination
func startMiniServices(miniWhiteList []string, allServicesReady chan struct{}) { func startMiniServices(miniWhiteList []string, allServicesReady chan struct{}) {
// Determine bind IP for health checks
bindIp := *miniIp
if *miniBindIp != "" {
bindIp = *miniBindIp
}
// Start Master server (no dependencies) // Start Master server (no dependencies)
go startMiniService("Master", func() { go startMiniService("Master", func() {
startMaster(miniMasterOptions, miniWhiteList) startMaster(miniMasterOptions, miniWhiteList)
}, *miniMasterOptions.port) }, *miniMasterOptions.port)
// Wait for master to be ready // Wait for master to be ready
waitForServiceReady("Master", *miniMasterOptions.port)
waitForServiceReady("Master", *miniMasterOptions.port, bindIp)
// Start Volume server (depends on master) // Start Volume server (depends on master)
go startMiniService("Volume", func() { go startMiniService("Volume", func() {
@ -782,7 +788,7 @@ func startMiniServices(miniWhiteList []string, allServicesReady chan struct{}) {
}, *miniOptions.v.port) }, *miniOptions.v.port)
// Wait for volume to be ready // Wait for volume to be ready
waitForServiceReady("Volume", *miniOptions.v.port)
waitForServiceReady("Volume", *miniOptions.v.port, bindIp)
// Start Filer (depends on master and volume) // Start Filer (depends on master and volume)
go startMiniService("Filer", func() { go startMiniService("Filer", func() {
@ -790,7 +796,7 @@ func startMiniServices(miniWhiteList []string, allServicesReady chan struct{}) {
}, *miniFilerOptions.port) }, *miniFilerOptions.port)
// Wait for filer to be ready // Wait for filer to be ready
waitForServiceReady("Filer", *miniFilerOptions.port)
waitForServiceReady("Filer", *miniFilerOptions.port, bindIp)
// Start S3 and WebDAV in parallel (both depend on filer) // Start S3 and WebDAV in parallel (both depend on filer)
go startMiniService("S3", func() { go startMiniService("S3", func() {
@ -802,8 +808,8 @@ func startMiniServices(miniWhiteList []string, allServicesReady chan struct{}) {
}, *miniWebDavOptions.port) }, *miniWebDavOptions.port)
// Wait for both S3 and WebDAV to be ready // Wait for both S3 and WebDAV to be ready
waitForServiceReady("S3", *miniS3Options.port)
waitForServiceReady("WebDAV", *miniWebDavOptions.port)
waitForServiceReady("S3", *miniS3Options.port, bindIp)
waitForServiceReady("WebDAV", *miniWebDavOptions.port, bindIp)
// Start Admin with worker (depends on master, filer, S3, WebDAV) // Start Admin with worker (depends on master, filer, S3, WebDAV)
go startMiniAdminWithWorker(allServicesReady) go startMiniAdminWithWorker(allServicesReady)
@ -816,8 +822,8 @@ func startMiniService(name string, fn func(), port int) {
} }
// waitForServiceReady pings the service HTTP endpoint to check if it's ready to accept connections // waitForServiceReady pings the service HTTP endpoint to check if it's ready to accept connections
func waitForServiceReady(name string, port int) {
address := fmt.Sprintf("http://127.0.0.1:%d", port)
func waitForServiceReady(name string, port int, bindIp string) {
address := fmt.Sprintf("http://%s:%d", bindIp, port)
maxAttempts := 30 // 30 * 200ms = 6 seconds max wait maxAttempts := 30 // 30 * 200ms = 6 seconds max wait
attempt := 0 attempt := 0
client := &http.Client{ client := &http.Client{

Loading…
Cancel
Save