Skip to content

Commit a25bb5a

Browse files
authored
[SC2] Refactor fallback channel selection to sort by semantic version and find the first available channel (#1172)
* Refactor fallback channel selection to sort by semantic version and find the first available channel Signed-off-by: Daniel Fan <[email protected]> * @Daniel-Fan Increase golangci-lint timeout Signed-off-by: Daniel Fan <[email protected]> --------- Signed-off-by: Daniel Fan <[email protected]>
1 parent 27c7eeb commit a25bb5a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

common/scripts/lint_go.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
# limitations under the License.
1616
#
1717

18-
GOGC=25 golangci-lint run -c ./common/config/.golangci.yml --timeout=300s
18+
GOGC=25 golangci-lint run -c ./common/config/.golangci.yml --timeout=600s

controllers/operator/manager.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,14 @@ func findCatalogFromFallbackChannels(fallbackChannels []string, fallBackChannelA
269269
// sort fallback channels by semantic version
270270
semverlList, semVerChannelMappings := prunedSemverChannel(fallbackChannels)
271271

272-
maxChannel := util.FindMaxSemver("", semverlList, semVerChannelMappings)
273-
if catalogSources, ok := fallBackChannelAndCatalogMapping[maxChannel]; ok {
274-
fallbackChannel = maxChannel
275-
fallbackCatalog = append(fallbackCatalog, catalogSources...)
272+
sort.Sort(semver.ByVersion(semverlList))
273+
// find the first available channel from the sorted list in descending order
274+
for i := len(semverlList) - 1; i >= 0; i-- {
275+
if catalogs, ok := fallBackChannelAndCatalogMapping[semVerChannelMappings[semverlList[i]]]; ok {
276+
fallbackChannel = semVerChannelMappings[semverlList[i]]
277+
fallbackCatalog = catalogs
278+
break
279+
}
276280
}
277281
return fallbackChannel, fallbackCatalog
278282
}

0 commit comments

Comments
 (0)