Skip to content
Merged
Changes from all commits
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
8 changes: 4 additions & 4 deletions controllers/openstackmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger
if err != nil {
return ctrl.Result{}, err
}

logger.Info("Creating Machine")
Copy link
Contributor

Choose a reason for hiding this comment

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

Not good message is true. I suggest to update to 'Reconciling Machine create started'
in contrast to L370 logger.Info("Reconciled Machine create successfully").

logger.Info("Reconciling Machine create started")

clusterName := fmt.Sprintf("%s-%s", cluster.ObjectMeta.Namespace, cluster.Name)

Expand All @@ -307,7 +306,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger
return ctrl.Result{}, err
}

instance, err := r.getOrCreate(computeService, machine, openStackMachine, cluster, openStackCluster, userData)
instance, err := r.getOrCreate(computeService, machine, openStackMachine, cluster, openStackCluster, userData, logger)
if err != nil {
handleUpdateMachineError(logger, openStackMachine, errors.Errorf("OpenStack instance cannot be created: %v", err))
return ctrl.Result{}, err
Expand Down Expand Up @@ -371,14 +370,15 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, logger
return ctrl.Result{}, nil
}

func (r *OpenStackMachineReconciler) getOrCreate(computeService *compute.Service, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, cluster *clusterv1.Cluster, openStackCluster *infrav1.OpenStackCluster, userData string) (*infrav1.Instance, error) {
func (r *OpenStackMachineReconciler) getOrCreate(computeService *compute.Service, machine *clusterv1.Machine, openStackMachine *infrav1.OpenStackMachine, cluster *clusterv1.Cluster, openStackCluster *infrav1.OpenStackCluster, userData string, logger logr.Logger) (*infrav1.Instance, error) {

instance, err := computeService.InstanceExists(openStackMachine.Name)
if err != nil {
return nil, err
}

if instance == nil {
logger.Info("Machine not exist, Creating Machine", "Machine", openStackMachine.Name)
instance, err = computeService.InstanceCreate(cluster.Name, machine, openStackMachine, openStackCluster, userData)
if err != nil {
return nil, errors.Errorf("error creating Openstack instance: %v", err)
Expand Down