@@ -76,15 +76,22 @@ func retryIfTransient(err error, logger logr.Logger) (ctrl.Result, error) {
76
76
}
77
77
return ctrl.Result {RequeueAfter : reconciler .DefaultMachineControllerRetryDelay }, nil
78
78
}
79
- logger .Error (err , "unknown Linode API error" )
80
- return ctrl.Result {RequeueAfter : reconciler . DefaultMachineControllerRetryDelay }, nil
79
+ logger .Error (err , "non-retryable Linode API error, skipping requeue " )
80
+ return ctrl.Result {}, nil
81
81
}
82
82
83
83
func fillCreateConfig (createConfig * linodego.InstanceCreateOptions , machineScope * scope.MachineScope ) {
84
84
if machineScope .LinodeMachine .Spec .PrivateIP != nil {
85
85
createConfig .PrivateIP = * machineScope .LinodeMachine .Spec .PrivateIP
86
86
} else {
87
- createConfig .PrivateIP = true
87
+ if machineScope .LinodeMachine .Spec .LinodeInterfaces == nil {
88
+ // Supported only for legacy network interfaces.
89
+ createConfig .PrivateIP = true
90
+ } else {
91
+ // Network Helper is not supported for the new network interfaces.
92
+ createConfig .NetworkHelper = ptr .To (false )
93
+ createConfig .InterfaceGeneration = linodego .GenerationLinode
94
+ }
88
95
}
89
96
90
97
if createConfig .Tags == nil {
@@ -638,12 +645,21 @@ func getVPCLinodeInterfaceConfig(ctx context.Context, machineScope *scope.Machin
638
645
}
639
646
640
647
// Check if a VPC interface already exists
641
- for i , netInterface := range linodeInterfaces {
648
+ for iface , netInterface := range linodeInterfaces {
642
649
if netInterface .VPC != nil {
643
- linodeInterfaces [i ].VPC .SubnetID = subnetID
650
+ linodeInterfaces [iface ].VPC .SubnetID = subnetID
644
651
// If IPv6 range config is not empty, add it to the interface configuration
645
652
if ! isVPCInterfaceIPv6ConfigEmpty (ipv6Config ) {
646
- linodeInterfaces [i ].VPC .IPv6 = ipv6Config
653
+ linodeInterfaces [iface ].VPC .IPv6 = ipv6Config
654
+ }
655
+ if netInterface .VPC .IPv4 == nil {
656
+ linodeInterfaces [iface ].VPC .IPv4 = & linodego.VPCInterfaceIPv4CreateOptions {
657
+ Addresses : []linodego.VPCInterfaceIPv4AddressCreateOptions {{
658
+ Primary : ptr .To (true ),
659
+ NAT1To1Address : ptr .To ("auto" ),
660
+ Address : "auto" ,
661
+ }},
662
+ }
647
663
}
648
664
return nil , nil //nolint:nilnil // it is important we don't return an interface if a VPC interface already exists
649
665
}
@@ -656,7 +672,8 @@ func getVPCLinodeInterfaceConfig(ctx context.Context, machineScope *scope.Machin
656
672
IPv4 : & linodego.VPCInterfaceIPv4CreateOptions {
657
673
Addresses : []linodego.VPCInterfaceIPv4AddressCreateOptions {{
658
674
Primary : ptr .To (true ),
659
- NAT1To1Address : ptr .To ("any" ),
675
+ NAT1To1Address : ptr .To ("auto" ),
676
+ Address : "auto" ,
660
677
}},
661
678
},
662
679
},
@@ -667,6 +684,8 @@ func getVPCLinodeInterfaceConfig(ctx context.Context, machineScope *scope.Machin
667
684
vpcIntfCreateOpts .VPC .IPv6 = ipv6Config
668
685
}
669
686
687
+ logger .Info ("Creating LinodeInterfaceCreateOptions" , "VPC" , * vpcIntfCreateOpts )
688
+
670
689
return vpcIntfCreateOpts , nil
671
690
}
672
691
@@ -738,7 +757,7 @@ func getVPCLinodeInterfaceConfigFromDirectID(ctx context.Context, machineScope *
738
757
IPv4 : & linodego.VPCInterfaceIPv4CreateOptions {
739
758
Addresses : []linodego.VPCInterfaceIPv4AddressCreateOptions {{
740
759
Primary : ptr .To (true ),
741
- NAT1To1Address : ptr .To ("any " ),
760
+ NAT1To1Address : ptr .To ("auto " ),
742
761
}},
743
762
},
744
763
},
@@ -905,7 +924,6 @@ func getVPCInterfaceIPv6Config(machineScope *scope.MachineScope, numIPv6RangesIn
905
924
906
925
// Unfortunately, this is necessary since DeepCopy can't be generated for linodego.LinodeInterfaceCreateOptions
907
926
// so here we manually create the options for Linode interfaces.
908
- // /
909
927
//
910
928
//nolint:gocognit,cyclop,gocritic,nestif,nolintlint // Also, unfortunately, this cannot be made any reasonably simpler with how complicated the linodego struct is
911
929
func constructLinodeInterfaceCreateOpts (createOpts []infrav1alpha2.LinodeInterfaceCreateOptions ) []linodego.LinodeInterfaceCreateOptions {
@@ -946,7 +964,8 @@ func constructLinodeInterfaceCreateOpts(createOpts []infrav1alpha2.LinodeInterfa
946
964
ipv4Addrs = []linodego.VPCInterfaceIPv4AddressCreateOptions {
947
965
{
948
966
Primary : ptr .To (true ),
949
- NAT1To1Address : ptr .To ("any" ),
967
+ NAT1To1Address : ptr .To ("auto" ),
968
+ Address : "auto" , // Default to auto-assigned address
950
969
},
951
970
}
952
971
}
@@ -1021,37 +1040,39 @@ func constructLinodeInterfaceCreateOpts(createOpts []infrav1alpha2.LinodeInterfa
1021
1040
return linodeInterfaces
1022
1041
}
1023
1042
1043
+ // for converting LinodeMachineSpec to linodego.InstanceCreateOptions. Any defaulting should be done in fillCreateConfig instead
1024
1044
func linodeMachineSpecToInstanceCreateConfig (machineSpec infrav1alpha2.LinodeMachineSpec , machineTags []string ) * linodego.InstanceCreateOptions {
1025
- interfaces := make ([]linodego.InstanceConfigInterfaceCreateOptions , len (machineSpec .Interfaces ))
1026
- for idx , iface := range machineSpec .Interfaces {
1027
- interfaces [idx ] = linodego.InstanceConfigInterfaceCreateOptions {
1028
- IPAMAddress : iface .IPAMAddress ,
1029
- Label : iface .Label ,
1030
- Purpose : iface .Purpose ,
1031
- Primary : iface .Primary ,
1032
- SubnetID : iface .SubnetID ,
1033
- IPRanges : iface .IPRanges ,
1034
- }
1035
- }
1036
- privateIP := false
1037
- if machineSpec .PrivateIP != nil {
1038
- privateIP = * machineSpec .PrivateIP
1039
- }
1040
1045
instCreateOpts := & linodego.InstanceCreateOptions {
1041
1046
Region : machineSpec .Region ,
1042
1047
Type : machineSpec .Type ,
1043
1048
AuthorizedKeys : machineSpec .AuthorizedKeys ,
1044
1049
AuthorizedUsers : machineSpec .AuthorizedUsers ,
1045
1050
RootPass : machineSpec .RootPass ,
1046
1051
Image : machineSpec .Image ,
1047
- Interfaces : interfaces ,
1048
- PrivateIP : privateIP ,
1049
1052
Tags : machineTags ,
1050
1053
FirewallID : machineSpec .FirewallID ,
1051
1054
DiskEncryption : linodego .InstanceDiskEncryption (machineSpec .DiskEncryption ),
1052
1055
}
1056
+
1057
+ if machineSpec .PrivateIP != nil {
1058
+ instCreateOpts .PrivateIP = * machineSpec .PrivateIP
1059
+ }
1060
+
1053
1061
if len (machineSpec .LinodeInterfaces ) > 0 {
1054
1062
instCreateOpts .LinodeInterfaces = constructLinodeInterfaceCreateOpts (machineSpec .LinodeInterfaces )
1063
+ } else {
1064
+ interfaces := make ([]linodego.InstanceConfigInterfaceCreateOptions , len (machineSpec .Interfaces ))
1065
+ for idx , iface := range machineSpec .Interfaces {
1066
+ interfaces [idx ] = linodego.InstanceConfigInterfaceCreateOptions {
1067
+ IPAMAddress : iface .IPAMAddress ,
1068
+ Label : iface .Label ,
1069
+ Purpose : iface .Purpose ,
1070
+ Primary : iface .Primary ,
1071
+ SubnetID : iface .SubnetID ,
1072
+ IPRanges : iface .IPRanges ,
1073
+ }
1074
+ }
1075
+ instCreateOpts .Interfaces = interfaces
1055
1076
}
1056
1077
1057
1078
return instCreateOpts
@@ -1478,6 +1499,14 @@ func configureFirewall(ctx context.Context, machineScope *scope.MachineScope, cr
1478
1499
}
1479
1500
1480
1501
createConfig .FirewallID = fwID
1502
+
1503
+ // If using LinodeInterfaces that needs to know about the firewall ID
1504
+ if machineScope .LinodeMachine .Spec .LinodeInterfaces != nil {
1505
+ for i := range createConfig .LinodeInterfaces {
1506
+ createConfig .LinodeInterfaces [i ].FirewallID = ptr .To (fwID )
1507
+ }
1508
+ }
1509
+
1481
1510
return nil
1482
1511
}
1483
1512
0 commit comments