From a1501da0c8e6cee936fc9b174ab10124b76bcf9e Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Fri, 6 Aug 2021 15:45:46 +0800 Subject: [PATCH] fix(region): sync openstack multi zone storages --- pkg/multicloud/openstack/novastorage.go | 4 ++++ pkg/multicloud/openstack/storage.go | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/multicloud/openstack/novastorage.go b/pkg/multicloud/openstack/novastorage.go index e8b163d62b..eb4a094d95 100644 --- a/pkg/multicloud/openstack/novastorage.go +++ b/pkg/multicloud/openstack/novastorage.go @@ -108,3 +108,7 @@ func (storage *SNovaStorage) GetMountPoint() string { func (storage *SNovaStorage) IsSysDiskStore() bool { return true } + +func (self *SNovaStorage) DisableSync() bool { + return true +} diff --git a/pkg/multicloud/openstack/storage.go b/pkg/multicloud/openstack/storage.go index af24739ec4..6eb831f6f9 100644 --- a/pkg/multicloud/openstack/storage.go +++ b/pkg/multicloud/openstack/storage.go @@ -15,6 +15,7 @@ package openstack import ( + "fmt" "net/url" "strings" "time" @@ -54,7 +55,7 @@ func (storage *SStorage) GetName() string { } func (storage *SStorage) GetGlobalId() string { - return storage.ID + return fmt.Sprintf("%s-%s", storage.zone.GetGlobalId(), storage.ID) } func (storage *SStorage) IsEmulated() bool { @@ -72,7 +73,7 @@ func (storage *SStorage) GetIDisks() ([]cloudprovider.ICloudDisk, error) { } idisks := []cloudprovider.ICloudDisk{} for i := 0; i < len(disks); i++ { - if disks[i].VolumeType == storage.Name || strings.HasSuffix(disks[i].Host, "#"+storage.ExtraSpecs.VolumeBackendName) { + if disks[i].AvailabilityZone == storage.zone.ZoneName && (disks[i].VolumeType == storage.Name || strings.HasSuffix(disks[i].Host, "#"+storage.ExtraSpecs.VolumeBackendName)) { disks[i].storage = storage idisks = append(idisks, &disks[i]) } @@ -143,6 +144,9 @@ func (storage *SStorage) GetIDiskById(idStr string) (cloudprovider.ICloudDisk, e if err != nil { return nil, err } + if disk.AvailabilityZone != storage.zone.ZoneName { + return nil, errors.Wrapf(cloudprovider.ErrNotFound, "disk %s not in zone %s", storage.zone.ZoneName) + } disk.storage = storage return disk, nil }