* Fix: Add -admin.grpc flag to worker for explicit gRPC port configuration * Fix(helm): Add adminGrpcServer to worker configuration * Refactor: Support host:port.grpcPort address format, revert -admin.grpc flag * Helm: Conditionally append grpcPort to worker admin address * weed/admin: fix "send on closed channel" panic in worker gRPC server Make unregisterWorker connection-aware to prevent closing channels belonging to newer connections. * weed/worker: improve gRPC client stability and logging - Fix goroutine leak in reconnection logic - Refactor reconnection loop to exit on success and prevent busy-waiting - Add session identification and enhanced logging to client handlers - Use constant for internal reset action and remove unused variables * weed/worker: fix worker state initialization and add lifecycle logs - Revert workerState to use running boolean correctly - Prevent handleStart failing by checking running state instead of startTime - Add more detailed logs for worker startup events
This commit is contained in:
@@ -257,6 +257,15 @@ func hostAndPort(address string) (host string, port uint64, err error) {
|
||||
if colonIndex < 0 {
|
||||
return "", 0, fmt.Errorf("server should have hostname:port format: %v", address)
|
||||
}
|
||||
dotIndex := strings.LastIndex(address, ".")
|
||||
if dotIndex > colonIndex {
|
||||
// port format is "port.grpcPort"
|
||||
port, err = strconv.ParseUint(address[colonIndex+1:dotIndex], 10, 64)
|
||||
if err != nil {
|
||||
return "", 0, fmt.Errorf("server port parse error: %w", err)
|
||||
}
|
||||
return address[:colonIndex], port, err
|
||||
}
|
||||
port, err = strconv.ParseUint(address[colonIndex+1:], 10, 64)
|
||||
if err != nil {
|
||||
return "", 0, fmt.Errorf("server port parse error: %w", err)
|
||||
@@ -267,6 +276,19 @@ func hostAndPort(address string) (host string, port uint64, err error) {
|
||||
|
||||
func ServerToGrpcAddress(server string) (serverGrpcAddress string) {
|
||||
|
||||
colonIndex := strings.LastIndex(server, ":")
|
||||
if colonIndex >= 0 {
|
||||
if dotIndex := strings.LastIndex(server, "."); dotIndex > colonIndex {
|
||||
// port format is "port.grpcPort"
|
||||
// return the host:grpcPort
|
||||
host := server[:colonIndex]
|
||||
grpcPort := server[dotIndex+1:]
|
||||
if _, err := strconv.ParseUint(grpcPort, 10, 64); err == nil {
|
||||
return util.JoinHostPort(host, int(0+util.ParseInt(grpcPort, 0)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
host, port, parseErr := hostAndPort(server)
|
||||
if parseErr != nil {
|
||||
glog.Fatalf("server address %s parse error: %v", server, parseErr)
|
||||
|
||||
Reference in New Issue
Block a user