hanahmily commented on code in PR #927:
URL:
https://github.com/apache/skywalking-banyandb/pull/927#discussion_r2674830485
##########
banyand/backup/lifecycle/service.go:
##########
@@ -105,17 +135,95 @@ func (l *lifecycleService) FlagSet() *run.FlagSet {
flagS.IntVar(&l.maxExecutionTimes, "max-execution-times", 0, "Maximum
number of times to execute the lifecycle migration. 0 means no limit.")
l.chunkSize = run.Bytes(1024 * 1024)
flagS.VarP(&l.chunkSize, "chunk-size", "", "Chunk size in bytes for
streaming data during migration (default: 1MB)")
+
+ // Lifecycle server flags
+ flagS.BoolVar(&l.lifecycleTLS, "lifecycle-tls", false, "connection uses
TLS if true, else plain TCP")
+ flagS.StringVar(&l.lifecycleCertFile, "lifecycle-cert-file", "", "the
TLS cert file")
+ flagS.StringVar(&l.lifecycleKeyFile, "lifecycle-key-file", "", "the TLS
key file")
+ flagS.StringVar(&l.lifecycleHost, "lifecycle-grpc-host", "", "the host
of lifecycle server listens")
+ flagS.Uint32Var(&l.lifecycleGRPCPort, "lifecycle-grpc-port", 17912,
"the port of lifecycle server listens")
+ flagS.Uint32Var(&l.lifecycleHTTPPort, "lifecycle-http-port", 17913,
"the port of lifecycle http api listens")
+
return flagS
}
func (l *lifecycleService) Validate() error {
+ l.lifecycleGRPCAddr = net.JoinHostPort(l.lifecycleHost,
strconv.FormatUint(uint64(l.lifecycleGRPCPort), 10))
+ if l.lifecycleGRPCAddr == ":" {
+ return errors.New("no gRPC address")
+ }
+ l.lifecycleHTTPAddr = net.JoinHostPort(l.lifecycleHost,
strconv.FormatUint(uint64(l.lifecycleHTTPPort), 10))
+ if l.lifecycleHTTPAddr == ":" {
+ return errors.New("no HTTP address")
+ }
+ if l.lifecycleTLS {
+ if l.lifecycleCertFile == "" {
+ return errors.New("missing cert file when TLS is
enabled")
+ }
+ if l.lifecycleKeyFile == "" {
+ return errors.New("missing key file when TLS is
enabled")
+ }
+ }
Review Comment:
Validate them only when l.schedule is not empty.
##########
banyand/backup/lifecycle/service.go:
##########
@@ -124,6 +232,11 @@ func (l *lifecycleService) Name() string {
func (l *lifecycleService) Serve() run.StopNotify {
l.l = logger.GetLogger("lifecycle")
+ l.stopCh = make(chan struct{})
+
+ // Start gRPC/HTTP servers
+ l.startServers()
Review Comment:
Start the server when the agent runs with a schedule.
##########
banyand/backup/lifecycle/service.go:
##########
@@ -105,17 +135,95 @@ func (l *lifecycleService) FlagSet() *run.FlagSet {
flagS.IntVar(&l.maxExecutionTimes, "max-execution-times", 0, "Maximum
number of times to execute the lifecycle migration. 0 means no limit.")
l.chunkSize = run.Bytes(1024 * 1024)
flagS.VarP(&l.chunkSize, "chunk-size", "", "Chunk size in bytes for
streaming data during migration (default: 1MB)")
+
+ // Lifecycle server flags
+ flagS.BoolVar(&l.lifecycleTLS, "lifecycle-tls", false, "connection uses
TLS if true, else plain TCP")
+ flagS.StringVar(&l.lifecycleCertFile, "lifecycle-cert-file", "", "the
TLS cert file")
+ flagS.StringVar(&l.lifecycleKeyFile, "lifecycle-key-file", "", "the TLS
key file")
+ flagS.StringVar(&l.lifecycleHost, "lifecycle-grpc-host", "", "the host
of lifecycle server listens")
+ flagS.Uint32Var(&l.lifecycleGRPCPort, "lifecycle-grpc-port", 17912,
"the port of lifecycle server listens")
+ flagS.Uint32Var(&l.lifecycleHTTPPort, "lifecycle-http-port", 17913,
"the port of lifecycle http api listens")
+
return flagS
}
func (l *lifecycleService) Validate() error {
+ l.lifecycleGRPCAddr = net.JoinHostPort(l.lifecycleHost,
strconv.FormatUint(uint64(l.lifecycleGRPCPort), 10))
+ if l.lifecycleGRPCAddr == ":" {
+ return errors.New("no gRPC address")
+ }
+ l.lifecycleHTTPAddr = net.JoinHostPort(l.lifecycleHost,
strconv.FormatUint(uint64(l.lifecycleHTTPPort), 10))
+ if l.lifecycleHTTPAddr == ":" {
+ return errors.New("no HTTP address")
+ }
+ if l.lifecycleTLS {
+ if l.lifecycleCertFile == "" {
+ return errors.New("missing cert file when TLS is
enabled")
+ }
+ if l.lifecycleKeyFile == "" {
+ return errors.New("missing key file when TLS is
enabled")
+ }
+ }
+ return nil
+}
+
+// PreRun initializes the lifecycle service and its embedded server.
+func (l *lifecycleService) PreRun(_ context.Context) error {
+ l.l = logger.GetLogger("lifecycle")
+
+ if l.lifecycleTLS {
+ var err error
+ l.tlsReloader, err = pkgtls.NewReloader(l.lifecycleCertFile,
l.lifecycleKeyFile, l.l)
+ if err != nil {
+ return errors.Wrap(err, "failed to initialize TLS
reloader")
+ }
+ }
Review Comment:
Execute them only if the schedule is not empty.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]