@@ -30,6 +30,7 @@ import (
3030 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3131 "k8s.io/client-go/tools/record"
3232 "k8s.io/klog/v2"
33+ clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3334 "sigs.k8s.io/cluster-api/util/conditions"
3435 ctrl "sigs.k8s.io/controller-runtime"
3536 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -38,7 +39,6 @@ import (
3839
3940 vmwarev1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/vmware/v1beta1"
4041 infrautilv1 "sigs.k8s.io/cluster-api-provider-vsphere/pkg/util"
41- clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
4242)
4343
4444const (
@@ -72,6 +72,7 @@ func (r *VirtualMachineGroupReconciler) Reconcile(ctx context.Context, req ctrl.
7272 }
7373
7474 log = log .WithValues ("Cluster" , klog .KObj (cluster ))
75+
7576 // If Cluster is deleted, just return as VirtualMachineGroup will be GCed and no extra processing needed.
7677 if ! cluster .DeletionTimestamp .IsZero () {
7778 return reconcile.Result {}, nil
@@ -86,10 +87,9 @@ func (r *VirtualMachineGroupReconciler) Reconcile(ctx context.Context, req ctrl.
8687
8788 // Continue with the main logic.
8889 return r .createOrUpdateVMG (ctx , cluster )
89-
9090}
9191
92- // createOrUpdateVMG Create or Update VirtualMachineGroup
92+ // createOrUpdateVMG Create or Update VirtualMachineGroup.
9393func (r * VirtualMachineGroupReconciler ) createOrUpdateVMG (ctx context.Context , cluster * clusterv1.Cluster ) (_ reconcile.Result , reterr error ) {
9494 log := ctrl .LoggerFrom (ctx )
9595
@@ -228,8 +228,7 @@ func (r *VirtualMachineGroupReconciler) createOrUpdateVMG(ctx context.Context, c
228228 return reconcile.Result {}, err
229229}
230230
231- // getExpectedVSphereMachines returns the total number of replicas across all
232- // MachineDeployments belonging to the Cluster
231+ // MachineDeployments belonging to the Cluster.
233232func getExpectedVSphereMachines (ctx context.Context , kubeClient client.Client , cluster * clusterv1.Cluster ) (int32 , error ) {
234233 var mdList clusterv1.MachineDeploymentList
235234 if err := kubeClient .List (
@@ -329,8 +328,8 @@ func GenerateVMGPlacementAnnotations(ctx context.Context, vmg *vmoprv1.VirtualMa
329328 return annotations , nil
330329}
331330
332- // Duplicated this logic from pkg/services/vmoperator/vmopmachine.go
333331// GenerateVirtualMachineName generates the name of a VirtualMachine based on the naming strategy.
332+ // Duplicated this logic from pkg/services/vmoperator/vmopmachine.go.
334333func GenerateVirtualMachineName (machineName string , namingStrategy * vmwarev1.VirtualMachineNamingStrategy ) (string , error ) {
335334 // Per default the name of the VirtualMachine should be equal to the Machine name (this is the same as "{{ .machine.name }}")
336335 if namingStrategy == nil || namingStrategy .Template == nil {
0 commit comments