Fix a bug in zoneToRegion
which didn't work if multiple zones where passed separated by __
#2731
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change Overview
There was a bug in
zoneToRegion
function because of which the PV resources were not being created with correctnodeAffinity
set.zoneToRegion
tried to get regions from passed zone just by removing-[onechar]
from the zone. For example if we passed the zoneus-west1-b
this function would returnus-west1
by removing-b
. This would work properly in the cases where just one zone is given to the function.But if more than one zones are given to the function (separated by
__
), this function didn't work properly. Because for the inputus-west1-a__us-west2-a
it returnedus-west1-a__us-west2
(using existing logic), which is incorrect. As we can see the-a
was not reomved from first zone. This commit doesn't introduce the separator__
, it was already part of code and zones were being passed to this funciton separated by__
.This commit fixes above problem by making sure that we split the zones and then remove
-char
from the zone and add the regions together again using__
sep.Pull request type
Please check the type of change your PR introduces:
Issues
Test Plan