-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from Abirdcfly/log
fix: use right debug log level
- Loading branch information
Showing
5 changed files
with
24 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,19 +75,19 @@ type ComponentPlanReconciler struct { | |
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *ComponentPlanReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
logger := log.FromContext(ctx) | ||
logger.V(4).Info("Reconciling ComponentPlan") | ||
logger.V(1).Info("Reconciling ComponentPlan") | ||
|
||
// Fetch the ComponentPlan instance | ||
plan := &corev1alpha1.ComponentPlan{} | ||
err := r.Get(ctx, req.NamespacedName, plan) | ||
if err != nil { | ||
// There's no need to requeue if the resource no longer exists. | ||
// Otherwise, we'll be requeued implicitly because we return an error. | ||
logger.V(4).Info("Failed to get ComponentPlan") | ||
logger.V(1).Info("Failed to get ComponentPlan") | ||
return reconcile.Result{}, utils.IgnoreNotFound(err) | ||
} | ||
logger = logger.WithValues("Generation", plan.GetGeneration(), "ObservedGeneration", plan.Status.ObservedGeneration) | ||
logger.V(4).Info("Get ComponentPlan instance") | ||
logger.V(1).Info("Get ComponentPlan instance") | ||
|
||
// Get watched component | ||
component := &corev1alpha1.Component{} | ||
|
@@ -104,7 +104,7 @@ func (r *ComponentPlanReconciler) Reconcile(ctx context.Context, req ctrl.Reques | |
logger.Info("Failed to get Component.Status.RepositoryRef, wait 1 minute to retry", "obj", klog.KObj(component)) | ||
return reconcile.Result{RequeueAfter: time.Minute}, nil | ||
} | ||
logger.V(4).Info("Get Component instance", "Component", klog.KObj(component)) | ||
logger.V(1).Info("Get Component instance", "Component", klog.KObj(component)) | ||
|
||
if plan.Labels[corev1alpha1.ComponentPlanReleaseNameLabel] != plan.Spec.Name { | ||
if plan.GetLabels() == nil { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ type SubscriptionReconciler struct { | |
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
logger := log.FromContext(ctx) | ||
logger.V(4).Info("Reconciling Subscription") | ||
logger.V(1).Info("Reconciling Subscription") | ||
|
||
// Fetch the Subscription instance | ||
sub := &corev1alpha1.Subscription{} | ||
|
@@ -82,7 +82,7 @@ func (r *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request | |
logger.Error(err, "Failed to get Subscription") | ||
return reconcile.Result{}, utils.IgnoreNotFound(err) | ||
} | ||
logger.V(4).Info("Get Subscription instance") | ||
logger.V(1).Info("Get Subscription instance") | ||
|
||
// Get watched component | ||
component := &corev1alpha1.Component{} | ||
|
@@ -91,7 +91,7 @@ func (r *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request | |
logger.Error(err, "Failed to get Component", "Component.Namespace", sub.Spec.ComponentRef.Namespace, "Component.Name", sub.Spec.ComponentRef.Name) | ||
return reconcile.Result{}, utils.IgnoreNotFound(err) | ||
} | ||
logger.V(4).Info("Get Component instance", "Component.Namespace", component.Namespace, "Component.Name", component.Name) | ||
logger.V(1).Info("Get Component instance", "Component.Namespace", component.Namespace, "Component.Name", component.Name) | ||
|
||
// Update spec.repositoryRef | ||
if sub.Spec.RepositoryRef == nil || sub.Spec.RepositoryRef.Name == "" { | ||
|
@@ -109,7 +109,7 @@ func (r *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request | |
logger.Error(err, "Failed to patch subscription.spec.RepositoryRef", "Repository.Namespace", newSub.Spec.RepositoryRef.Namespace, "Repository.Name", newSub.Spec.RepositoryRef.Name) | ||
return ctrl.Result{Requeue: true}, r.PatchCondition(ctx, sub, corev1alpha1.SubscriptionReconcileError(corev1alpha1.SubscriptionTypeReady, err)) | ||
} | ||
logger.V(4).Info("Patch subscription.Spec.RepositoryRef") | ||
logger.V(1).Info("Patch subscription.Spec.RepositoryRef") | ||
return ctrl.Result{Requeue: true}, nil | ||
} | ||
|
||
|
@@ -118,7 +118,7 @@ func (r *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request | |
logger.Error(err, "Failed to update subscription status repositoryHealth", "RepositoryNamespace", sub.Spec.RepositoryRef.Namespace, "RepositoryName", sub.Spec.RepositoryRef.Name) | ||
return ctrl.Result{Requeue: true}, r.PatchCondition(ctx, sub, corev1alpha1.SubscriptionReconcileError(corev1alpha1.SubscriptionTypeReady, err)) | ||
} | ||
logger.V(4).Info("patch subscription status repositoryHealth") | ||
logger.V(1).Info("patch subscription status repositoryHealth") | ||
|
||
// compare component latest version with installed | ||
var latestVersionFetch, latestVersionInstalled corev1alpha1.ComponentVersion | ||
|
@@ -129,11 +129,11 @@ func (r *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request | |
logger.Info(msg) | ||
return ctrl.Result{}, r.PatchCondition(ctx, sub, corev1alpha1.SubscriptionReconcileSuccess(corev1alpha1.SubscriptionTypeReady).WithMessage(msg)) | ||
} | ||
logger.V(4).Info("get component latest fetch version") | ||
logger.V(1).Info("get component latest fetch version") | ||
if plans := sub.Status.Installed; len(plans) > 0 { | ||
latestVersionInstalled = plans[0].InstalledVersion | ||
} | ||
logger.V(4).Info("get component latest installed version") | ||
logger.V(1).Info("get component latest installed version") | ||
if latestVersionFetch.Equal(&latestVersionInstalled) { | ||
msg := "component latest version is the same as installed, skip" | ||
logger.Info(msg) | ||
|
@@ -148,14 +148,14 @@ func (r *SubscriptionReconciler) Reconcile(ctx context.Context, req ctrl.Request | |
return ctrl.Result{Requeue: true, RequeueAfter: 3 * time.Second}, r.PatchCondition(ctx, sub, corev1alpha1.SubscriptionReconcileError(corev1alpha1.SubscriptionTypePlanSynce, err)) | ||
} | ||
r.Recorder.Eventf(sub, v1.EventTypeNormal, "Success", "componentPlan %s create successfully", componentPlanName) | ||
logger.V(4).Info("create component plan") | ||
logger.V(1).Info("create component plan") | ||
|
||
// update status.Installed | ||
if err = r.UpdateStatusInstalled(ctx, logger, sub, latestVersionFetch); err != nil { | ||
logger.Error(err, "Failed to update subscription status installed") | ||
return ctrl.Result{Requeue: true, RequeueAfter: 3 * time.Second}, r.PatchCondition(ctx, sub, corev1alpha1.SubscriptionReconcileError(corev1alpha1.SubscriptionTypeReady, err)) | ||
} | ||
logger.V(4).Info("update subscription status installed") | ||
logger.V(1).Info("update subscription status installed") | ||
return ctrl.Result{}, r.PatchCondition(ctx, sub, corev1alpha1.SubscriptionAvailable()) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters