Skip to content

Commit

Permalink
PR improvements in logging
Browse files Browse the repository at this point in the history
  • Loading branch information
carmal891 committed Oct 21, 2024
1 parent 36c6127 commit 719512a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions controllers/ibmpowervsmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,27 +212,26 @@ func (r *IBMPowerVSMachineReconciler) handleLoadBalancerPoolMemberConfiguration(
}

func (r *IBMPowerVSMachineReconciler) reconcileNormal(machineScope *scope.PowerVSMachineScope) (ctrl.Result, error) {
ctx := context.Background()
log := ctrl.LoggerFrom(ctx)
machineScope.Info("Reconciling IBMPowerVSMachine")
log := ctrl.LoggerFrom(context.Background())
log.V(3).Info("Reconciling IBMPowerVSMachine")

if !machineScope.Cluster.Status.InfrastructureReady {
machineScope.Info("Cluster infrastructure is not ready yet")
log.V(3).Info("Cluster infrastructure is not ready yet")
conditions.MarkFalse(machineScope.IBMPowerVSMachine, infrav1beta2.InstanceReadyCondition, infrav1beta2.WaitingForClusterInfrastructureReason, capiv1beta1.ConditionSeverityInfo, "")
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}

if machineScope.IBMPowerVSImage != nil {
if !machineScope.IBMPowerVSImage.Status.Ready {
machineScope.Info("IBMPowerVSImage is not ready yet")
log.V(3).Info("IBMPowerVSImage is not ready yet")
conditions.MarkFalse(machineScope.IBMPowerVSMachine, infrav1beta2.InstanceReadyCondition, infrav1beta2.WaitingForIBMPowerVSImageReason, capiv1beta1.ConditionSeverityInfo, "")
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}
}

// Make sure bootstrap data is available and populated.
if machineScope.Machine.Spec.Bootstrap.DataSecretName == nil {
machineScope.Info("Bootstrap data secret reference is not yet available")
log.V(3).Info("Bootstrap data secret reference is not yet available")
conditions.MarkFalse(machineScope.IBMPowerVSMachine, infrav1beta2.InstanceReadyCondition, infrav1beta2.WaitingForBootstrapDataReason, capiv1beta1.ConditionSeverityInfo, "")
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
}
Expand Down Expand Up @@ -282,7 +281,7 @@ func (r *IBMPowerVSMachineReconciler) reconcileNormal(machineScope *scope.PowerV
return ctrl.Result{}, nil
default:
machineScope.SetNotReady()
machineScope.Info("PowerVS instance state is undefined", "state", *instance.Status, "instance-id", machineScope.GetInstanceID())
log.V(3).Info("PowerVS instance state is undefined", "state", *instance.Status, "instance-id", machineScope.GetInstanceID())
conditions.MarkUnknown(machineScope.IBMPowerVSMachine, infrav1beta2.InstanceReadyCondition, "", "")
}
} else {
Expand All @@ -298,17 +297,18 @@ func (r *IBMPowerVSMachineReconciler) reconcileNormal(machineScope *scope.PowerV
return ctrl.Result{}, nil
}
// Register instance with load balancer
machineScope.Info("updating loadbalancer for machine", "name", machineScope.IBMPowerVSMachine.Name)
log.V(3).Info("updating loadbalancer for machine", "name", machineScope.IBMPowerVSMachine.Name)
internalIP := machineScope.GetMachineInternalIP()
if internalIP == "" {
machineScope.Info("Unable to update the LoadBalancer, Machine internal IP not yet set", "machineName", machineScope.IBMPowerVSMachine.Name)
log.V(3).Info("Unable to update the LoadBalancer, Machine internal IP not yet set", "machineName", machineScope.IBMPowerVSMachine.Name)
return ctrl.Result{}, nil
}

if util.IsControlPlaneMachine(machineScope.Machine) {
log.V(3).Info("skipping loadbalancer configuration as it is not control plane machine", "machineName", machineScope.IBMPowerVSMachine.Name)
log.V(3).Info("Configuring loadbalancer configuration for control plane machine", "machineName", machineScope.IBMPowerVSMachine.Name)
return r.handleLoadBalancerPoolMemberConfiguration(machineScope)
}
log.V(3).Info("skipping loadbalancer configuration as it is not control plane machine", "machineName", machineScope.IBMPowerVSMachine.Name)

return ctrl.Result{}, nil
}

0 comments on commit 719512a

Please sign in to comment.