Skip to content

Commit 33c3b0c

Browse files
committed
rke2 package updates
update update Add more tests Update custom and parallelism update custom cluster agent/ace tests fixes
1 parent 42c7bc5 commit 33c3b0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1531
-957
lines changed

actions/nodes/ec2/ec2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
)
2727

2828
// CreateNodes creates `quantityPerPool[n]` number of ec2 instances
29-
func CreateNodes(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32) (ec2Nodes []*nodes.Node, err error) {
29+
func CreateNodes(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32, ec2Configs *rancherEc2.AWSEC2Configs) (ec2Nodes []*nodes.Node, err error) {
3030
ec2Client, err := client.GetEC2Client()
3131
if err != nil {
3232
return nil, err
@@ -36,7 +36,7 @@ func CreateNodes(client *rancher.Client, rolesPerPool []string, quantityPerPool
3636
reservationConfigs := []*rancherEc2.AWSEC2Config{}
3737
// provisioning instances in reverse order to allow windows instances time to become ready
3838
for i := len(quantityPerPool) - 1; i >= 0; i-- {
39-
config := MatchRoleToConfig(rolesPerPool[i], ec2Client.ClientConfig.AWSEC2Config)
39+
config := MatchRoleToConfig(rolesPerPool[i], ec2Configs.AWSEC2Config)
4040
if config == nil {
4141
return nil, errors.New("No matching nodesAndRole for AWSEC2Config with role:" + rolesPerPool[i])
4242
}

actions/provisioning/creates.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/sirupsen/logrus"
1212

1313
"github.com/rancher/shepherd/clients/corral"
14+
"github.com/rancher/shepherd/clients/ec2"
1415
"github.com/rancher/shepherd/clients/rancher"
1516

1617
apiv1 "github.com/rancher/rancher/pkg/apis/provisioning.cattle.io/v1"
@@ -184,7 +185,7 @@ func CreateProvisioningCluster(client *rancher.Client, provider Provider, creden
184185
}
185186

186187
// CreateProvisioningCustomCluster provisions a non-rke1 cluster using a 3rd party client for its nodes, then runs verify checks
187-
func CreateProvisioningCustomCluster(client *rancher.Client, externalNodeProvider *ExternalNodeProvider, clustersConfig *clusters.ClusterConfig) (*v1.SteveAPIObject, error) {
188+
func CreateProvisioningCustomCluster(client *rancher.Client, externalNodeProvider *ExternalNodeProvider, clustersConfig *clusters.ClusterConfig, ec2Configs *ec2.AWSEC2Configs) (*v1.SteveAPIObject, error) {
188189
setLogrusFormatter()
189190
rolesPerNode := []string{}
190191
quantityPerPool := []int32{}
@@ -221,7 +222,7 @@ func CreateProvisioningCustomCluster(client *rancher.Client, externalNodeProvide
221222
}
222223
}
223224

224-
nodes, err := externalNodeProvider.NodeCreationFunc(client, rolesPerPool, quantityPerPool)
225+
nodes, err := externalNodeProvider.NodeCreationFunc(client, rolesPerPool, quantityPerPool, ec2Configs)
225226
if err != nil {
226227
return nil, err
227228
}
@@ -429,7 +430,7 @@ func CreateProvisioningRKE1CustomCluster(client *rancher.Client, externalNodePro
429430
}
430431
}
431432

432-
nodes, err := externalNodeProvider.NodeCreationFunc(client, rolesPerPool, quantityPerPool)
433+
nodes, err := externalNodeProvider.NodeCreationFunc(client, rolesPerPool, quantityPerPool, nil)
433434
if err != nil {
434435
return nil, nil, err
435436
}

actions/provisioning/nodeproviders.go

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@ const (
1717
fromConfig = "config"
1818
)
1919

20-
type NodeCreationFunc func(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32) (nodes []*nodes.Node, err error)
20+
type NodeCreationFunc func(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32, ec2Configs *rancherEc2.AWSEC2Configs) (nodes []*nodes.Node, err error)
2121
type NodeDeletionFunc func(client *rancher.Client, nodes []*nodes.Node) error
2222
type CustomOSNamesFunc func(client *rancher.Client, customConfig rancherEc2.AWSEC2Configs) ([]string, error)
23+
type GetCustomWindowsPools func(client *rancher.Client, customConfig rancherEc2.AWSEC2Configs) []rancherEc2.AWSEC2Config
2324

2425
type ExternalNodeProvider struct {
25-
Name string
26-
NodeCreationFunc NodeCreationFunc
27-
NodeDeletionFunc NodeDeletionFunc
28-
GetOSNamesFunc CustomOSNamesFunc
26+
Name string
27+
NodeCreationFunc NodeCreationFunc
28+
NodeDeletionFunc NodeDeletionFunc
29+
GetOSNamesFunc CustomOSNamesFunc
30+
GetWindowsPoolsFunc GetCustomWindowsPools
2931
}
3032

3133
// ExternalNodeProviderSetup is a helper function that setups an ExternalNodeProvider object is a wrapper
@@ -34,15 +36,16 @@ func ExternalNodeProviderSetup(providerType string) ExternalNodeProvider {
3436
switch providerType {
3537
case ec2NodeProviderName:
3638
return ExternalNodeProvider{
37-
Name: providerType,
38-
NodeCreationFunc: ec2.CreateNodes,
39-
NodeDeletionFunc: ec2.DeleteNodes,
40-
GetOSNamesFunc: GetAWSOSNames,
39+
Name: providerType,
40+
NodeCreationFunc: ec2.CreateNodes,
41+
NodeDeletionFunc: ec2.DeleteNodes,
42+
GetOSNamesFunc: GetAWSOSNames,
43+
GetWindowsPoolsFunc: GetWindowsPools,
4144
}
4245
case fromConfig:
4346
return ExternalNodeProvider{
4447
Name: providerType,
45-
NodeCreationFunc: func(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32) (nodesList []*nodes.Node, err error) {
48+
NodeCreationFunc: func(client *rancher.Client, rolesPerPool []string, quantityPerPool []int32, ec2Configs *rancherEc2.AWSEC2Configs) (nodesList []*nodes.Node, err error) {
4649
var nodeConfig nodes.ExternalNodeConfig
4750
config.LoadConfig(nodes.ExternalNodeConfigConfigurationFileKey, &nodeConfig)
4851

@@ -91,3 +94,15 @@ func GetAWSOSNames(client *rancher.Client, customConfig rancherEc2.AWSEC2Configs
9194

9295
return osNames, nil
9396
}
97+
98+
// GetWindowsPools gets a list of the windows machine configs
99+
func GetWindowsPools(client *rancher.Client, customConfig rancherEc2.AWSEC2Configs) []rancherEc2.AWSEC2Config {
100+
var windowsConfigs []rancherEc2.AWSEC2Config
101+
for _, machineConfig := range customConfig.AWSEC2Config {
102+
if slices.Contains(machineConfig.Roles, "windows") {
103+
windowsConfigs = append(windowsConfigs, machineConfig)
104+
}
105+
}
106+
107+
return windowsConfigs
108+
}

actions/provisioning/permutations/permutations.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import (
44
"strings"
55

66
"github.com/rancher/shepherd/clients/corral"
7+
"github.com/rancher/shepherd/clients/ec2"
78
"github.com/rancher/shepherd/clients/rancher"
89
management "github.com/rancher/shepherd/clients/rancher/generated/management/v3"
910
steveV1 "github.com/rancher/shepherd/clients/rancher/v1"
1011
"github.com/rancher/shepherd/extensions/cloudcredentials"
12+
"github.com/rancher/shepherd/pkg/config"
1113
"github.com/rancher/shepherd/pkg/session"
1214
"github.com/rancher/tests/actions/cloudprovider"
1315
"github.com/rancher/tests/actions/clusters"
@@ -103,7 +105,10 @@ func RunTestPermutations(s *suite.Suite, testNamePrefix string, client *rancher.
103105
case RKE2CustomCluster, K3SCustomCluster:
104106
testClusterConfig.KubernetesVersion = kubeVersion
105107

106-
clusterObject, err = provisioning.CreateProvisioningCustomCluster(client, customProvider, testClusterConfig)
108+
awsEC2Configs := new(ec2.AWSEC2Configs)
109+
config.LoadConfig(ec2.ConfigurationFileKey, awsEC2Configs)
110+
111+
clusterObject, err = provisioning.CreateProvisioningCustomCluster(client, customProvider, testClusterConfig, awsEC2Configs)
107112
reports.TimeoutClusterReport(clusterObject, err)
108113
require.NoError(s.T(), err)
109114

validation/certificates/rke2k3s/cert_rotation_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"testing"
88

9+
"github.com/rancher/shepherd/clients/ec2"
910
"github.com/rancher/shepherd/clients/rancher"
1011
extClusters "github.com/rancher/shepherd/extensions/clusters"
1112
"github.com/rancher/shepherd/extensions/defaults/stevetypes"
@@ -55,6 +56,9 @@ func (c *CertRotationTestSuite) SetupSuite() {
5556
k3sClusterConfig := new(clusters.ClusterConfig)
5657
operations.LoadObjectFromMap(defaults.ClusterConfigKey, c.cattleConfig, k3sClusterConfig)
5758

59+
awsEC2Configs := new(ec2.AWSEC2Configs)
60+
operations.LoadObjectFromMap(ec2.ConfigurationFileKey, c.cattleConfig, awsEC2Configs)
61+
5862
nodeRolesStandard := []provisioninginput.MachinePools{
5963
provisioninginput.EtcdMachinePool,
6064
provisioninginput.ControlPlaneMachinePool,
@@ -68,10 +72,10 @@ func (c *CertRotationTestSuite) SetupSuite() {
6872
rke2ClusterConfig.MachinePools = nodeRolesStandard
6973
k3sClusterConfig.MachinePools = nodeRolesStandard
7074

71-
c.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, true, false)
75+
c.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, awsEC2Configs, true, false)
7276
require.NoError(c.T(), err)
7377

74-
c.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, true, false)
78+
c.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, awsEC2Configs, true, false)
7579
require.NoError(c.T(), err)
7680

7781
}

validation/certificates/rke2k3s/cert_rotation_wins_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"testing"
88

9+
"github.com/rancher/shepherd/clients/ec2"
910
"github.com/rancher/shepherd/clients/rancher"
1011
extClusters "github.com/rancher/shepherd/extensions/clusters"
1112
"github.com/rancher/shepherd/extensions/defaults/stevetypes"
@@ -51,6 +52,9 @@ func (c *CertRotationWindowsTestSuite) SetupSuite() {
5152
clusterConfig := new(clusters.ClusterConfig)
5253
operations.LoadObjectFromMap(defaults.ClusterConfigKey, c.cattleConfig, clusterConfig)
5354

55+
awsEC2Configs := new(ec2.AWSEC2Configs)
56+
operations.LoadObjectFromMap(ec2.ConfigurationFileKey, c.cattleConfig, awsEC2Configs)
57+
5458
if clusterConfig.Provider != "vsphere" {
5559
c.T().Skip("Test requires vSphere provider")
5660
}
@@ -69,7 +73,7 @@ func (c *CertRotationWindowsTestSuite) SetupSuite() {
6973

7074
clusterConfig.MachinePools = nodeRolesStandard
7175

72-
c.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.RKE2ClusterType.String(), clusterConfig, true, false)
76+
c.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(c.T(), standardUserClient, extClusters.RKE2ClusterType.String(), clusterConfig, awsEC2Configs, true, false)
7377
require.NoError(c.T(), err)
7478
}
7579

validation/charts/backup_restore/backup_restore.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/rancher/tests/actions/provisioning"
2121
"github.com/rancher/tests/actions/provisioninginput"
2222

23+
"github.com/rancher/shepherd/clients/ec2"
2324
"github.com/rancher/shepherd/clients/rancher"
2425
shepCharts "github.com/rancher/shepherd/extensions/charts"
2526
"github.com/rancher/shepherd/extensions/users"
@@ -297,7 +298,10 @@ func createRKE2dsCluster(t *testing.T, client *rancher.Client) (*v1.SteveAPIObje
297298
}
298299
testClusterConfig.MachinePools = nodeAndRoles
299300
testClusterConfig.KubernetesVersion = provisioningConfig.RKE2KubernetesVersions[0]
300-
steveObject, err := provisioning.CreateProvisioningCustomCluster(client, &externalNodeProvider, testClusterConfig)
301+
302+
awsEC2Configs := new(ec2.AWSEC2Configs)
303+
config.LoadConfig(ec2.ConfigurationFileKey, awsEC2Configs)
304+
steveObject, err := provisioning.CreateProvisioningCustomCluster(client, &externalNodeProvider, testClusterConfig, awsEC2Configs)
301305

302306
if err != nil {
303307
return nil, nil, err

validation/deleting/rke2k3s/delete_cluster_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"testing"
88

9+
"github.com/rancher/shepherd/clients/ec2"
910
"github.com/rancher/shepherd/clients/rancher"
1011
extClusters "github.com/rancher/shepherd/extensions/clusters"
1112
"github.com/rancher/shepherd/pkg/config"
@@ -54,6 +55,9 @@ func (d *DeleteClusterTestSuite) SetupSuite() {
5455
k3sClusterConfig := new(clusters.ClusterConfig)
5556
operations.LoadObjectFromMap(defaults.ClusterConfigKey, d.cattleConfig, k3sClusterConfig)
5657

58+
awsEC2Configs := new(ec2.AWSEC2Configs)
59+
operations.LoadObjectFromMap(ec2.ConfigurationFileKey, d.cattleConfig, awsEC2Configs)
60+
5761
nodeRolesStandard := []provisioninginput.MachinePools{
5862
provisioninginput.EtcdMachinePool,
5963
provisioninginput.ControlPlaneMachinePool,
@@ -67,10 +71,10 @@ func (d *DeleteClusterTestSuite) SetupSuite() {
6771
rke2ClusterConfig.MachinePools = nodeRolesStandard
6872
k3sClusterConfig.MachinePools = nodeRolesStandard
6973

70-
d.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, true, false)
74+
d.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, awsEC2Configs, true, false)
7175
require.NoError(d.T(), err)
7276

73-
d.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, true, false)
77+
d.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, awsEC2Configs, true, false)
7478
require.NoError(d.T(), err)
7579
}
7680

validation/deleting/rke2k3s/delete_init_machine_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"testing"
88

9+
"github.com/rancher/shepherd/clients/ec2"
910
"github.com/rancher/shepherd/clients/rancher"
1011
extClusters "github.com/rancher/shepherd/extensions/clusters"
1112
"github.com/rancher/shepherd/pkg/config"
@@ -53,6 +54,9 @@ func (d *DeleteInitMachineTestSuite) SetupSuite() {
5354
k3sClusterConfig := new(clusters.ClusterConfig)
5455
operations.LoadObjectFromMap(defaults.ClusterConfigKey, d.cattleConfig, k3sClusterConfig)
5556

57+
awsEC2Configs := new(ec2.AWSEC2Configs)
58+
operations.LoadObjectFromMap(ec2.ConfigurationFileKey, d.cattleConfig, awsEC2Configs)
59+
5660
nodeRolesStandard := []provisioninginput.MachinePools{
5761
provisioninginput.EtcdMachinePool,
5862
provisioninginput.ControlPlaneMachinePool,
@@ -66,10 +70,10 @@ func (d *DeleteInitMachineTestSuite) SetupSuite() {
6670
rke2ClusterConfig.MachinePools = nodeRolesStandard
6771
k3sClusterConfig.MachinePools = nodeRolesStandard
6872

69-
d.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, true, false)
73+
d.rke2ClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.RKE2ClusterType.String(), rke2ClusterConfig, awsEC2Configs, true, false)
7074
require.NoError(d.T(), err)
7175

72-
d.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, true, false)
76+
d.k3sClusterID, err = resources.ProvisionRKE2K3SCluster(d.T(), standardUserClient, extClusters.K3SClusterType.String(), k3sClusterConfig, awsEC2Configs, true, false)
7377
require.NoError(d.T(), err)
7478
}
7579

validation/fleet/provisioning/new_cluster_existing_gitrepo_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
99
provv1 "github.com/rancher/rancher/pkg/apis/provisioning.cattle.io/v1"
10+
"github.com/rancher/shepherd/clients/ec2"
1011
"github.com/rancher/shepherd/clients/rancher"
1112
management "github.com/rancher/shepherd/clients/rancher/generated/management/v3"
1213
steveV1 "github.com/rancher/shepherd/clients/rancher/v1"
@@ -171,7 +172,10 @@ func (f *FleetWithProvisioningTestSuite) TestHardenedAfterAddedGitRepo() {
171172
testClusterConfig.CNI = f.provisioningConfig.CNIs[0]
172173
testClusterConfig.EnableNetworkPolicy = true
173174

174-
clusterObject, err := provisioning.CreateProvisioningCustomCluster(tt.client, customProvider, testClusterConfig)
175+
awsEC2Configs := new(ec2.AWSEC2Configs)
176+
config.LoadConfig(ec2.ConfigurationFileKey, awsEC2Configs)
177+
178+
clusterObject, err := provisioning.CreateProvisioningCustomCluster(tt.client, customProvider, testClusterConfig, awsEC2Configs)
175179
require.NoError(f.T(), err)
176180

177181
reports.TimeoutClusterReport(clusterObject, err)
@@ -255,7 +259,10 @@ func (f *FleetWithProvisioningTestSuite) TestWindowsAfterAddedGitRepo() {
255259
testClusterConfig.CNI = f.provisioningConfig.CNIs[0]
256260
testClusterConfig.EnableNetworkPolicy = true
257261

258-
clusterObject, err := provisioning.CreateProvisioningCustomCluster(tt.client, customProvider, testClusterConfig)
262+
awsEC2Configs := new(ec2.AWSEC2Configs)
263+
config.LoadConfig(ec2.ConfigurationFileKey, awsEC2Configs)
264+
265+
clusterObject, err := provisioning.CreateProvisioningCustomCluster(tt.client, customProvider, testClusterConfig, awsEC2Configs)
259266
require.NoError(f.T(), err)
260267

261268
reports.TimeoutClusterReport(clusterObject, err)

0 commit comments

Comments
 (0)