@@ -123,6 +123,7 @@ func TestMachineCreation(t *testing.T) {
123123 platformType osconfigv1.PlatformType
124124 clusterID string
125125 presetClusterID bool
126+ isMasterMachine bool
126127 expectedError string
127128 disconnected bool
128129 providerSpecValue * kruntime.RawExtension
@@ -1033,6 +1034,66 @@ func TestMachineCreation(t *testing.T) {
10331034 },
10341035 expectedError : "" ,
10351036 },
1037+ {
1038+ name : "control plane machine with dedicated host should fail" ,
1039+ platformType : osconfigv1 .AWSPlatformType ,
1040+ clusterID : "aws-cluster" ,
1041+ isMasterMachine : true ,
1042+ providerSpecValue : & kruntime.RawExtension {
1043+ Object : & machinev1beta1.AWSMachineProviderConfig {
1044+ AMI : machinev1beta1.AWSResourceReference {ID : ptr.To [string ]("ami" )},
1045+ InstanceType : "test" ,
1046+ Placement : machinev1beta1.Placement {
1047+ Tenancy : machinev1beta1 .HostTenancy ,
1048+ Host : & machinev1beta1.HostPlacement {
1049+ Affinity : ptr .To (machinev1beta1 .HostAffinityAnyAvailable ),
1050+ },
1051+ },
1052+ },
1053+ },
1054+ expectedError : "admission webhook \" validation.machine.machine.openshift.io\" denied the request: spec.placement.tenancy: Forbidden: dedicated host tenancy is not supported for control plane machines" ,
1055+ },
1056+ {
1057+ name : "control plane machine with dedicated host and ID should fail" ,
1058+ platformType : osconfigv1 .AWSPlatformType ,
1059+ clusterID : "aws-cluster" ,
1060+ isMasterMachine : true ,
1061+ providerSpecValue : & kruntime.RawExtension {
1062+ Object : & machinev1beta1.AWSMachineProviderConfig {
1063+ AMI : machinev1beta1.AWSResourceReference {ID : ptr.To [string ]("ami" )},
1064+ InstanceType : "test" ,
1065+ Placement : machinev1beta1.Placement {
1066+ Tenancy : machinev1beta1 .HostTenancy ,
1067+ Host : & machinev1beta1.HostPlacement {
1068+ Affinity : ptr .To (machinev1beta1 .HostAffinityDedicatedHost ),
1069+ DedicatedHost : & machinev1beta1.DedicatedHost {
1070+ ID : "h-1234567890abcdef0" ,
1071+ },
1072+ },
1073+ },
1074+ },
1075+ },
1076+ expectedError : "admission webhook \" validation.machine.machine.openshift.io\" denied the request: spec.placement.tenancy: Forbidden: dedicated host tenancy is not supported for control plane machines" ,
1077+ },
1078+ {
1079+ name : "worker machine with dedicated host should succeed" ,
1080+ platformType : osconfigv1 .AWSPlatformType ,
1081+ clusterID : "aws-cluster" ,
1082+ isMasterMachine : false ,
1083+ providerSpecValue : & kruntime.RawExtension {
1084+ Object : & machinev1beta1.AWSMachineProviderConfig {
1085+ AMI : machinev1beta1.AWSResourceReference {ID : ptr.To [string ]("ami" )},
1086+ InstanceType : "test" ,
1087+ Placement : machinev1beta1.Placement {
1088+ Tenancy : machinev1beta1 .HostTenancy ,
1089+ Host : & machinev1beta1.HostPlacement {
1090+ Affinity : ptr .To (machinev1beta1 .HostAffinityAnyAvailable ),
1091+ },
1092+ },
1093+ },
1094+ },
1095+ expectedError : "" ,
1096+ },
10361097 {
10371098 name : "with VolumeType set to gp3 and Throughput set under minium value" ,
10381099 platformType : osconfigv1 .AWSPlatformType ,
@@ -2243,6 +2304,13 @@ func TestMachineCreation(t *testing.T) {
22432304 m .Labels = make (map [string ]string )
22442305 m .Labels [machinev1beta1 .MachineClusterIDLabel ] = presetClusterID
22452306 }
2307+ if tc .isMasterMachine {
2308+ if m .Labels == nil {
2309+ m .Labels = make (map [string ]string )
2310+ }
2311+ m .Labels [machineRoleLabel ] = "master"
2312+ m .Labels [machineTypeLabel ] = "master"
2313+ }
22462314
22472315 err = c .Create (ctx , m )
22482316 if err == nil {
0 commit comments