From 78129f2d617a8ca9b9f7d350f5d2b77a3ba20cab Mon Sep 17 00:00:00 2001 From: zhijian Date: Mon, 24 Jul 2023 11:06:30 +0800 Subject: [PATCH] fix --- cmd/sync.go | 12 ++++++------ pkg/sync/cluster.go | 8 ++++---- pkg/sync/config.go | 4 ++-- pkg/sync/sync.go | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cmd/sync.go b/cmd/sync.go index fdf0539b8f08..2ccb2c2f7810 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -213,17 +213,17 @@ func syncStorageFlags() []cli.Flag { func clusterFlags() []cli.Flag { return addCategories("CLUSTER", []cli.Flag{ &cli.StringFlag{ - Name: "manager", - Usage: "manager address", + Name: "manager", + Usage: "the manager address used only by the worker node", + Hidden: true, }, &cli.StringSliceFlag{ Name: "worker", Usage: "hosts (separated by comma) to launch worker", }, - &cli.BoolFlag{ - Name: "is-worker", - Usage: "start as a worker", - Hidden: true, + &cli.StringFlag{ + Name: "manager-address", + Usage: "manager address", }, }) } diff --git a/pkg/sync/cluster.go b/pkg/sync/cluster.go index d431a4304767..656e820f4d41 100644 --- a/pkg/sync/cluster.go +++ b/pkg/sync/cluster.go @@ -172,8 +172,8 @@ func startManager(config *Config, tasks <-chan object.Object) (string, error) { _, _ = w.Write([]byte("OK")) }) var addr string - if config.Manager != "" && !config.IsWorker { - addr = config.Manager + if config.ManagerAddr != "" { + addr = config.ManagerAddr } else { ips, err := utils.FindLocalIPs() if err != nil { @@ -267,9 +267,9 @@ func launchWorker(address string, config *Config, wg *sync.WaitGroup) { args = append(args, rpath) if strings.HasSuffix(path, "juicefs") { args = append(args, os.Args[1:]...) - args = append(args, "--is-worker", "--manager", address) + args = append(args, "--manager", address) } else { - args = append(args, "--is-worker", "--manager", address) + args = append(args, "--manager", address) args = append(args, os.Args[1:]...) } if !config.Verbose && !config.Quiet { diff --git a/pkg/sync/config.go b/pkg/sync/config.go index 7ab541509abf..065aebcbb873 100644 --- a/pkg/sync/config.go +++ b/pkg/sync/config.go @@ -44,7 +44,7 @@ type Config struct { Limit int64 Manager string Workers []string - IsWorker bool + ManagerAddr string ListThreads int ListDepth int BWLimit int @@ -150,7 +150,7 @@ func NewConfigFromCli(c *cli.Context) *Config { Links: c.Bool("links"), Limit: c.Int64("limit"), Workers: c.StringSlice("worker"), - IsWorker: c.Bool("is-worker"), + ManagerAddr: c.String("manager-address"), Manager: c.String("manager"), BWLimit: c.Int("bwlimit"), NoHTTPS: c.Bool("no-https"), diff --git a/pkg/sync/sync.go b/pkg/sync/sync.go index 1fcc99172540..358287814ec6 100644 --- a/pkg/sync/sync.go +++ b/pkg/sync/sync.go @@ -980,7 +980,7 @@ func Sync(src, dst object.ObjectStorage, config *Config) error { } var bufferSize = 10240 - if config.IsWorker { + if config.Manager != "" { bufferSize = 100 } tasks := make(chan object.Object, bufferSize) @@ -991,7 +991,7 @@ func Sync(src, dst object.ObjectStorage, config *Config) error { limiter = ratelimit.NewBucketWithRate(bps, int64(bps)*3) } - progress := utils.NewProgress(config.Verbose || config.Quiet || config.IsWorker) + progress := utils.NewProgress(config.Verbose || config.Quiet || config.Manager != "") handled = progress.AddCountBar("Scanned objects", 0) skipped = progress.AddCountSpinner("Skipped objects") pending = progress.AddCountSpinner("Pending objects") @@ -1032,7 +1032,7 @@ func Sync(src, dst object.ObjectStorage, config *Config) error { config.rules = rules } - if !config.IsWorker { + if config.Manager == "" { if len(config.Workers) > 0 { addr, err := startManager(config, tasks) if err != nil { @@ -1067,7 +1067,7 @@ func Sync(src, dst object.ObjectStorage, config *Config) error { pending.SetCurrent(0) progress.Done() - if !config.IsWorker { + if config.Manager == "" { msg := fmt.Sprintf("Found: %d, skipped: %d, copied: %d (%s)", handled.Current(), skipped.Current(), copied.Current(), formatSize(copiedBytes.Current())) if checked != nil {