Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,16 +1006,33 @@ func calculateExpectedMachinePoolMachineCount(ctx context.Context, c client.Clie
client.MatchingLabels{clusterv1.ClusterNameLabel: workloadClusterName},
); err == nil {
for _, mp := range machinePoolList.Items {
ref := &corev1.ObjectReference{}
err = util.UnstructuredUnmarshalField(&mp, ref, "spec", "template", "spec", "infrastructureRef")
if err != nil && !errors.Is(err, util.ErrUnstructuredFieldNotFound) {
return 0, err
}
var infraMachinePool *unstructured.Unstructured

// Fallback to v1beta1's objectReference
if clusterv1.GroupVersion.Version == "v1beta1" {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if clusterv1.GroupVersion.Version == "v1beta1" {
if coreCAPIStorageVersion == "v1beta1" {

Shouldn't this be like this instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoop, yeah ! good catch...

ref := &corev1.ObjectReference{}
err = util.UnstructuredUnmarshalField(&mp, ref, "spec", "template", "spec", "infrastructureRef")
if err != nil && !errors.Is(err, util.ErrUnstructuredFieldNotFound) {
return 0, err
}

infraMachinePool, err := external.Get(ctx, c, ref)
if err != nil {
return 0, err
infraMachinePool, err = external.Get(ctx, c, ref)
if err != nil {
return 0, err
}
} else {
ref := clusterv1.ContractVersionedObjectReference{}
err = util.UnstructuredUnmarshalField(&mp, &ref, "spec", "template", "spec", "infrastructureRef")
if err != nil && !errors.Is(err, util.ErrUnstructuredFieldNotFound) {
return 0, err
}

infraMachinePool, err = external.GetObjectFromContractVersionedRef(ctx, c, ref, mp.GetNamespace())
if err != nil {
return 0, err
}
}

// Check if the InfraMachinePool has an infrastructureMachineKind field. If it does not, we should skip checking for MachinePool machines.
err = util.UnstructuredUnmarshalField(infraMachinePool, ptr.To(""), "status", "infrastructureMachineKind")
if err != nil && !errors.Is(err, util.ErrUnstructuredFieldNotFound) {
Expand Down
Loading