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

[2.8] make out-of-tree helpers public for additional testing during upgrades #143

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
9 changes: 6 additions & 3 deletions extensions/charts/awsoutoftree.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
)

// InstallAWSOutOfTreeChart installs the CSI chart for aws cloud provider in a given cluster.
func InstallAWSOutOfTreeChart(client *rancher.Client, installOptions *InstallOptions, repoName, clusterID string) error {
func InstallAWSOutOfTreeChart(client *rancher.Client, installOptions *InstallOptions, repoName, clusterID string, isLeaderMigration bool) error {
serverSetting, err := client.Management.Setting.ByID(serverURLSettingID)
if err != nil {
return err
Expand All @@ -42,7 +42,7 @@ func InstallAWSOutOfTreeChart(client *rancher.Client, installOptions *InstallOpt
DefaultRegistry: registrySetting.Value,
}

chartInstallAction := awsChartInstallAction(awsChartInstallActionPayload, repoName, kubeSystemNamespace, installOptions.ProjectID)
chartInstallAction := awsChartInstallAction(awsChartInstallActionPayload, repoName, kubeSystemNamespace, installOptions.ProjectID, isLeaderMigration)

catalogClient, err := client.GetClusterCatalogClient(installOptions.ClusterID)
if err != nil {
Expand Down Expand Up @@ -73,7 +73,7 @@ func InstallAWSOutOfTreeChart(client *rancher.Client, installOptions *InstallOpt
}

// awsChartInstallAction is a helper function that returns a chartInstallAction for aws out-of-tree chart.
func awsChartInstallAction(awsChartInstallActionPayload *payloadOpts, repoName, chartNamespace, chartProject string) *types.ChartInstallAction {
func awsChartInstallAction(awsChartInstallActionPayload *payloadOpts, repoName, chartNamespace, chartProject string, isLeaderMigration bool) *types.ChartInstallAction {
chartValues := map[string]interface{}{
"args": []interface{}{
"--use-service-account-credentials=true",
Expand Down Expand Up @@ -217,6 +217,9 @@ func awsChartInstallAction(awsChartInstallActionPayload *payloadOpts, repoName,
},
},
}
if isLeaderMigration {
chartValues["args"] = append(chartValues["args"].([]interface{}), "--enable-leader-migration=true")
}

chartInstall := newChartInstall(
awsChartInstallActionPayload.Name,
Expand Down
5 changes: 5 additions & 0 deletions extensions/charts/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package charts

import (
"context"
"errors"

v1 "github.com/rancher/rancher/pkg/apis/catalog.cattle.io/v1"
"github.com/rancher/shepherd/clients/rancher/catalog"
Expand All @@ -28,6 +29,10 @@ func VerifyChartInstall(client *catalog.Client, chartNamespace, chartName string
if state == string(v1.StatusDeployed) {
return true, nil
}

if state == string(v1.StatusFailed) {
return false, errors.New("chart install has failed")
}
return false, nil
})
return err
Expand Down
24 changes: 20 additions & 4 deletions extensions/clusters/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ func NewK3SRKE2ClusterConfig(clusterName, namespace string, clustersConfig *Clus
}

if clustersConfig.CloudProvider == provisioninginput.AWSProviderName.String() {
machineSelectorConfigs = append(machineSelectorConfigs, awsOutOfTreeSystemConfig()...)
machineSelectorConfigs = append(machineSelectorConfigs, OutOfTreeSystemConfig(clustersConfig.CloudProvider)...)
} else if strings.Contains(clustersConfig.CloudProvider, "-in-tree") {
machineSelectorConfigs = append(machineSelectorConfigs, InTreeSystemConfig(strings.Split(clustersConfig.CloudProvider, "-in-tree")[0])...)
}

rkeSpecCommon := rkev1.RKEClusterSpecCommon{
Expand Down Expand Up @@ -460,9 +462,9 @@ func NewK3SRKE2ClusterConfig(clusterName, namespace string, clustersConfig *Clus
return v1Cluster
}

// awsOutOfTreeSystemConfig constructs the proper rkeSystemConfig slice for enabling the aws cloud provider
// OutOfTreeSystemConfig constructs the proper rkeSystemConfig slice for enabling the aws cloud provider
// out-of-tree services
func awsOutOfTreeSystemConfig() (rkeConfig []rkev1.RKESystemConfig) {
func OutOfTreeSystemConfig(providerName string) (rkeConfig []rkev1.RKESystemConfig) {
roles := []string{etcdRole, controlPlaneRole, workerRole}

for _, role := range roles {
Expand All @@ -488,14 +490,28 @@ func awsOutOfTreeSystemConfig() (rkeConfig []rkev1.RKESystemConfig) {
}

configData := map[string]interface{}{
cloudProviderAnnotationName: provisioninginput.AWSProviderName,
cloudProviderAnnotationName: providerName,
protectKernelDefaults: false,
}

rkeConfig = append(rkeConfig, RKESystemConfigTemplate(configData, nil))
return
}

// InTreeSystemConfig constructs the proper rkeSystemConfig slice for enabling cloud provider
// in-tree services.
// Vsphere deprecated 1.21+
// AWS deprecated 1.27+
// Azure deprecated 1.28+
func InTreeSystemConfig(providerName string) (rkeConfig []rkev1.RKESystemConfig) {
configData := map[string]interface{}{
cloudProviderAnnotationName: providerName,
protectKernelDefaults: false,
}
rkeConfig = append(rkeConfig, RKESystemConfigTemplate(configData, nil))
return
}

// RKESYstemConfigTemplate constructs an RKESystemConfig object given config data and a selector
func RKESystemConfigTemplate(config map[string]interface{}, selector *metav1.LabelSelector) rkev1.RKESystemConfig {
return rkev1.RKESystemConfig{
Expand Down
2 changes: 1 addition & 1 deletion extensions/kubectl/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
JobName = "kubectl"
)

var importTimeout = int64(60 * 1)
var importTimeout = int64(60 * 2)

// CreateJobAndRunKubectlCommands is a helper to create a job and run the kubectl commands in the pods of the Job.
// It then returns errors or nil from the job.
Expand Down