Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

Commit 2fcbf39

Browse files
authored
Merge pull request #351 from zetaab/fixopenstackaz
BUG: OpenStack ignore AvailabilityZone in discovery
2 parents 622c454 + f592740 commit 2fcbf39

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pkg/volumes/openstack/discovery.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var _ discovery.Interface = &OpenstackVolumes{}
2828

2929
func (os *OpenstackVolumes) Poll() (map[string]discovery.Node, error) {
3030

31-
allVolumes, err := os.FindVolumes()
31+
allVolumes, err := os.findVolumes(false)
3232
if err != nil {
3333
return nil, err
3434
}

pkg/volumes/openstack/volumes.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func (stack *OpenstackVolumes) buildOpenstackVolume(d *cinderv2.Volume) (*volume
274274
return vol, nil
275275
}
276276

277-
func (stack *OpenstackVolumes) matchesTags(d *cinderv2.Volume) bool {
277+
func (stack *OpenstackVolumes) matchesTags(d *cinderv2.Volume, filterByAZ bool) bool {
278278
for _, k := range stack.matchTagKeys {
279279
_, found := d.Metadata[k]
280280
if !found {
@@ -290,7 +290,7 @@ func (stack *OpenstackVolumes) matchesTags(d *cinderv2.Volume) bool {
290290
}
291291

292292
// find volume az matching compute az
293-
if !stack.ignoreAZ {
293+
if filterByAZ && !stack.ignoreAZ {
294294
if d.AvailabilityZone != stack.zone {
295295
return false
296296
}
@@ -300,6 +300,10 @@ func (stack *OpenstackVolumes) matchesTags(d *cinderv2.Volume) bool {
300300
}
301301

302302
func (stack *OpenstackVolumes) FindVolumes() ([]*volumes.Volume, error) {
303+
return stack.findVolumes(true)
304+
}
305+
306+
func (stack *OpenstackVolumes) findVolumes(filterByAZ bool) ([]*volumes.Volume, error) {
303307
var volumes []*volumes.Volume
304308

305309
klog.V(2).Infof("Listing Openstack disks in %s/%s", stack.project, stack.meta.AvailabilityZone)
@@ -316,7 +320,7 @@ func (stack *OpenstackVolumes) FindVolumes() ([]*volumes.Volume, error) {
316320
}
317321

318322
for _, volume := range vols {
319-
if !stack.matchesTags(&volume) {
323+
if !stack.matchesTags(&volume, filterByAZ) {
320324
continue
321325
}
322326
vol, err := stack.buildOpenstackVolume(&volume)

0 commit comments

Comments
 (0)