From 52f39d6e8615f746d457d797177745c4eb30e646 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 25 Apr 2026 13:43:01 -0700 Subject: [PATCH] parquet_pushdown(M0-C5): add weed pushdown.ping smoke command Add weed/command/pushdown_ping.go that dials a pushdown daemon over gRPC, calls Ping with a 5s timeout, and prints the daemon's reported version and trust mode. Used both as a deployment smoke test and by the M0 integration test. Default -server=localhost:18888 matches the daemon's default listen port. -tls toggles between insecure and the security/grpc.client TLS config; default insecure mirrors the iam command's pattern for local-development smoke tests. Naming follows the existing dotted convention (mq.agent, mq.broker, mq.kafka.gateway): the daemon is "weed pushdown", the smoke test is "weed pushdown.ping". --- weed/command/command.go | 1 + weed/command/pushdown_ping.go | 71 +++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 weed/command/pushdown_ping.go diff --git a/weed/command/command.go b/weed/command/command.go index 8025dcd4f..1bc12c64e 100644 --- a/weed/command/command.go +++ b/weed/command/command.go @@ -38,6 +38,7 @@ var Commands = []*Command{ cmdMqBroker, cmdMqKafkaGateway, cmdPushdown, + cmdPushdownPing, cmdS3, cmdScaffold, cmdServer, diff --git a/weed/command/pushdown_ping.go b/weed/command/pushdown_ping.go new file mode 100644 index 000000000..2912d39c2 --- /dev/null +++ b/weed/command/pushdown_ping.go @@ -0,0 +1,71 @@ +package command + +import ( + "context" + "fmt" + "os" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + + "github.com/seaweedfs/seaweedfs/weed/glog" + pb "github.com/seaweedfs/seaweedfs/weed/pb/parquet_pushdown_pb" + "github.com/seaweedfs/seaweedfs/weed/security" + "github.com/seaweedfs/seaweedfs/weed/util" +) + +var ( + pushdownPingOptions PushdownPingOptions +) + +type PushdownPingOptions struct { + target *string + timeout *time.Duration + useTLS *bool +} + +func init() { + cmdPushdownPing.Run = runPushdownPing + pushdownPingOptions.target = cmdPushdownPing.Flag.String("server", "localhost:18888", "pushdown daemon gRPC address") + pushdownPingOptions.timeout = cmdPushdownPing.Flag.Duration("timeout", 5*time.Second, "RPC deadline") + pushdownPingOptions.useTLS = cmdPushdownPing.Flag.Bool("tls", false, "dial with TLS using grpc.client config") +} + +var cmdPushdownPing = &Command{ + UsageLine: "pushdown.ping [-server=]", + Short: " ping a running pushdown daemon (M0 smoke test)", + Long: `ping a running pushdown daemon. + + Calls the SeaweedParquetPushdown.Ping RPC and prints the daemon's + reported version and trust mode. Used as a deployment smoke test + and by the M0 integration test.`, +} + +func runPushdownPing(cmd *Command, args []string) bool { + util.LoadSecurityConfiguration() + + dialOpt := grpc.WithTransportCredentials(insecure.NewCredentials()) + if *pushdownPingOptions.useTLS { + dialOpt = security.LoadClientTLS(util.GetViper(), "grpc.client") + } + + ctx, cancel := context.WithTimeout(context.Background(), *pushdownPingOptions.timeout) + defer cancel() + + conn, err := grpc.NewClient(*pushdownPingOptions.target, dialOpt) + if err != nil { + glog.Errorf("dial %s: %v", *pushdownPingOptions.target, err) + return false + } + defer conn.Close() + + resp, err := pb.NewSeaweedParquetPushdownClient(conn).Ping(ctx, &pb.PingRequest{}) + if err != nil { + glog.Errorf("ping %s: %v", *pushdownPingOptions.target, err) + return false + } + + fmt.Fprintf(os.Stdout, "ok: server=%s version=%q trust=%q\n", *pushdownPingOptions.target, resp.Version, resp.TrustMode) + return true +}