Skip to content

Commit

Permalink
review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sbueringer committed Sep 27, 2022
1 parent 4bdba42 commit ec73efc
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions internal/controllers/topology/cluster/desired_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)),
Expand All @@ -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,
Expand Down

0 comments on commit ec73efc

Please sign in to comment.