Skip to content

Commit 4bff8cf

Browse files
Merge pull request #370 from damdo/fix-falsely-passing-units
NO-JIRA: machine_sync: assorted fixes
2 parents 2a0af92 + f8013af commit 4bff8cf

File tree

3 files changed

+50
-46
lines changed

3 files changed

+50
-46
lines changed

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The repository also includes:
7272
### Running Tests
7373
```bash
7474
make unit # All unit tests
75-
make unit TEST_PACKAGES="./pkg/controllers/machinesync/..." # Specific package
75+
make unit TEST_DIRS="./pkg/controllers/machinesync/..." # Specific package directories/dirs
7676
./hack/test.sh "./pkg/..." 10m # With timeout
7777
```
7878
#### Default ginkgo arguments

pkg/controllers/machinesync/machine_sync_controller.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,10 @@ func (r *MachineSyncReconciler) convertMAPIMachineOwnerReferencesToCAPI(ctx cont
917917
func (r *MachineSyncReconciler) convertCAPIMachineOwnerReferencesToMAPI(ctx context.Context, capiMachine *clusterv1.Machine) ([]metav1.OwnerReference, error) {
918918
mapiOwnerReferences := []metav1.OwnerReference{}
919919

920+
if capiMachine.OwnerReferences == nil {
921+
return nil, nil
922+
}
923+
920924
if len(capiMachine.OwnerReferences) == 0 {
921925
return mapiOwnerReferences, nil
922926
}
@@ -964,7 +968,7 @@ func (r *MachineSyncReconciler) convertCAPIMachineOwnerReferencesToMAPI(ctx cont
964968
}
965969

966970
// MAPI doesn't have a cluster, so we don't need to add an owner reference.
967-
return mapiOwnerReferences, nil
971+
return nil, nil
968972
default:
969973
return nil, field.Invalid(field.NewPath("metadata", "ownerReferences"), capiMachine.OwnerReferences, errUnsuportedOwnerKindForConversion.Error())
970974
}
@@ -1296,7 +1300,7 @@ func compareMAPIMachines(a, b *machinev1beta1.Machine) (map[string]any, error) {
12961300
return nil, fmt.Errorf("unable to parse first Machine API machine set providerSpec: %w", err)
12971301
}
12981302

1299-
ps2, err := mapi2capi.AWSProviderSpecFromRawExtension(a.Spec.ProviderSpec.Value)
1303+
ps2, err := mapi2capi.AWSProviderSpecFromRawExtension(b.Spec.ProviderSpec.Value)
13001304
if err != nil {
13011305
return nil, fmt.Errorf("unable to parse second Machine API machine set providerSpec: %w", err)
13021306
}

0 commit comments

Comments
 (0)