Skip to content

Commit 99ca899

Browse files
committed
fix setting of interfaceGeneration
1 parent f7032ce commit 99ca899

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

internal/controller/linodemachine_controller.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,6 @@ func (r *LinodeMachineReconciler) reconcilePreflightMetadataSupportConfigure(ctx
553553
}
554554

555555
func (r *LinodeMachineReconciler) reconcilePreflightCreate(ctx context.Context, logger logr.Logger, machineScope *scope.MachineScope) (ctrl.Result, error) {
556-
// default to legacy interface generation if not set for now
557-
if machineScope.LinodeMachine.Spec.InterfaceGeneration == "" {
558-
machineScope.LinodeMachine.Spec.InterfaceGeneration = linodego.GenerationLegacyConfig
559-
}
560556
// get the bootstrap data for the Linode instance and set it for create config
561557
createOpts, err := newCreateConfig(ctx, machineScope, r.GzipCompressionEnabled, logger)
562558
if err != nil {

internal/controller/linodemachine_controller_helpers.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,23 @@ func retryIfTransient(err error, logger logr.Logger) (ctrl.Result, error) {
8181
}
8282

8383
func fillCreateConfig(createConfig *linodego.InstanceCreateOptions, machineScope *scope.MachineScope) {
84+
// default to legacy interface generation if not set for now unless linodeInterfaces are defined
85+
if machineScope.LinodeMachine.Spec.InterfaceGeneration == "" {
86+
if machineScope.LinodeMachine.Spec.LinodeInterfaces != nil {
87+
createConfig.InterfaceGeneration = linodego.GenerationLinode
88+
} else {
89+
createConfig.InterfaceGeneration = linodego.GenerationLegacyConfig
90+
}
91+
}
8492
if machineScope.LinodeMachine.Spec.PrivateIP != nil {
8593
createConfig.PrivateIP = *machineScope.LinodeMachine.Spec.PrivateIP
8694
} else {
87-
if machineScope.LinodeMachine.Spec.LinodeInterfaces == nil && machineScope.LinodeMachine.Spec.InterfaceGeneration == linodego.GenerationLegacyConfig {
95+
if createConfig.InterfaceGeneration == linodego.GenerationLegacyConfig {
8896
// Supported only for legacy network interfaces.
8997
createConfig.PrivateIP = true
9098
} else {
9199
// Network Helper is not supported for the new network interfaces.
92100
createConfig.NetworkHelper = nil
93-
createConfig.InterfaceGeneration = linodego.GenerationLinode
94101
}
95102
}
96103

@@ -1043,15 +1050,16 @@ func constructLinodeInterfaceCreateOpts(createOpts []infrav1alpha2.LinodeInterfa
10431050
// for converting LinodeMachineSpec to linodego.InstanceCreateOptions. Any defaulting should be done in fillCreateConfig instead
10441051
func linodeMachineSpecToInstanceCreateConfig(machineSpec infrav1alpha2.LinodeMachineSpec, machineTags []string) *linodego.InstanceCreateOptions {
10451052
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),
1053+
Region: machineSpec.Region,
1054+
Type: machineSpec.Type,
1055+
AuthorizedKeys: machineSpec.AuthorizedKeys,
1056+
AuthorizedUsers: machineSpec.AuthorizedUsers,
1057+
RootPass: machineSpec.RootPass,
1058+
Image: machineSpec.Image,
1059+
Tags: machineTags,
1060+
FirewallID: machineSpec.FirewallID,
1061+
InterfaceGeneration: machineSpec.InterfaceGeneration,
1062+
DiskEncryption: linodego.InstanceDiskEncryption(machineSpec.DiskEncryption),
10551063
}
10561064

10571065
if machineSpec.PrivateIP != nil {

0 commit comments

Comments
 (0)