when creating bucket, use remote storage client for default storage

This commit is contained in:
Chris Lu 2021-09-04 04:54:55 -07:00
parent 63c84584bb
commit 13cc2ef723
2 changed files with 9 additions and 4 deletions

View file

@ -105,7 +105,6 @@ func runFilerRemoteSynchronize(cmd *Command, args []string) bool {
})
}
storageName := *remoteSyncOptions.createBucketAt
remoteSyncOptions.bucketsDir = "/buckets"
// check buckets again
remoteSyncOptions.WithFilerClient(func(filerClient filer_pb.SeaweedFilerClient) error {
@ -117,10 +116,11 @@ func runFilerRemoteSynchronize(cmd *Command, args []string) bool {
return nil
})
storageName := *remoteSyncOptions.createBucketAt
if storageName != "" {
fmt.Printf("synchronize %s, default new bucket creation in %s ...\n", remoteSyncOptions.bucketsDir, storageName)
util.RetryForever("filer.remote.sync buckets "+storageName, func() error {
return followBucketUpdatesAndUploadToRemote(&remoteSyncOptions, filerSource, storageName)
return remoteSyncOptions.followBucketUpdatesAndUploadToRemote(filerSource)
}, func(err error) bool {
if err != nil {
glog.Errorf("synchronize %s to %s: %v", remoteSyncOptions.bucketsDir, storageName, err)

View file

@ -16,7 +16,7 @@ import (
"time"
)
func followBucketUpdatesAndUploadToRemote(option *RemoteSyncOptions, filerSource *source.FilerSource, storageName string) error {
func (option *RemoteSyncOptions) followBucketUpdatesAndUploadToRemote(filerSource *source.FilerSource) error {
// read filer remote storage mount mappings
if detectErr := option.collectRemoteStorageConf(); detectErr != nil {
@ -46,7 +46,12 @@ func (option *RemoteSyncOptions) makeBucketedEventProcessor(filerSource *source.
if !entry.IsDirectory {
return nil
}
client, err := option.findRemoteStorageClient(entry.Name)
remoteConf, found := option.remoteConfs[*option.createBucketAt]
if !found {
return fmt.Errorf("un-configured remote storage %s", *option.createBucketAt)
}
client, err := remote_storage.GetRemoteStorage(remoteConf)
if err != nil {
return err
}