Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 improve logging for the machine provisioning workflow #6993

Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions internal/controllers/machine/machine_controller_noderef.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (r *Reconciler) reconcileNode(ctx context.Context, cluster *clusterv1.Clust

// Check that the Machine has a valid ProviderID.
if machine.Spec.ProviderID == nil || *machine.Spec.ProviderID == "" {
log.Info("Cannot reconcile Machine's Node, no valid ProviderID yet")
log.Info("Waiting for infrastructure provider to report spec.providerID", util.LowerCamelCase(machine.Spec.InfrastructureRef.Kind), klog.KRef(machine.Spec.InfrastructureRef.Namespace, machine.Spec.InfrastructureRef.Name))
conditions.MarkFalse(machine, clusterv1.MachineNodeHealthyCondition, clusterv1.WaitingForNodeRefReason, clusterv1.ConditionSeverityInfo, "")
return ctrl.Result{}, nil
}
Expand Down Expand Up @@ -88,7 +88,7 @@ func (r *Reconciler) reconcileNode(ctx context.Context, cluster *clusterv1.Clust
Name: node.Name,
UID: node.UID,
}
log.Info("Set Machine's NodeRef", "noderef", machine.Status.NodeRef.Name)
log.Info("Infrastructure provider reporting spec.providerID, Kubernetes node is now available", util.LowerCamelCase(machine.Spec.InfrastructureRef.Kind), klog.KRef(machine.Spec.InfrastructureRef.Namespace, machine.Spec.InfrastructureRef.Name), "providerID", providerID, "node", klog.KRef("", machine.Status.NodeRef.Name))
r.recorder.Event(machine, corev1.EventTypeNormal, "SuccessfulSetNodeRef", machine.Status.NodeRef.Name)
}

Expand Down
11 changes: 8 additions & 3 deletions internal/controllers/machine/machine_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, cluster *clusterv1.

// If the bootstrap provider is not ready, requeue.
if !ready {
log.Info("Bootstrap provider is not ready, requeuing")
log.Info("Waiting for bootstrap provider to generate data secret and report status.ready", util.LowerCamelCaseKind(bootstrapConfig), klog.KObj(bootstrapConfig))
return ctrl.Result{RequeueAfter: externalReadyWait}, nil
}

Expand All @@ -230,8 +230,10 @@ func (r *Reconciler) reconcileBootstrap(ctx context.Context, cluster *clusterv1.
} else if secretName == "" {
return ctrl.Result{}, errors.Errorf("retrieved empty dataSecretName from bootstrap provider for Machine %q in namespace %q", m.Name, m.Namespace)
}

m.Spec.Bootstrap.DataSecretName = pointer.StringPtr(secretName)
if !m.Status.BootstrapReady {
log.Info("Bootstrap provider generated data secret and reports status.ready", util.LowerCamelCaseKind(bootstrapConfig), klog.KObj(bootstrapConfig), "secret", klog.KRef(m.Namespace, secretName))
}
m.Status.BootstrapReady = true
return ctrl.Result{}, nil
}
Expand Down Expand Up @@ -271,6 +273,9 @@ func (r *Reconciler) reconcileInfrastructure(ctx context.Context, cluster *clust
if err != nil {
return ctrl.Result{}, err
}
if ready && !m.Status.InfrastructureReady {
log.Info("Infrastructure provider has completed machine infrastructure provisioning and reports status.ready", util.LowerCamelCaseKind(infraConfig), klog.KObj(infraConfig))
}
m.Status.InfrastructureReady = ready

// Report a summary of current status of the infrastructure object defined for this machine.
Expand All @@ -281,7 +286,7 @@ func (r *Reconciler) reconcileInfrastructure(ctx context.Context, cluster *clust

// If the infrastructure provider is not ready, return early.
if !ready {
log.Info("Infrastructure provider is not ready, requeuing")
log.Info("Waiting for infrastructure provider to create machine infrastructure and report status.ready", util.LowerCamelCaseKind(infraConfig), klog.KObj(infraConfig))
return ctrl.Result{RequeueAfter: externalReadyWait}, nil
}

Expand Down
11 changes: 8 additions & 3 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,14 @@ func IsNil(i interface{}) bool {
// LowerCamelCaseKind mirrors how controller runtime formats the object's kind when used as a logging key
// for the object being reconciled.
func LowerCamelCaseKind(obj runtime.Object) string {
kind := obj.GetObjectKind().GroupVersionKind().Kind
if kind != "" {
return strings.ToLower(kind[:1]) + kind[1:]
return LowerCamelCase(obj.GetObjectKind().GroupVersionKind().Kind)
}

// LowerCamelCase mirrors how controller runtime formats the object's kind when used as a logging key
// for the object being reconciled.
func LowerCamelCase(s string) string {
if s != "" {
return strings.ToLower(s[:1]) + s[1:]
}
return ""
}