Skip to content

Commit

Permalink
check there is indeed an upgrade route (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-sun-star authored Jan 8, 2025
1 parent dedcb63 commit 96be8d7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/helper/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func FindShortestUpgradePath(nodeMap map[string]*VersionDep, startVersionFull, t
v.Precursor = node
queue = append(queue, v)
visited.Add(v)
log.Println("Visited", v.Version, len(v.Next))
log.Printf("Visited version %s, next versions: %d \n", v.Version, len(v.Next))
}
}
}
Expand Down Expand Up @@ -221,5 +221,13 @@ func FindShortestUpgradePath(nodeMap map[string]*VersionDep, startVersionFull, t
if len(res) == 1 {
res = append([]VersionDep{*startNode}, res...)
}
result := make([]string, 0)
for _, v := range res {
result = append(result, v.Version)
}
log.Println("final result", result)
if len(result) == 0 || result[len(result)-1] != targetVersion {
return res, errors.New("There is no route to target version")
}
return res, nil
}

0 comments on commit 96be8d7

Please sign in to comment.