Skip to content

Commit

Permalink
types: drop image options from install config for all platforms
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
abhinavdahiya committed Jan 12, 2019
1 parent 255566f commit b07f23e
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 55 deletions.
7 changes: 1 addition & 6 deletions pkg/types/aws/machinepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/types/libvirt/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions pkg/types/libvirt/validation/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))...)
}
Expand Down
12 changes: 1 addition & 11 deletions pkg/types/libvirt/validation/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions pkg/types/openstack/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
6 changes: 0 additions & 6 deletions pkg/types/openstack/validation/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down
16 changes: 0 additions & 16 deletions pkg/types/openstack/validation/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
Expand Down
8 changes: 3 additions & 5 deletions pkg/types/validation/installconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
},
Expand All @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit b07f23e

Please sign in to comment.