From b07f23e0a2dafb889ac97087c78bcf4a303ddd68 Mon Sep 17 00:00:00 2001 From: Abhinav Dahiya Date: Fri, 11 Jan 2019 10:33:15 -0800 Subject: [PATCH] types: drop image options from install config for all platforms RHCOS image that needs to be used for installation must be sources from RHCOS build pipeline and RHCOS build. Keeping the image related fields in install-config allows users to change these values as part of valid configuration, but we do not want users to configure this option as the RHCOS image controls the runtime and kubelet versions we depend on. --- pkg/types/aws/machinepool.go | 7 +------ pkg/types/libvirt/platform.go | 4 ---- pkg/types/libvirt/validation/platform.go | 3 --- pkg/types/libvirt/validation/platform_test.go | 12 +----------- pkg/types/openstack/platform.go | 4 ---- pkg/types/openstack/validation/platform.go | 6 ------ pkg/types/openstack/validation/platform_test.go | 16 ---------------- pkg/types/validation/installconfig_test.go | 8 +++----- 8 files changed, 5 insertions(+), 55 deletions(-) diff --git a/pkg/types/aws/machinepool.go b/pkg/types/aws/machinepool.go index b19dcea1ad2..ba872b1635c 100644 --- a/pkg/types/aws/machinepool.go +++ b/pkg/types/aws/machinepool.go @@ -6,9 +6,6 @@ type MachinePool struct { // Zones is list of availability zones that can be used. Zones []string `json:"zones,omitempty"` - // AMIID defines the AMI that should be used. - AMIID string `json:"amiID,omitempty"` - // InstanceType defines the ec2 instance type. // eg. m4-large InstanceType string `json:"type"` @@ -30,9 +27,7 @@ func (a *MachinePool) Set(required *MachinePool) { if len(required.Zones) > 0 { a.Zones = required.Zones } - if required.AMIID != "" { - a.AMIID = required.AMIID - } + if required.InstanceType != "" { a.InstanceType = required.InstanceType } diff --git a/pkg/types/libvirt/platform.go b/pkg/types/libvirt/platform.go index 34ce2115eec..e9dbe6fbac9 100644 --- a/pkg/types/libvirt/platform.go +++ b/pkg/types/libvirt/platform.go @@ -12,10 +12,6 @@ type Platform struct { // cluster (where the cluster-API controller pod will be running). URI string `json:"URI"` - // Image is the URL to the OS image. - // E.g. "http://aos-ostree.rhev-ci-vms.eng.rdu2.redhat.com/rhcos/images/cloud/latest/rhcos-qemu.qcow2.gz" - Image string `json:"image"` - // DefaultMachinePlatform is the default configuration used when // installing on libvirt for machine pools which do not define their // own platform configuration. diff --git a/pkg/types/libvirt/validation/platform.go b/pkg/types/libvirt/validation/platform.go index 951b3251c79..c058c223d95 100644 --- a/pkg/types/libvirt/validation/platform.go +++ b/pkg/types/libvirt/validation/platform.go @@ -13,9 +13,6 @@ func ValidatePlatform(p *libvirt.Platform, fldPath *field.Path) field.ErrorList if err := validate.URI(p.URI); err != nil { allErrs = append(allErrs, field.Invalid(fldPath.Child("uri"), p.URI, err.Error())) } - if err := validate.URI(p.Image); err != nil { - allErrs = append(allErrs, field.Invalid(fldPath.Child("image"), p.Image, err.Error())) - } if p.DefaultMachinePlatform != nil { allErrs = append(allErrs, ValidateMachinePool(p.DefaultMachinePlatform, fldPath.Child("defaultMachinePlatform"))...) } diff --git a/pkg/types/libvirt/validation/platform_test.go b/pkg/types/libvirt/validation/platform_test.go index a218f65347a..67377269f2f 100644 --- a/pkg/types/libvirt/validation/platform_test.go +++ b/pkg/types/libvirt/validation/platform_test.go @@ -11,8 +11,7 @@ import ( func validPlatform() *libvirt.Platform { return &libvirt.Platform{ - URI: "qemu+tcp://192.168.122.1/system", - Image: "https://example.com/rhcos-qemu.qcow2", + URI: "qemu+tcp://192.168.122.1/system", Network: libvirt.Network{ IfName: "tt0", }, @@ -39,15 +38,6 @@ func TestValidatePlatform(t *testing.T) { }(), valid: false, }, - { - name: "invalid image", - platform: func() *libvirt.Platform { - p := validPlatform() - p.Image = "bad-image" - return p - }(), - valid: false, - }, { name: "missing interface name", platform: func() *libvirt.Platform { diff --git a/pkg/types/openstack/platform.go b/pkg/types/openstack/platform.go index 1c7c0d8abc7..ca474845121 100644 --- a/pkg/types/openstack/platform.go +++ b/pkg/types/openstack/platform.go @@ -11,10 +11,6 @@ type Platform struct { // platform configuration. DefaultMachinePlatform *MachinePool `json:"defaultMachinePlatform,omitempty"` - // BaseImage - // Name of image to use from OpenStack cloud - BaseImage string `json:"baseImage"` - // Cloud // Name of OpenStack cloud to use from clouds.yaml Cloud string `json:"cloud"` diff --git a/pkg/types/openstack/validation/platform.go b/pkg/types/openstack/validation/platform.go index a8d3a89c122..121797893b8 100644 --- a/pkg/types/openstack/validation/platform.go +++ b/pkg/types/openstack/validation/platform.go @@ -23,12 +23,6 @@ func ValidatePlatform(p *openstack.Platform, fldPath *field.Path, fetcher ValidV } else if !isValidValue(p.Region, validRegions) { allErrs = append(allErrs, field.NotSupported(fldPath.Child("region"), p.Region, validRegions)) } - validImages, err := fetcher.GetImageNames(p.Cloud) - if err != nil { - allErrs = append(allErrs, field.InternalError(fldPath.Child("baseImage"), errors.New("could not retrieve valid images"))) - } else if !isValidValue(p.BaseImage, validImages) { - allErrs = append(allErrs, field.NotSupported(fldPath.Child("baseImage"), p.BaseImage, validImages)) - } validNetworks, err := fetcher.GetNetworkNames(p.Cloud) if err != nil { allErrs = append(allErrs, field.InternalError(fldPath.Child("externalNetwork"), errors.New("could not retrieve valid networks"))) diff --git a/pkg/types/openstack/validation/platform_test.go b/pkg/types/openstack/validation/platform_test.go index f7413a0d3a0..2f1c616f816 100644 --- a/pkg/types/openstack/validation/platform_test.go +++ b/pkg/types/openstack/validation/platform_test.go @@ -15,7 +15,6 @@ import ( func validPlatform() *openstack.Platform { return &openstack.Platform{ Region: "test-region", - BaseImage: "test-image", Cloud: "test-cloud", ExternalNetwork: "test-network", FlavorName: "test-flavor", @@ -47,15 +46,6 @@ func TestValidatePlatform(t *testing.T) { }(), valid: false, }, - { - name: "invalid base image", - platform: func() *openstack.Platform { - p := validPlatform() - p.BaseImage = "bad-image" - return p - }(), - valid: false, - }, { name: "missing cloud", platform: func() *openstack.Platform { @@ -95,12 +85,6 @@ func TestValidatePlatform(t *testing.T) { noRegions: true, valid: false, }, - { - name: "images fetch failure", - platform: validPlatform(), - noImages: true, - valid: false, - }, { name: "networks fetch failure", platform: validPlatform(), diff --git a/pkg/types/validation/installconfig_test.go b/pkg/types/validation/installconfig_test.go index 1f458a37287..0a4e9f836e7 100644 --- a/pkg/types/validation/installconfig_test.go +++ b/pkg/types/validation/installconfig_test.go @@ -207,7 +207,7 @@ func TestValidateInstallConfig(t *testing.T) { c.Platform.Libvirt = &libvirt.Platform{} return c }(), - expectedError: `^\[platform: Invalid value: types\.Platform{AWS:\(\*aws\.Platform\)\(0x[0-9a-f]*\), Libvirt:\(\*libvirt\.Platform\)\(0x[0-9a-f]*\), None:\(\*none\.Platform\)\(nil\), OpenStack:\(\*openstack\.Platform\)\(nil\)}: must only specify a single type of platform; cannot use both "aws" and "libvirt", platform\.libvirt\.uri: Invalid value: "": invalid URI "" \(no scheme\), platform.libvirt.image: Invalid value: "": invalid URI "" \(no scheme\), platform\.libvirt\.network\.if: Required value]$`, + expectedError: `^\[platform: Invalid value: types\.Platform{AWS:\(\*aws\.Platform\)\(0x[0-9a-f]*\), Libvirt:\(\*libvirt\.Platform\)\(0x[0-9a-f]*\), None:\(\*none\.Platform\)\(nil\), OpenStack:\(\*openstack\.Platform\)\(nil\)}: must only specify a single type of platform; cannot use both "aws" and "libvirt", platform\.libvirt\.uri: Invalid value: "": invalid URI "" \(no scheme\), platform\.libvirt\.network\.if: Required value]$`, }, { name: "invalid aws platform", @@ -226,8 +226,7 @@ func TestValidateInstallConfig(t *testing.T) { c := validInstallConfig() c.Platform = types.Platform{ Libvirt: &libvirt.Platform{ - URI: "qemu+tcp://192.168.122.1/system", - Image: "https://example.com/test-image", + URI: "qemu+tcp://192.168.122.1/system", Network: libvirt.Network{ IfName: "tt0", }, @@ -246,7 +245,7 @@ func TestValidateInstallConfig(t *testing.T) { } return c }(), - expectedError: `^\[platform: Invalid value: types\.Platform{AWS:\(\*aws\.Platform\)\(nil\), Libvirt:\(\*libvirt\.Platform\)\(0x[0-9a-f]*\), None:\(\*none\.Platform\)\(nil\), OpenStack:\(\*openstack\.Platform\)\(nil\)}: must specify one of the platforms \(aws, none, openstack\), platform\.libvirt\.uri: Invalid value: "": invalid URI "" \(no scheme\), platform.libvirt.image: Invalid value: "": invalid URI "" \(no scheme\), platform\.libvirt\.network\.if: Required value]$`, + expectedError: `^\[platform: Invalid value: types\.Platform{AWS:\(\*aws\.Platform\)\(nil\), Libvirt:\(\*libvirt\.Platform\)\(0x[0-9a-f]*\), None:\(\*none\.Platform\)\(nil\), OpenStack:\(\*openstack\.Platform\)\(nil\)}: must specify one of the platforms \(aws, none, openstack\), platform\.libvirt\.uri: Invalid value: "": invalid URI "" \(no scheme\), platform\.libvirt\.network\.if: Required value]$`, }, { name: "valid openstack platform", @@ -255,7 +254,6 @@ func TestValidateInstallConfig(t *testing.T) { c.Platform = types.Platform{ OpenStack: &openstack.Platform{ Region: "test-region", - BaseImage: "test-image", Cloud: "test-cloud", ExternalNetwork: "test-network", FlavorName: "test-flavor",