Skip to content

Commit

Permalink
migrating openstackmachine_controller.go to structured logging
Browse files Browse the repository at this point in the history
  • Loading branch information
asarunova authored Jul 25, 2023
1 parent fac17a8 commit 88ecd6b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions controllers/openstackmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,12 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope

switch instanceStatus.State() {
case infrav1.InstanceStateActive:
scope.Logger().Info("Machine instance state is ACTIVE", "instance-id", instanceStatus.ID())
scope.Logger().Info("Machine instance state is ACTIVE", "id", instanceStatus.ID())
conditions.MarkTrue(openStackMachine, infrav1.InstanceReadyCondition)
openStackMachine.Status.Ready = true
case infrav1.InstanceStateError:
// Error is unexpected, thus we report error and never retry
scope.Logger().Info("Machine instance state is ERROR", "instance-id", instanceStatus.ID())
scope.Logger().Info("Machine instance state is ERROR", "id", instanceStatus.ID())
err = fmt.Errorf("instance state %q is unexpected", instanceStatus.State())
openStackMachine.SetFailure(capierrors.UpdateMachineError, err)
conditions.MarkFalse(openStackMachine, infrav1.InstanceReadyCondition, infrav1.InstanceStateErrorReason, clusterv1.ConditionSeverityError, "")
Expand All @@ -377,7 +377,7 @@ func (r *OpenStackMachineReconciler) reconcileNormal(ctx context.Context, scope
default:
// The other state is normal (for example, migrating, shutoff) but we don't want to proceed until it's ACTIVE
// due to potential conflict or unexpected actions
scope.Logger().Info("Waiting for instance to become ACTIVE", "instance-id", instanceStatus.ID(), "status", instanceStatus.State())
scope.Logger().Info("Waiting for instance to become ACTIVE", "id", instanceStatus.ID(), "status", instanceStatus.State())
conditions.MarkUnknown(openStackMachine, infrav1.InstanceReadyCondition, infrav1.InstanceNotReadyReason, "Instance state is not handled: %s", instanceStatus.State())
return ctrl.Result{RequeueAfter: waitForInstanceBecomeActiveToReconcile}, nil
}
Expand Down Expand Up @@ -433,7 +433,7 @@ func (r *OpenStackMachineReconciler) getOrCreate(logger logr.Logger, cluster *cl

if instanceStatus == nil {
instanceSpec := machineToInstanceSpec(openStackCluster, machine, openStackMachine, userData)
logger.Info("Machine not exist, Creating Machine", "Machine", openStackMachine.Name)
logger.Info("Machine does not exist, creating Machine", "name", openStackMachine.Name)
instanceStatus, err = computeService.CreateInstance(openStackMachine, openStackCluster, instanceSpec, cluster.Name, false)
if err != nil {
conditions.MarkFalse(openStackMachine, infrav1.InstanceReadyCondition, infrav1.InstanceCreateFailedReason, clusterv1.ConditionSeverityError, err.Error())
Expand Down

0 comments on commit 88ecd6b

Please sign in to comment.