Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Clusterctl enforce provider order during init and upgrade #5321

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/clusterctl/client/cluster/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cluster

import (
"context"
"sort"
"time"

"github.com/pkg/errors"
Expand Down Expand Up @@ -76,6 +77,11 @@ var _ ProviderInstaller = &providerInstaller{}

func (i *providerInstaller) Add(components repository.Components) {
i.installQueue = append(i.installQueue, components)

// Ensure Providers are installed in the following order: Core, Bootstrap, ControlPlane, Infrastructure.
sort.Slice(i.installQueue, func(a, b int) bool {
return i.installQueue[a].Type().Order() < i.installQueue[b].Type().Order()
})
}

func (i *providerInstaller) Install(opts InstallOptions) ([]repository.Components, error) {
Expand Down
10 changes: 9 additions & 1 deletion cmd/clusterctl/client/cluster/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package cluster

import (
"sort"

"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/version"
Expand Down Expand Up @@ -344,7 +346,13 @@ func (u *providerUpgrader) doUpgrade(upgradePlan *UpgradePlan) error {
}
}

for _, upgradeItem := range upgradePlan.Providers {
// Ensure Providers are updated in the following order: Core, Bootstrap, ControlPlane, Infrastructure.
providers := upgradePlan.Providers
sort.Slice(providers, func(a, b int) bool {
return providers[a].GetProviderType().Order() < providers[b].GetProviderType().Order()
})

for _, upgradeItem := range providers {
// If there is not a specified next version, skip it (we are already up-to-date).
if upgradeItem.NextVersion == "" {
continue
Expand Down