diff --git a/data/data/install.openshift.io_installconfigs.yaml b/data/data/install.openshift.io_installconfigs.yaml index 6e32a346b1a..6120e22021b 100644 --- a/data/data/install.openshift.io_installconfigs.yaml +++ b/data/data/install.openshift.io_installconfigs.yaml @@ -1810,22 +1810,6 @@ spec: cluster. If empty, a new resource group will be created for the cluster." type: string - subnets: - description: Subnets is a list of existing subnet IDs. Leave unset - and the installer will create new subnets in the VPC network - on your behalf. - items: - type: string - type: array - vpc: - description: VPC is the ID of an existing VPC network. Leave unset - and the installer will create a new VPC network on your behalf. - type: string - vpcResourceGroupName: - description: VPCResourceGroupName specifies the resource group - containing an existing VPC. This must be defined if `VPC` is - defined. - type: string required: - region type: object diff --git a/pkg/asset/cluster/ibmcloud/ibmcloud.go b/pkg/asset/cluster/ibmcloud/ibmcloud.go index cd836159a10..c47da384cde 100644 --- a/pkg/asset/cluster/ibmcloud/ibmcloud.go +++ b/pkg/asset/cluster/ibmcloud/ibmcloud.go @@ -20,7 +20,5 @@ func Metadata(infraID string, config *types.InstallConfig, meta *icibmcloud.Meta CISInstanceCRN: cisCrn, Region: config.Platform.IBMCloud.Region, ResourceGroupName: config.Platform.IBMCloud.ClusterResourceGroupName(infraID), - Subnets: config.Platform.IBMCloud.Subnets, - VPC: config.Platform.IBMCloud.VPC, } } diff --git a/pkg/asset/installconfig/ibmcloud/validation.go b/pkg/asset/installconfig/ibmcloud/validation.go index d076cf636df..e62410ec592 100644 --- a/pkg/asset/installconfig/ibmcloud/validation.go +++ b/pkg/asset/installconfig/ibmcloud/validation.go @@ -42,10 +42,6 @@ func validatePlatform(client API, ic *types.InstallConfig, path *field.Path) fie allErrs = append(allErrs, validateResourceGroup(client, ic, path)...) } - if ic.Platform.IBMCloud.VPC != "" { - allErrs = append(allErrs, validateNetworking(client, ic, path)...) - } - if ic.Platform.IBMCloud.DefaultMachinePlatform != nil { allErrs = append(allErrs, validateMachinePool(client, ic.IBMCloud, ic.Platform.IBMCloud.DefaultMachinePlatform, path)...) } @@ -222,40 +218,6 @@ func validateResourceGroup(client API, ic *types.InstallConfig, path *field.Path return allErrs } -func validateNetworking(client API, ic *types.InstallConfig, path *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - platform := ic.Platform.IBMCloud - - _, err := client.GetVPC(context.TODO(), platform.VPC) - if err != nil { - if errors.Is(err, &VPCResourceNotFoundError{}) { - allErrs = append(allErrs, field.NotFound(path.Child("vpc"), platform.VPC)) - } else { - allErrs = append(allErrs, field.InternalError(path.Child("vpc"), err)) - } - } - - allErrs = append(allErrs, validateSubnets(client, ic, platform.Subnets, path)...) - - return allErrs -} - -func validateSubnets(client API, ic *types.InstallConfig, subnets []string, path *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - zones, err := client.GetVPCZonesForRegion(context.TODO(), ic.Platform.IBMCloud.Region) - if err != nil { - allErrs = append(allErrs, field.InternalError(path.Child("subnets"), err)) - } - validZones := sets.NewString(zones...) - for idx, subnet := range subnets { - subnetPath := path.Child("subnets").Index(idx) - allErrs = append(allErrs, validateSubnetZone(client, subnet, validZones, subnetPath)...) - } - - // TODO: IBM[#80]: additional subnet validation - return allErrs -} - func validateSubnetZone(client API, subnetID string, validZones sets.String, subnetPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} if subnet, err := client.GetSubnet(context.TODO(), subnetID); err == nil { diff --git a/pkg/asset/installconfig/ibmcloud/validation_test.go b/pkg/asset/installconfig/ibmcloud/validation_test.go index a6125c8c1c8..cb9597903d2 100644 --- a/pkg/asset/installconfig/ibmcloud/validation_test.go +++ b/pkg/asset/installconfig/ibmcloud/validation_test.go @@ -27,7 +27,6 @@ var ( validClusterName = "valid-cluster-name" validDNSZoneID = "valid-zone-id" validBaseDomain = "valid.base.domain" - validVPC = "valid-vpc" validPublicSubnetUSSouth1ID = "public-subnet-us-south-1-id" validPublicSubnetUSSouth2ID = "public-subnet-us-south-2-id" validPrivateSubnetUSSouth1ID = "private-subnet-us-south-1-id" @@ -42,13 +41,6 @@ var ( validInstanceProfies = []vpcv1.InstanceProfile{{Name: &[]string{"type-a"}[0]}, {Name: &[]string{"type-b"}[0]}} - validVPCConfig = func(ic *types.InstallConfig) { - ic.IBMCloud.VPC = validVPC - ic.IBMCloud.Subnets = validSubnets - } - notFoundVPC = func(ic *types.InstallConfig) { ic.IBMCloud.VPC = "not-found" } - internalErrorVPC = func(ic *types.InstallConfig) { ic.IBMCloud.VPC = "internal-error-vpc" } - subnetInvalidZone = func(ic *types.InstallConfig) { ic.IBMCloud.Subnets = []string{"subnet-invalid-zone"} } machinePoolInvalidType = func(ic *types.InstallConfig) { ic.ControlPlane.Platform.IBMCloud = &ibmcloudtypes.MachinePool{ InstanceType: "invalid-type", @@ -115,36 +107,6 @@ func TestValidate(t *testing.T) { edits: editFunctions{}, errorMsg: "", }, - { - name: "valid vpc config", - edits: editFunctions{validVPCConfig}, - errorMsg: "", - }, - { - name: "not found vpc", - edits: editFunctions{validVPCConfig, notFoundVPC}, - errorMsg: `^platform\.ibmcloud\.vpc: Not found: \"not-found\"$`, - }, - { - name: "internal error vpc", - edits: editFunctions{validVPCConfig, internalErrorVPC}, - errorMsg: `^platform\.ibmcloud\.vpc: Internal error$`, - }, - { - name: "subnet invalid zone", - edits: editFunctions{validVPCConfig, subnetInvalidZone}, - errorMsg: `^\Qplatform.ibmcloud.subnets[0]: Invalid value: "subnet-invalid-zone": subnet is not in expected zones: [us-south-1 us-south-2 us-south-3]\E$`, - }, - { - name: "machine pool invalid type", - edits: editFunctions{validVPCConfig, machinePoolInvalidType}, - errorMsg: `^\QcontrolPlane.platform.ibmcloud.type: Not found: "invalid-type"\E$`, - }, - { - name: "machine pool invalid type", - edits: editFunctions{validVPCConfig, machinePoolInvalidType}, - errorMsg: `^\QcontrolPlane.platform.ibmcloud.type: Not found: "invalid-type"\E$`, - }, } mockCtrl := gomock.NewController(t) @@ -152,10 +114,6 @@ func TestValidate(t *testing.T) { ibmcloudClient := mock.NewMockAPI(mockCtrl) - ibmcloudClient.EXPECT().GetVPC(gomock.Any(), validVPC).Return(&vpcv1.VPC{}, nil).AnyTimes() - ibmcloudClient.EXPECT().GetVPC(gomock.Any(), "not-found").Return(nil, &ibmcloud.VPCResourceNotFoundError{}) - ibmcloudClient.EXPECT().GetVPC(gomock.Any(), "internal-error-vpc").Return(nil, fmt.Errorf("")) - ibmcloudClient.EXPECT().GetSubnet(gomock.Any(), validPublicSubnetUSSouth1ID).Return(&vpcv1.Subnet{Zone: &vpcv1.ZoneReference{Name: &validZoneUSSouth1}}, nil).AnyTimes() ibmcloudClient.EXPECT().GetSubnet(gomock.Any(), validPublicSubnetUSSouth2ID).Return(&vpcv1.Subnet{Zone: &vpcv1.ZoneReference{Name: &validZoneUSSouth1}}, nil).AnyTimes() ibmcloudClient.EXPECT().GetSubnet(gomock.Any(), validPrivateSubnetUSSouth1ID).Return(&vpcv1.Subnet{Zone: &vpcv1.ZoneReference{Name: &validZoneUSSouth1}}, nil).AnyTimes() diff --git a/pkg/asset/machines/ibmcloud/machines.go b/pkg/asset/machines/ibmcloud/machines.go index 02a2c209c7c..d73358ad8dd 100644 --- a/pkg/asset/machines/ibmcloud/machines.go +++ b/pkg/asset/machines/ibmcloud/machines.go @@ -74,12 +74,7 @@ func provider(clusterID string, ) (*ibmcloudprovider.IBMCloudMachineProviderSpec, error) { az := mpool.Zones[azIdx] - var vpc string - if platform.VPC != "" { - vpc = platform.VPC - } else { - vpc = fmt.Sprintf("%s-vpc", clusterID) - } + var vpc = fmt.Sprintf("%s-vpc", clusterID) var resourceGroup string if platform.ResourceGroupName != "" { diff --git a/pkg/types/ibmcloud/platform.go b/pkg/types/ibmcloud/platform.go index 33de12af7a4..16524e8fff6 100644 --- a/pkg/types/ibmcloud/platform.go +++ b/pkg/types/ibmcloud/platform.go @@ -18,25 +18,11 @@ type Platform struct { // +optional ResourceGroupName string `json:"resourceGroupName,omitempty"` - // VPCResourceGroupName specifies the resource group containing an existing - // VPC. This must be defined if `VPC` is defined. - // +optional - VPCResourceGroupName string `json:"vpcResourceGroupName,omitempty"` - // DefaultMachinePlatform is the default configuration used when installing // on IBM Cloud for machine pools which do not define their own platform // configuration. // +optional DefaultMachinePlatform *MachinePool `json:"defaultMachinePlatform,omitempty"` - - // VPC is the ID of an existing VPC network. Leave unset and the installer - // will create a new VPC network on your behalf. - VPC string `json:"vpc,omitempty"` - - // Subnets is a list of existing subnet IDs. Leave unset and the installer - // will create new subnets in the VPC network on your behalf. - // +optional - Subnets []string `json:"subnets,omitempty"` } // ClusterResourceGroupName returns the name of the resource group for the cluster. diff --git a/pkg/types/ibmcloud/validation/platform.go b/pkg/types/ibmcloud/validation/platform.go index 7b18d8bd858..5dcb80577fc 100644 --- a/pkg/types/ibmcloud/validation/platform.go +++ b/pkg/types/ibmcloud/validation/platform.go @@ -42,26 +42,8 @@ func ValidatePlatform(p *ibmcloud.Platform, fldPath *field.Path) field.ErrorList allErrs = append(allErrs, field.NotSupported(fldPath.Child("region"), p.Region, regionShortNames)) } - allErrs = append(allErrs, validateVPCConfig(p, fldPath)...) - if p.DefaultMachinePlatform != nil { allErrs = append(allErrs, ValidateMachinePool(p, p.DefaultMachinePlatform, fldPath.Child("defaultMachinePlatform"))...) } return allErrs } - -func validateVPCConfig(p *ibmcloud.Platform, path *field.Path) field.ErrorList { - allErrs := field.ErrorList{} - if p.VPC != "" || len(p.Subnets) > 0 || p.VPCResourceGroupName != "" { - if p.VPC == "" { - allErrs = append(allErrs, field.Required(path.Child("vpc"), "vpc is required when specifying subnets or vpcResourceGroupName")) - } - if len(p.Subnets) == 0 { - allErrs = append(allErrs, field.Required(path.Child("subnets"), "subnets is required when specifying vpc or vpcResourceGroupName")) - } - if p.VPCResourceGroupName == "" { - allErrs = append(allErrs, field.Required(path.Child("vpcResourceGroupName"), "vpcResourceGroupName is required when specifying vpc or subnets")) - } - } - return allErrs -} diff --git a/pkg/types/ibmcloud/validation/platform_test.go b/pkg/types/ibmcloud/validation/platform_test.go index a14cb3bb5cf..ee5dc0ff101 100644 --- a/pkg/types/ibmcloud/validation/platform_test.go +++ b/pkg/types/ibmcloud/validation/platform_test.go @@ -61,93 +61,6 @@ func TestValidatePlatform(t *testing.T) { }(), valid: true, }, - { - name: "valid vpc config", - platform: func() *ibmcloud.Platform { - p := validMinimalPlatform() - p.VPC = "valid-vpc-name" - p.Subnets = []string{"valid-compute-subnet-id", "valid-control-subnet-id"} - p.VPCResourceGroupName = "vpc-rg-name" - return p - }(), - valid: true, - }, - { - name: "invalid vpc config missing vpc", - platform: func() *ibmcloud.Platform { - p := validMinimalPlatform() - p.Subnets = []string{"valid-compute-subnet-id", "valid-control-subnet-id"} - p.VPCResourceGroupName = "vpc-rg-name" - return p - }(), - valid: false, - }, - { - name: "invalid vpc config missing subnets", - platform: func() *ibmcloud.Platform { - p := validMinimalPlatform() - p.VPC = "valid-vpc-name" - p.VPCResourceGroupName = "vpc-rg-name" - return p - }(), - valid: false, - }, - { - name: "invalid vpc config missing vpcResourceGroupNname", - platform: func() *ibmcloud.Platform { - p := validMinimalPlatform() - p.VPC = "valid-vpc-name" - p.Subnets = []string{"valid-compute-subnet-id", "valid-control-subnet-id"} - return p - }(), - valid: false, - }, - { - name: "invalid vpc config missing vpc and subnets", - platform: func() *ibmcloud.Platform { - p := validMinimalPlatform() - p.VPCResourceGroupName = "vpc-rg-name" - return p - }(), - valid: false, - }, - { - name: "invalid vpc config missing vpcResourceGroupName", - platform: func() *ibmcloud.Platform { - p := validMinimalPlatform() - p.VPC = "valid-vpc-name" - p.Subnets = []string{"valid-compute-subnet-id", "valid-control-subnet-id"} - return p - }(), - valid: false, - }, - { - name: "invalid vpc config missing vpc and subnets", - platform: func() *ibmcloud.Platform { - p := validMinimalPlatform() - p.VPCResourceGroupName = "vpc-rg-name" - return p - }(), - valid: false, - }, - { - name: "invalid vpc config missing vpc and vpcResourceGroupName", - platform: func() *ibmcloud.Platform { - p := validMinimalPlatform() - p.Subnets = []string{"valid-compute-subnet-id", "valid-control-subnet-id"} - return p - }(), - valid: false, - }, - { - name: "invalid vpc config missing subnets and vpcResourceGroupName", - platform: func() *ibmcloud.Platform { - p := validMinimalPlatform() - p.VPC = "valid-vpc-name" - return p - }(), - valid: false, - }, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) {