@@ -708,109 +708,166 @@ def test_placement_group_validator(
708708 "is_flexible" ,
709709 "subnet_availability_zone" ,
710710 "capacity_type" ,
711+ "os" ,
711712 "expected_messages" ,
712713 ),
713714 [
714715 (
715- CapacityReservationInfo ({"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1a" }),
716+ CapacityReservationInfo (
717+ {"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1a" , "InstancePlatform" : "Linux/UNIX" }
718+ ),
716719 ["c5.xlarge" ],
717720 False ,
718721 "us-east-1a" ,
719722 None ,
723+ "alinux2" ,
720724 [],
721725 ),
722726 # Wrong instance type
723727 (
724- CapacityReservationInfo ({"InstanceType" : "m5.xlarge" , "AvailabilityZone" : "us-east-1a" }),
728+ CapacityReservationInfo (
729+ {"InstanceType" : "m5.xlarge" , "AvailabilityZone" : "us-east-1a" , "InstancePlatform" : "Linux/UNIX" }
730+ ),
725731 ["c5.xlarge" ],
726732 False ,
727733 "us-east-1a" ,
728734 CapacityType .ONDEMAND ,
735+ "alinux2023" ,
729736 ["Capacity reservation .* must have the same instance type as c5.xlarge." ],
730737 ),
731738 # Wrong availability zone
732739 (
733- CapacityReservationInfo ({"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1b" }),
740+ CapacityReservationInfo (
741+ {"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1b" , "InstancePlatform" : "Linux/UNIX" }
742+ ),
734743 ["c5.xlarge" ],
735744 False ,
736745 "us-east-1a" ,
737746 CapacityType .SPOT ,
738- ["Capacity reservation .* must use the same availability zone as subnet" ],
747+ "ubuntu2404" ,
748+ [
749+ "Capacity reservation .* has platform Linux/UNIX, which is not compatible with "
750+ + "the cluster OS ubuntu2404. Please use a reservation with platform Ubuntu Pro." ,
751+ "Capacity reservation .* must use the same availability zone as subnet" ,
752+ ],
739753 ),
740754 # Both instance type and availability zone are wrong
741755 (
742- CapacityReservationInfo ({"InstanceType" : "m5.xlarge" , "AvailabilityZone" : "us-east-1b" }),
756+ CapacityReservationInfo (
757+ {"InstanceType" : "m5.xlarge" , "AvailabilityZone" : "us-east-1b" , "InstancePlatform" : "Ubuntu Pro" }
758+ ),
743759 ["c5.xlarge" ],
744760 False ,
745761 "us-east-1a" ,
746762 CapacityType .ONDEMAND ,
763+ "ubuntu2204" ,
747764 [
748765 "Capacity reservation .* must have the same instance type as c5.xlarge." ,
749766 "Capacity reservation .* must use the same availability zone as subnet" ,
750767 ],
751768 ),
752769 (
753- CapacityReservationInfo ({"InstanceType" : "m5.xlarge" , "AvailabilityZone" : "us-east-1b" }),
770+ CapacityReservationInfo (
771+ {
772+ "InstanceType" : "m5.xlarge" ,
773+ "AvailabilityZone" : "us-east-1b" ,
774+ "InstancePlatform" : "Red Hat Enterprise Linux" ,
775+ }
776+ ),
754777 ["c5.xlarge" ],
755778 False ,
756779 "us-east-1a" ,
757780 CapacityType .SPOT ,
758- ["Capacity reservation .* must use the same availability zone as subnet" ],
781+ "ubuntu2004" ,
782+ [
783+ "Capacity reservation .* has platform Red Hat Enterprise Linux, which is not "
784+ + "compatible with the cluster OS ubuntu2004. Please use a reservation with platform Ubuntu Pro." ,
785+ "Capacity reservation .* must use the same availability zone as subnet" ,
786+ ],
759787 ),
760788 # empty instance type, this should not happen because instance type is automatically retrieved when usinc cr-id
761789 (
762- CapacityReservationInfo ({"InstanceType" : "m5.xlarge" , "AvailabilityZone" : "us-east-1b" }),
790+ CapacityReservationInfo (
791+ {"InstanceType" : "m5.xlarge" , "AvailabilityZone" : "us-east-1b" , "InstancePlatform" : "Linux/UNIX" }
792+ ),
763793 None ,
764794 False ,
765795 "us-east-1a" ,
766796 CapacityType .ONDEMAND ,
797+ "alinux2" ,
767798 [
768799 "Unexpected failure. InstanceType parameter cannot be empty when using CapacityReservationId" ,
769800 "Capacity reservation .* must use the same availability zone as subnet" ,
770801 ],
771802 ),
772803 # empty instance type, this should not happen because instance type is automatically retrieved when usinc cr-id
773804 (
774- CapacityReservationInfo ({"InstanceType" : "m5.xlarge" , "AvailabilityZone" : "us-east-1b" }),
805+ CapacityReservationInfo (
806+ {
807+ "InstanceType" : "m5.xlarge" ,
808+ "AvailabilityZone" : "us-east-1b" ,
809+ "InstancePlatform" : "Red Hat Enterprise Linux" ,
810+ }
811+ ),
775812 "" ,
776813 False ,
777814 "us-east-1a" ,
778815 CapacityType .SPOT ,
816+ "rocky9" ,
779817 [
780818 "Unexpected failure. InstanceType parameter cannot be empty when using CapacityReservationId" ,
781819 "Capacity reservation .* must use the same availability zone as subnet" ,
782820 ],
783821 ),
784822 # wrong capacity type
785823 (
786- CapacityReservationInfo ({"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1a" }),
824+ CapacityReservationInfo (
825+ {
826+ "InstanceType" : "c5.xlarge" ,
827+ "AvailabilityZone" : "us-east-1a" ,
828+ "InstancePlatform" : "Red Hat Enterprise Linux" ,
829+ }
830+ ),
787831 ["c5.xlarge" ],
788832 False ,
789833 "us-east-1a" ,
790834 CapacityType .CAPACITY_BLOCK ,
835+ "rocky8" ,
791836 [
792837 "Capacity reservation cr-123 is not a Capacity Block reservation. "
793838 "It cannot be used when specifying CapacityType: CAPACITY_BLOCK."
794839 ],
795840 ),
796841 (
797842 CapacityReservationInfo (
798- {"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1a" , "ReservationType" : "capacity-block" }
843+ {
844+ "InstanceType" : "c5.xlarge" ,
845+ "AvailabilityZone" : "us-east-1a" ,
846+ "ReservationType" : "capacity-block" ,
847+ "InstancePlatform" : "Ubuntu Pro" ,
848+ }
799849 ),
800850 ["c5.xlarge" ],
801851 False ,
802852 "us-east-1a" ,
803853 CapacityType .ONDEMAND ,
854+ "ubuntu2004" ,
804855 [], # Do not check Ondemand capacity type
805856 ),
806857 (
807858 CapacityReservationInfo (
808- {"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1a" , "ReservationType" : "ondemand" }
859+ {
860+ "InstanceType" : "c5.xlarge" ,
861+ "AvailabilityZone" : "us-east-1a" ,
862+ "ReservationType" : "ondemand" ,
863+ "InstancePlatform" : "Linux/UNIX" ,
864+ }
809865 ),
810866 ["c5.xlarge" ],
811867 False ,
812868 "us-east-1a" ,
813869 CapacityType .CAPACITY_BLOCK ,
870+ "alinux2" ,
814871 [
815872 "Capacity reservation cr-123 is not a Capacity Block reservation. "
816873 "It cannot be used when specifying CapacityType: CAPACITY_BLOCK."
@@ -819,43 +876,88 @@ def test_placement_group_validator(
819876 # right capacity type
820877 (
821878 CapacityReservationInfo (
822- {"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1a" , "ReservationType" : "ondemand" }
879+ {
880+ "InstanceType" : "c5.xlarge" ,
881+ "AvailabilityZone" : "us-east-1a" ,
882+ "ReservationType" : "ondemand" ,
883+ "InstancePlatform" : "Linux/UNIX" ,
884+ }
823885 ),
824886 ["c5.xlarge" ],
825887 False ,
826888 "us-east-1a" ,
827889 CapacityType .ONDEMAND ,
890+ "alinux2023" ,
828891 [],
829892 ),
830893 (
831894 CapacityReservationInfo (
832- {"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1a" , "ReservationType" : "capacity-block" }
895+ {
896+ "InstanceType" : "c5.xlarge" ,
897+ "AvailabilityZone" : "us-east-1a" ,
898+ "ReservationType" : "capacity-block" ,
899+ "InstancePlatform" : "Linux/UNIX" ,
900+ }
833901 ),
834902 ["c5.xlarge" ],
835903 False ,
836904 "us-east-1a" ,
837905 CapacityType .CAPACITY_BLOCK ,
906+ "alinux2" ,
838907 [],
839908 ),
909+ (
910+ CapacityReservationInfo (
911+ {"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1a" , "InstancePlatform" : "SUSE Linux" }
912+ ),
913+ ["c5.xlarge" ],
914+ False ,
915+ "us-east-1a" ,
916+ CapacityType .ONDEMAND ,
917+ "alinux2" ,
918+ [
919+ "Capacity reservation .* has platform SUSE Linux, which is not compatible"
920+ + " with the cluster OS alinux2. Please use a reservation with platform Linux/UNIX."
921+ ],
922+ ),
840923 # Flexible instance type, with a single instance and capacity_reservation_id
841924 (
842- CapacityReservationInfo ({"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1a" }),
925+ CapacityReservationInfo (
926+ {
927+ "InstanceType" : "c5.xlarge" ,
928+ "AvailabilityZone" : "us-east-1a" ,
929+ "InstancePlatform" : "Linux/UNIX with HA" ,
930+ }
931+ ),
843932 ["c5.xlarge" ],
844933 True ,
845934 "us-east-1a" ,
846935 None ,
847- ["CapacityReservationId parameter cannot be used with Instances parameter." ],
936+ "alinux2023" ,
937+ [
938+ "Capacity reservation .* has platform Linux/UNIX with HA, which is not compatible "
939+ + "with the cluster OS alinux2023. Please use a reservation with platform Linux/UNIX." ,
940+ "CapacityReservationId parameter cannot be used with Instances parameter." ,
941+ ],
848942 ),
849943 # Flexible instance type with multiple instance types and capacity_reservation_id
850944 (
851945 CapacityReservationInfo (
852- {"InstanceType" : "c5.xlarge" , "AvailabilityZone" : "us-east-1a" , "ReservationType" : "ondemand" }
946+ {
947+ "InstanceType" : "c5.xlarge" ,
948+ "AvailabilityZone" : "us-east-1a" ,
949+ "ReservationType" : "ondemand" ,
950+ "InstancePlatform" : "Ubuntu Pro" ,
951+ }
853952 ),
854953 ["c5.xlarge" , "m5.2xlarge" ],
855954 True ,
856955 "us-east-1a" ,
857956 CapacityType .ONDEMAND ,
858- ["CapacityReservationId parameter cannot be used with Instances parameter." ],
957+ "ubuntu2004" ,
958+ [
959+ "CapacityReservationId parameter cannot be used with Instances parameter." ,
960+ ],
859961 ),
860962 ],
861963)
@@ -866,6 +968,7 @@ def test_capacity_reservation_validator(
866968 subnet_availability_zone ,
867969 is_flexible ,
868970 capacity_type ,
971+ os ,
869972 expected_messages ,
870973):
871974 mock_aws_api (mocker )
@@ -877,6 +980,7 @@ def test_capacity_reservation_validator(
877980 is_flexible = is_flexible ,
878981 subnet = "subnet-123" ,
879982 capacity_type = capacity_type ,
983+ os = os ,
880984 )
881985 assert_failure_messages (actual_failures , expected_messages )
882986
0 commit comments