Skip to content

Commit 85a3545

Browse files
committed
CORS-3608: aws: deprecate platform.aws.amiID field
This field was introduced [1] before the Installer had support for custom AMIs in machine pools [2]. Now that it does, the same functionality is achieved via the defaultMachinePlatform field `platform.aws.defaultMachinePlatform.amiID` [1] fdf94e3 [2] bc47222
1 parent e852868 commit 85a3545

File tree

7 files changed

+44
-10
lines changed

7 files changed

+44
-10
lines changed

data/data/install.openshift.io_installconfigs.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,9 +2155,9 @@ spec:
21552155
description: AWS is the configuration used when installing on AWS.
21562156
properties:
21572157
amiID:
2158-
description: AMIID is the AMI that should be used to boot machines
2159-
for the cluster. If set, the AMI should belong to the same region
2160-
as the cluster.
2158+
description: The field is deprecated. AMIID is the AMI that should
2159+
be used to boot machines for the cluster. If set, the AMI should
2160+
belong to the same region as the cluster.
21612161
type: string
21622162
bestEffortDeleteIgnition:
21632163
description: BestEffortDeleteIgnition is an optional field that

docs/user/aws/customization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Beyond the [platform-agnostic `install-config.yaml` properties](../customization
55
## Cluster-scoped properties
66

77
* `amiID` (optional string): The AMI that should be used to boot machines for the cluster.
8-
If set, the AMI should belong to the same region as the cluster.
8+
If set, the AMI should belong to the same region as the cluster. This field is now deprecated and `defaultMachinePlatform` should be used instead.
99
* `region` (required string): The AWS region where the cluster will be created.
1010
* `subnets` (optional array of strings): Existing subnets (by ID) where cluster resources will be created.
1111
Leave unset to have the installer create subnets in a new VPC on your behalf.

pkg/asset/rhcos/image.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ func osImage(ctx context.Context, config *types.InstallConfig) (string, error) {
8484
}
8585
switch config.Platform.Name() {
8686
case aws.Name:
87-
if len(config.Platform.AWS.AMIID) > 0 {
88-
return config.Platform.AWS.AMIID, nil
89-
}
9087
region := config.Platform.AWS.Region
9188
if !rhcos.AMIRegions(config.ControlPlane.Architecture).Has(region) {
9289
const globalResourceRegion = "us-east-1"

pkg/explain/printer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func Test_PrintFields(t *testing.T) {
148148
path: []string{"platform", "aws"},
149149
desc: `FIELDS:
150150
amiID <string>
151-
AMIID is the AMI that should be used to boot machines for the cluster. If set, the AMI should belong to the same region as the cluster.
151+
The field is deprecated. AMIID is the AMI that should be used to boot machines for the cluster. If set, the AMI should belong to the same region as the cluster.
152152
153153
bestEffortDeleteIgnition <boolean>
154154
BestEffortDeleteIgnition is an optional field that can be used to ignore errors from S3 deletion of ignition objects during cluster bootstrap. The default behavior is to fail the installation if ignition objects cannot be deleted. Enable this functionality when there are known reasons disallowing their deletion.

pkg/types/aws/platform.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ const (
1616
// Platform stores all the global configuration that all machinesets
1717
// use.
1818
type Platform struct {
19-
// AMIID is the AMI that should be used to boot machines for the cluster.
20-
// If set, the AMI should belong to the same region as the cluster.
19+
// The field is deprecated. AMIID is the AMI that should be used to boot
20+
// machines for the cluster. If set, the AMI should belong to the same
21+
// region as the cluster.
2122
//
2223
// +optional
2324
AMIID string `json:"amiID,omitempty"`

pkg/types/conversion/installconfig.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,5 +289,14 @@ func convertAWS(config *types.InstallConfig) error {
289289
if !config.AWS.BestEffortDeleteIgnition {
290290
config.AWS.BestEffortDeleteIgnition = config.AWS.PreserveBootstrapIgnition
291291
}
292+
if ami := config.AWS.AMIID; len(ami) > 0 {
293+
if config.AWS.DefaultMachinePlatform == nil {
294+
config.AWS.DefaultMachinePlatform = &aws.MachinePool{}
295+
}
296+
// DefaultMachinePlatform.AMIID takes precedence in the machine manifest code anyway
297+
if len(config.AWS.DefaultMachinePlatform.AMIID) == 0 {
298+
config.AWS.DefaultMachinePlatform.AMIID = ami
299+
}
300+
}
292301
return nil
293302
}

pkg/types/conversion/installconfig_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/openshift/installer/pkg/ipnet"
1212
"github.com/openshift/installer/pkg/types"
13+
"github.com/openshift/installer/pkg/types/aws"
1314
"github.com/openshift/installer/pkg/types/baremetal"
1415
"github.com/openshift/installer/pkg/types/nutanix"
1516
"github.com/openshift/installer/pkg/types/openstack"
@@ -706,6 +707,32 @@ func TestConvertInstallConfig(t *testing.T) {
706707
},
707708
},
708709
},
710+
{
711+
name: "aws deprecated platform amiID",
712+
config: &types.InstallConfig{
713+
TypeMeta: metav1.TypeMeta{
714+
APIVersion: types.InstallConfigVersion,
715+
},
716+
Platform: types.Platform{
717+
AWS: &aws.Platform{
718+
AMIID: "deprec-id",
719+
},
720+
},
721+
},
722+
expected: &types.InstallConfig{
723+
TypeMeta: metav1.TypeMeta{
724+
APIVersion: types.InstallConfigVersion,
725+
},
726+
Platform: types.Platform{
727+
AWS: &aws.Platform{
728+
AMIID: "deprec-id",
729+
DefaultMachinePlatform: &aws.MachinePool{
730+
AMIID: "deprec-id",
731+
},
732+
},
733+
},
734+
},
735+
},
709736
}
710737

711738
for _, tc := range cases {

0 commit comments

Comments
 (0)