@@ -81,16 +81,20 @@ func retryIfTransient(err error, logger logr.Logger) (ctrl.Result, error) {
81
81
}
82
82
83
83
func fillCreateConfig (createConfig * linodego.InstanceCreateOptions , machineScope * scope.MachineScope ) {
84
+ // This will only be empty if no interfaces or linodeInterfaces were specified in the LinodeMachine spec.
85
+ // In that case we default to legacy interfaces.
86
+ if createConfig .InterfaceGeneration == "" {
87
+ createConfig .InterfaceGeneration = linodego .GenerationLegacyConfig
88
+ }
84
89
if machineScope .LinodeMachine .Spec .PrivateIP != nil {
85
90
createConfig .PrivateIP = * machineScope .LinodeMachine .Spec .PrivateIP
86
91
} else {
87
- if machineScope . LinodeMachine . Spec . LinodeInterfaces == nil && machineScope . LinodeMachine . Spec .InterfaceGeneration == linodego .GenerationLegacyConfig {
92
+ if createConfig .InterfaceGeneration == linodego .GenerationLegacyConfig {
88
93
// Supported only for legacy network interfaces.
89
94
createConfig .PrivateIP = true
90
95
} else {
91
96
// Network Helper is not supported for the new network interfaces.
92
97
createConfig .NetworkHelper = nil
93
- createConfig .InterfaceGeneration = linodego .GenerationLinode
94
98
}
95
99
}
96
100
@@ -1040,18 +1044,19 @@ func constructLinodeInterfaceCreateOpts(createOpts []infrav1alpha2.LinodeInterfa
1040
1044
return linodeInterfaces
1041
1045
}
1042
1046
1043
- // for converting LinodeMachineSpec to linodego.InstanceCreateOptions. Any defaulting should be done in fillCreateConfig instead
1047
+ // For converting LinodeMachineSpec to linodego.InstanceCreateOptions. Any defaulting should be done in fillCreateConfig instead
1044
1048
func linodeMachineSpecToInstanceCreateConfig (machineSpec infrav1alpha2.LinodeMachineSpec , machineTags []string ) * linodego.InstanceCreateOptions {
1045
1049
instCreateOpts := & linodego.InstanceCreateOptions {
1046
- Region : machineSpec .Region ,
1047
- Type : machineSpec .Type ,
1048
- AuthorizedKeys : machineSpec .AuthorizedKeys ,
1049
- AuthorizedUsers : machineSpec .AuthorizedUsers ,
1050
- RootPass : machineSpec .RootPass ,
1051
- Image : machineSpec .Image ,
1052
- Tags : machineTags ,
1053
- FirewallID : machineSpec .FirewallID ,
1054
- DiskEncryption : linodego .InstanceDiskEncryption (machineSpec .DiskEncryption ),
1050
+ Region : machineSpec .Region ,
1051
+ Type : machineSpec .Type ,
1052
+ AuthorizedKeys : machineSpec .AuthorizedKeys ,
1053
+ AuthorizedUsers : machineSpec .AuthorizedUsers ,
1054
+ RootPass : machineSpec .RootPass ,
1055
+ Image : machineSpec .Image ,
1056
+ Tags : machineTags ,
1057
+ FirewallID : machineSpec .FirewallID ,
1058
+ InterfaceGeneration : machineSpec .InterfaceGeneration ,
1059
+ DiskEncryption : linodego .InstanceDiskEncryption (machineSpec .DiskEncryption ),
1055
1060
}
1056
1061
1057
1062
if machineSpec .PrivateIP != nil {
@@ -1060,6 +1065,8 @@ func linodeMachineSpecToInstanceCreateConfig(machineSpec infrav1alpha2.LinodeMac
1060
1065
1061
1066
if len (machineSpec .LinodeInterfaces ) > 0 {
1062
1067
instCreateOpts .LinodeInterfaces = constructLinodeInterfaceCreateOpts (machineSpec .LinodeInterfaces )
1068
+ // If LinodeInterfaces are specified, the InterfaceGeneration must be GenerationLinode
1069
+ instCreateOpts .InterfaceGeneration = linodego .GenerationLinode
1063
1070
} else if len (machineSpec .Interfaces ) > 0 {
1064
1071
interfaces := make ([]linodego.InstanceConfigInterfaceCreateOptions , len (machineSpec .Interfaces ))
1065
1072
for idx , iface := range machineSpec .Interfaces {
@@ -1073,6 +1080,8 @@ func linodeMachineSpecToInstanceCreateConfig(machineSpec infrav1alpha2.LinodeMac
1073
1080
}
1074
1081
}
1075
1082
instCreateOpts .Interfaces = interfaces
1083
+ // If Interfaces are specified, the InterfaceGeneration must be GenerationLegacyConfig
1084
+ instCreateOpts .InterfaceGeneration = linodego .GenerationLegacyConfig
1076
1085
}
1077
1086
1078
1087
return instCreateOpts
0 commit comments