Skip to content
Permalink
Browse files

*: Bump to install-config v0.12.0

Catching up with openshift/installer@dafc79f (Generate
Network.cluster config instead of NetworkConfig.networkoperator,
2019-01-15, openshift/installer#1013), openshift/installer@3b393da
(pkg/types/aws/machinepool: Drop IAM-role overrides, 2019-01-30,
openshift/installer#1154), and openshift/installer@9ad20c3
(pkg/destroy/aws: Remove ClusterName consumer, 2019-01-31,
openshift/installer#1170).

The uint32 -> int32 cast is slightly dangerous, because it will
silently wrap overflowing values [1,2].  But I'll try and get the
installer updated to use unsigned types as well, and then we won't
have to worry about converting.

[1]: golang/go#19624
[2]: golang/go#30209
  • Loading branch information...
wking committed Feb 14, 2019
1 parent 7fb42d3 commit cfe8fd8276f2f6507863e4762d1da337b160d2d9
@@ -55,10 +55,6 @@ spec:
description: AWS is the configuration used when installing
on AWS.
properties:
iamRoleName:
description: IAMRoleName defines the IAM role associated
with the ec2 instance.
type: string
rootVolume:
description: EC2RootVolume defines the storage for ec2
instance.
@@ -91,7 +87,6 @@ spec:
type: array
required:
- type
- iamRoleName
- rootVolume
type: object
libvirt:
@@ -172,10 +167,6 @@ spec:
description: AWS is the configuration used when installing on
AWS.
properties:
iamRoleName:
description: IAMRoleName defines the IAM role associated
with the ec2 instance.
type: string
rootVolume:
description: EC2RootVolume defines the storage for ec2 instance.
properties:
@@ -207,7 +198,6 @@ spec:
type: array
required:
- type
- iamRoleName
- rootVolume
type: object
libvirt:
@@ -345,10 +335,6 @@ spec:
used when installing on AWS for machine pools which do not
define their own platform configuration.
properties:
iamRoleName:
description: IAMRoleName defines the IAM role associated
with the ec2 instance.
type: string
rootVolume:
description: EC2RootVolume defines the storage for ec2 instance.
properties:
@@ -380,7 +366,6 @@ spec:
type: array
required:
- type
- iamRoleName
- rootVolume
type: object
region:
@@ -22,7 +22,6 @@ spec:
platform:
aws:
type: m4.large
iamRoleName: ""
rootVolume:
iops: 100 # TODO
size: 22
@@ -34,7 +33,6 @@ spec:
platform:
aws:
type: m4.large
iamRoleName: ""
rootVolume:
iops: 100 # TODO
size: 22
@@ -119,7 +119,6 @@ objects:
platform:
aws:
type: m4.large
iamRoleName: ""
rootVolume:
iops: 100 # TODO
size: 22
@@ -130,7 +129,6 @@ objects:
platform:
aws:
type: m4.large
iamRoleName: ""
rootVolume:
iops: 100 # TODO
size: 22
@@ -48,7 +48,6 @@ func NewDeprovisionAWSWithTagsCommand() *cobra.Command {
flags := cmd.Flags()
flags.StringVar(&logLevel, "loglevel", "info", "log level, one of: debug, info, warn, error, fatal, panic")
flags.StringVar(&opt.Region, "region", "us-east-1", "AWS region to use")
flags.StringVar(&opt.ClusterName, "cluster-name", "", "Name that cluster was installed with")
return cmd
}

@@ -328,7 +328,6 @@ func runUninstaller(clusterName, region, clusterID string, logger log.FieldLogge
uninstaller := &aws.ClusterUninstaller{
Filters: filters,
Region: region,
ClusterName: clusterName,
Logger: logger,
}

@@ -36,10 +36,6 @@ type AWSMachinePoolPlatform struct {
// eg. m4-large
InstanceType string `json:"type"`

// IAMRoleName defines the IAM role associated
// with the ec2 instance.
IAMRoleName string `json:"iamRoleName"`

// EC2RootVolume defines the storage for ec2 instance.
EC2RootVolume `json:"rootVolume"`
}
@@ -308,13 +308,6 @@ func (r *ReconcileRemoteMachineSet) generateMachineSetsFromClusterDeployment(cd
workerPool.Platform.AWS.Zones = azs
}

hivePool := findHiveMachinePool(cd, workerPool.Name)

defaultIAMRole := fmt.Sprintf("%s-worker-role", ic.ObjectMeta.Name)
if hivePool.Platform.AWS.IAMRoleName == "" {
workerPool.Platform.AWS.IAMRoleName = defaultIAMRole
}

icMachineSets, err := installaws.MachineSets(cd.Status.ClusterID, ic, &workerPool, defaultAMI, workerPool.Name, "worker-user-data")
if err != nil {
return nil, err
@@ -104,7 +104,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "No-op",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("worker", 3, testName+"-worker", []string{}),
testMachinePool("worker", 3, []string{}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
@@ -130,7 +130,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Update machine set replicas",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("worker", 3, testName+"-worker", []string{}),
testMachinePool("worker", 3, []string{}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
@@ -156,7 +156,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Create missing machine set",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("worker", 3, testName+"-worker", []string{"us-east-1a", "us-east-1b", "us-east-1c"}),
testMachinePool("worker", 3, []string{"us-east-1a", "us-east-1b", "us-east-1c"}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
@@ -181,7 +181,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Delete extra machine set",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("worker", 3, testName+"-worker", []string{}),
testMachinePool("worker", 3, []string{}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
@@ -208,8 +208,8 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Multiple machineset noop",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("alpha", 3, testName+"-worker", []string{"us-east-1a"}),
testMachinePool("beta", 3, testName+"-worker", []string{"us-east-1b"}),
testMachinePool("alpha", 3, []string{"us-east-1a"}),
testMachinePool("beta", 3, []string{"us-east-1b"}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
@@ -233,8 +233,8 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Update multiple machineset replicas",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("alpha", 3, testName+"-worker", []string{"us-east-1a"}),
testMachinePool("beta", 3, testName+"-worker", []string{"us-east-1b"}),
testMachinePool("alpha", 3, []string{"us-east-1a"}),
testMachinePool("beta", 3, []string{"us-east-1b"}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
@@ -258,8 +258,8 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Create additional machinepool machinesets",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("alpha", 3, testName+"-worker", []string{}),
testMachinePool("beta", 3, testName+"-worker", []string{}),
testMachinePool("alpha", 3, []string{}),
testMachinePool("beta", 3, []string{}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
@@ -288,7 +288,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
name: "Delete additional machinepool machinesets",
localExisting: []runtime.Object{
testClusterDeployment([]hivev1.MachinePool{
testMachinePool("alpha", 3, testName+"-worker", []string{}),
testMachinePool("alpha", 3, []string{}),
}),
testSecret(adminKubeconfigSecret, adminKubeconfigSecretKey, testName),
testSecret(adminPasswordSecret, adminPasswordSecretKey, testName),
@@ -391,7 +391,7 @@ func TestRemoteMachineSetReconcile(t *testing.T) {
}
}

func testMachinePool(name string, replicas int, iamRoleName string, zones []string) hivev1.MachinePool {
func testMachinePool(name string, replicas int, zones []string) hivev1.MachinePool {
mpReplicas := int64(replicas)

testMachinePool := hivev1.MachinePool{
@@ -400,7 +400,6 @@ func testMachinePool(name string, replicas int, iamRoleName string, zones []stri
Platform: hivev1.MachinePoolPlatform{
AWS: &hivev1.AWSMachinePoolPlatform{
InstanceType: "m4.large",
IAMRoleName: iamRoleName,
},
},
}
@@ -17,17 +17,14 @@ limitations under the License.
package install

import (
"fmt"

hivev1 "github.com/openshift/hive/pkg/apis/hive/v1alpha1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

networkv1 "github.com/openshift/cluster-network-operator/pkg/apis/networkoperator/v1"
"github.com/openshift/installer/pkg/ipnet"
"github.com/openshift/installer/pkg/types"
installeraws "github.com/openshift/installer/pkg/types/aws"

netopv1 "github.com/openshift/cluster-network-operator/pkg/apis/networkoperator/v1"
)

// GenerateInstallConfig builds an InstallConfig for the installer from our ClusterDeploymentSpec.
@@ -38,11 +35,6 @@ import (
func GenerateInstallConfig(cd *hivev1.ClusterDeployment, sshKey, pullSecret string) (*types.InstallConfig, error) {
spec := cd.Spec

networkType, err := convertNetworkingType(spec.Networking.Type)
if err != nil {
return nil, err
}

platform := types.Platform{}
if spec.Platform.AWS != nil {
aws := spec.Platform.AWS
@@ -53,7 +45,6 @@ func GenerateInstallConfig(cd *hivev1.ClusterDeployment, sshKey, pullSecret stri
if aws.DefaultMachinePlatform != nil {
platform.AWS.DefaultMachinePlatform = &installeraws.MachinePool{
InstanceType: aws.DefaultMachinePlatform.InstanceType,
IAMRoleName: aws.DefaultMachinePlatform.IAMRoleName,
EC2RootVolume: installeraws.EC2RootVolume{
IOPS: aws.DefaultMachinePlatform.EC2RootVolume.IOPS,
Size: aws.DefaultMachinePlatform.EC2RootVolume.Size,
@@ -84,7 +75,6 @@ func GenerateInstallConfig(cd *hivev1.ClusterDeployment, sshKey, pullSecret stri
if mp.Platform.AWS != nil {
newMP.Platform.AWS = &installeraws.MachinePool{
InstanceType: mp.Platform.AWS.InstanceType,
IAMRoleName: mp.Platform.AWS.IAMRoleName,
EC2RootVolume: installeraws.EC2RootVolume{
IOPS: mp.Platform.AWS.EC2RootVolume.IOPS,
Size: mp.Platform.AWS.EC2RootVolume.Size,
@@ -101,14 +91,14 @@ func GenerateInstallConfig(cd *hivev1.ClusterDeployment, sshKey, pullSecret stri
Name: spec.ClusterName,
},
TypeMeta: metav1.TypeMeta{
APIVersion: "v1beta1",
APIVersion: types.InstallConfigVersion,
},
SSHKey: sshKey,
BaseDomain: spec.BaseDomain,
Networking: &types.Networking{
Type: networkType,
Type: string(spec.Networking.Type),
ServiceCIDR: parseCIDR(spec.Networking.ServiceCIDR),
ClusterNetworks: spec.Networking.ClusterNetworks,
ClusterNetworks: convertClusterNetworks(spec.Networking.ClusterNetworks),
MachineCIDR: parseCIDR(spec.Networking.MachineCIDR),
},
PullSecret: pullSecret,
@@ -125,13 +115,13 @@ func parseCIDR(s string) *ipnet.IPNet {
return ipnet.MustParseCIDR(s)
}

func convertNetworkingType(hnt hivev1.NetworkType) (netopv1.NetworkType, error) {
switch hnt {
case hivev1.NetworkTypeOpenshiftOVN:
return netopv1.NetworkTypeOVNKubernetes, nil
case hivev1.NetworkTypeOpenshiftSDN:
return netopv1.NetworkTypeOpenshiftSDN, nil
default:
return "", fmt.Errorf("unknown NetworkType: %s", hnt)
func convertClusterNetworks(networks []networkv1.ClusterNetwork) []types.ClusterNetworkEntry {
output := make([]types.ClusterNetworkEntry, 0, len(networks))
for _, network := range networks {
output = append(output, types.ClusterNetworkEntry{
CIDR: *parseCIDR(network.CIDR),
HostSubnetLength: int32(network.HostSubnetLength),
})
}
return output
}
@@ -48,7 +48,6 @@ const (
pullSecret = "pullSecret"
awsInstanceType = "fake-aws-type"
awsRegion = "us-east-1"
iamRoleName = "rolename"
ec2VolIOPS = 100
ec2VolSize = 500
ec2VolType = "sometype"
@@ -83,7 +82,6 @@ func buildValidClusterDeployment() *hivev1.ClusterDeployment {
},
DefaultMachinePlatform: &hivev1.AWSMachinePoolPlatform{
InstanceType: awsInstanceType,
IAMRoleName: iamRoleName,
EC2RootVolume: hivev1.EC2RootVolume{
IOPS: ec2VolIOPS,
Size: ec2VolSize,
@@ -109,7 +107,6 @@ func buildValidClusterDeployment() *hivev1.ClusterDeployment {
Platform: hivev1.MachinePoolPlatform{
AWS: &hivev1.AWSMachinePoolPlatform{
InstanceType: awsInstanceType,
IAMRoleName: iamRoleName,
EC2RootVolume: hivev1.EC2RootVolume{
IOPS: ec2VolIOPS,
Size: ec2VolSize,
@@ -126,7 +123,6 @@ func buildValidClusterDeployment() *hivev1.ClusterDeployment {
Platform: hivev1.MachinePoolPlatform{
AWS: &hivev1.AWSMachinePoolPlatform{
InstanceType: awsInstanceType,
IAMRoleName: iamRoleName,
EC2RootVolume: hivev1.EC2RootVolume{
IOPS: ec2VolIOPS,
Size: ec2VolSize,
@@ -145,7 +141,7 @@ func buildBaseExpectedInstallConfig() *installtypes.InstallConfig {
replicas := int64(3)
return &installtypes.InstallConfig{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1beta1",
APIVersion: installtypes.InstallConfigVersion,
},
BaseDomain: "test.example.com",
SSHKey: adminSSHKey,
@@ -154,9 +150,9 @@ func buildBaseExpectedInstallConfig() *installtypes.InstallConfig {
// TODO: Hardcoded to match installer for now.
Type: "OpenshiftSDN",
ServiceCIDR: ipnet.MustParseCIDR("172.30.0.0/16"),
ClusterNetworks: []netopv1.ClusterNetwork{
ClusterNetworks: []installtypes.ClusterNetworkEntry{
{
CIDR: "10.128.0.0/14",
CIDR: *ipnet.MustParseCIDR("10.128.0.0/14"),
HostSubnetLength: 9,
},
},
@@ -170,7 +166,6 @@ func buildBaseExpectedInstallConfig() *installtypes.InstallConfig {
},
DefaultMachinePlatform: &installawstypes.MachinePool{
InstanceType: awsInstanceType,
IAMRoleName: iamRoleName,
EC2RootVolume: installawstypes.EC2RootVolume{
IOPS: ec2VolIOPS,
Size: ec2VolSize,
@@ -186,7 +181,6 @@ func buildBaseExpectedInstallConfig() *installtypes.InstallConfig {
Platform: installtypes.MachinePoolPlatform{
AWS: &installawstypes.MachinePool{
InstanceType: awsInstanceType,
IAMRoleName: iamRoleName,
EC2RootVolume: installawstypes.EC2RootVolume{
IOPS: ec2VolIOPS,
Size: ec2VolSize,
@@ -202,7 +196,6 @@ func buildBaseExpectedInstallConfig() *installtypes.InstallConfig {
Platform: installtypes.MachinePoolPlatform{
AWS: &installawstypes.MachinePool{
InstanceType: awsInstanceType,
IAMRoleName: iamRoleName,
EC2RootVolume: installawstypes.EC2RootVolume{
IOPS: ec2VolIOPS,
Size: ec2VolSize,
@@ -264,9 +257,8 @@ func TestConvert(t *testing.T) {
expectedInstallConfig: func() *installtypes.InstallConfig {
ic := buildBaseExpectedInstallConfig()
ic.Networking.ServiceCIDR = &ipnet.IPNet{}
ic.Networking.PodCIDR = nil
ic.Networking.MachineCIDR = &ipnet.IPNet{}
ic.Networking.ClusterNetworks = []netopv1.ClusterNetwork{}
ic.Networking.ClusterNetworks = []installtypes.ClusterNetworkEntry{}
return ic
}(),
},

0 comments on commit cfe8fd8

Please sign in to comment.
You can’t perform that action at this time.