Skip to content

Commit fe126ca

Browse files
Merge pull request openshift#8755 from r4f4/aws-deprec-platform-amiid
CORS-3608: aws: deprecate platform.aws.amiID field
2 parents 5804b02 + 85a3545 commit fe126ca

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
@@ -2497,9 +2497,9 @@ spec:
24972497
description: AWS is the configuration used when installing on AWS.
24982498
properties:
24992499
amiID:
2500-
description: AMIID is the AMI that should be used to boot machines
2501-
for the cluster. If set, the AMI should belong to the same region
2502-
as the cluster.
2500+
description: The field is deprecated. AMIID is the AMI that should
2501+
be used to boot machines for the cluster. If set, the AMI should
2502+
belong to the same region as the cluster.
25032503
type: string
25042504
bestEffortDeleteIgnition:
25052505
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
@@ -95,9 +95,6 @@ func osImage(ctx context.Context, config *types.InstallConfig, nodeArch types.Ar
9595
}
9696
switch config.Platform.Name() {
9797
case aws.Name:
98-
if len(config.Platform.AWS.AMIID) > 0 {
99-
return config.Platform.AWS.AMIID, nil
100-
}
10198
region := config.Platform.AWS.Region
10299
if !rhcos.AMIRegions(nodeArch).Has(region) {
103100
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)