From ec73efc137a9aeaa31752f900c2e73ca92e02cb3 Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Tue, 27 Sep 2022 13:15:49 +0200 Subject: [PATCH] review fix --- .../topology/cluster/desired_state.go | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/internal/controllers/topology/cluster/desired_state.go b/internal/controllers/topology/cluster/desired_state.go index aa0e7ae4b307..733e00be25c4 100644 --- a/internal/controllers/topology/cluster/desired_state.go +++ b/internal/controllers/topology/cluster/desired_state.go @@ -506,7 +506,7 @@ func computeMachineDeployments(ctx context.Context, s *scope.Scope, desiredContr for _, mdTopology := range s.Blueprint.Topology.Workers.MachineDeployments { desiredMachineDeployment, err := computeMachineDeployment(ctx, s, desiredControlPlaneState, mdTopology) if err != nil { - return nil, err + return nil, errors.Wrapf(err, "failed to compute MachineDepoyment for topology %q", mdTopology.Name) } machineDeploymentsStateMap[mdTopology.Name] = desiredMachineDeployment } @@ -582,11 +582,19 @@ func computeMachineDeployment(_ context.Context, s *scope.Scope, desiredControlP } // Compute the MachineDeployment object. - gv := clusterv1.GroupVersion + desiredBootstrapTemplateRef, err := calculateRefDesiredAPIVersion(currentBootstrapTemplateRef, desiredMachineDeployment.BootstrapTemplate) + if err != nil { + return nil, errors.Wrap(err, "failed to calculate desired bootstrap template ref") + } + desiredInfraMachineTemplateRef, err := calculateRefDesiredAPIVersion(currentInfraMachineTemplateRef, desiredMachineDeployment.InfrastructureMachineTemplate) + if err != nil { + return nil, errors.Wrap(err, "failed to calculate desired infrastructure machine template ref") + } + desiredMachineDeploymentObj := &clusterv1.MachineDeployment{ TypeMeta: metav1.TypeMeta{ - Kind: gv.WithKind("MachineDeployment").Kind, - APIVersion: gv.String(), + Kind: clusterv1.GroupVersion.WithKind("MachineDeployment").Kind, + APIVersion: clusterv1.GroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ Name: names.SimpleNameGenerator.GenerateName(fmt.Sprintf("%s-%s-", s.Current.Cluster.Name, machineDeploymentTopology.Name)), @@ -602,8 +610,8 @@ func computeMachineDeployment(_ context.Context, s *scope.Scope, desiredControlP Spec: clusterv1.MachineSpec{ ClusterName: s.Current.Cluster.Name, Version: pointer.String(version), - Bootstrap: clusterv1.Bootstrap{ConfigRef: contract.ObjToRef(desiredMachineDeployment.BootstrapTemplate)}, - InfrastructureRef: *contract.ObjToRef(desiredMachineDeployment.InfrastructureMachineTemplate), + Bootstrap: clusterv1.Bootstrap{ConfigRef: desiredBootstrapTemplateRef}, + InfrastructureRef: *desiredInfraMachineTemplateRef, FailureDomain: machineDeploymentTopology.FailureDomain, NodeDrainTimeout: machineDeploymentTopology.NodeDrainTimeout, NodeVolumeDetachTimeout: machineDeploymentTopology.NodeVolumeDetachTimeout,