Commit 89f989a
committed
<fix>[storage]: fix wrong BS selected in mixed VCenter env
When SelectBackupStorageMsg carries preferBsTypes, the sorting
logic uses indexOf() which returns -1 for non-preferred types
(e.g. VCenter BS), causing them to sort before preferred ones.
This fix filters backup storages by preferBsTypes first, then
sorts within the filtered set. Also adds error code
ADDON_PRIMARY_10015 when no matching backup storage is available.
1. Why is this change necessary?
SelectBackupStorageMsg.preferBsTypes is used to sort backup
storages via indexOf() on the preference list. However,
indexOf() returns -1 for types not in the list, which sorts
non-preferred types (like VCenter BS) before preferred ones.
In a mixed VCenter + Expon environment, this causes VCenter
BS to be incorrectly selected over the intended Expon BS.
2. How does it address the problem?
Instead of only sorting, the code now first filters the
candidate backup storages to only include those whose bsType
matches the preferBsTypes list. Then it sorts within the
filtered set. A new error code ADDON_PRIMARY_10015 is added
for the case where no matching backup storage is available
after filtering. All 10 locale i18n JSON files are updated.
3. Are there any side effects?
None. The filtering is only applied when preferBsTypes is
non-empty, preserving existing behavior for other callers.
# Summary of changes (by module):
- storage: filter BS candidates by preferBsTypes before sort
- utils: add ADDON_PRIMARY_10015 error code constant
- conf/i18n: add i18n entries for new error code (10 locales)
- test: add ExternalPrimaryStorageSelectBackupStorageCase
Related: ZSTAC-71706
Change-Id: Ia3af38cc50e69132a1c769180792363495c1080f1 parent 8f4ac96 commit 89f989a
13 files changed
Lines changed: 225 additions & 2 deletions
File tree
- conf/i18n/globalErrorCodeMapping
- storage/src/main/java/org/zstack/storage/addon/primary
- test/src/test/groovy/org/zstack/test/integration/storage/primary/addon
- utils/src/main/java/org/zstack/utils/clouderrorcode
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
629 | 629 | | |
630 | 630 | | |
631 | 631 | | |
| 632 | + | |
632 | 633 | | |
633 | 634 | | |
634 | 635 | | |
| |||
0 commit comments