Skip to content

Commit

Permalink
Reduce ws-manager-mk2 logs verbosity (gitpod-io#18626)
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf authored Sep 4, 2023
1 parent 63c0c26 commit 7909192
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion components/ws-manager-mk2/controllers/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func (m *controllerMetrics) recordWorkspaceStartupTime(log *logr.Logger, ws *wor
}

duration := time.Since(ws.CreationTimestamp.Time)
log.Info("workspace startup time", "ws", ws.Name, "duration", duration)
hist.Observe(float64(duration.Seconds()))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (r *TimeoutReconciler) Reconcile(ctx context.Context, req ctrl.Request) (re
}

// Workspace timed out, set Timeout condition.
log.Info("Workspace timed out", "reason", timedout)
log.V(2).Info("Workspace timed out", "reason", timedout)
if err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
err := r.Get(ctx, types.NamespacedName{Name: workspace.Name, Namespace: workspace.Namespace}, &workspace)
if err != nil {
Expand Down
15 changes: 7 additions & 8 deletions components/ws-manager-mk2/controllers/workspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -107,7 +108,7 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
workspace.Status.Conditions = []metav1.Condition{}
}

log.Info("reconciling workspace", "workspace", req.NamespacedName, "phase", workspace.Status.Phase)
log.V(2).Info("reconciling workspace", "workspace", req.NamespacedName, "phase", workspace.Status.Phase)

var workspacePods corev1.PodList
err := r.List(ctx, &workspacePods, client.InNamespace(req.Namespace), client.MatchingFields{wsOwnerKey: req.Name})
Expand Down Expand Up @@ -136,7 +137,11 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
if err = scrubber.Default.Struct(scrubbedStatus); err != nil {
log.Error(err, "failed to scrub workspace status")
}
log.Info("updating workspace status", "status", scrubbedStatus, "podStatus", scrubbedPodStatus)

if !equality.Semantic.DeepDerivative(oldStatus, workspace.Status) {
log.Info("updating workspace status", "status", scrubbedStatus, "podStatus", scrubbedPodStatus)
}

err = r.Status().Update(ctx, &workspace)
if err != nil {
return errorResultLogConflict(log, fmt.Errorf("failed to update workspace status: %w", err))
Expand Down Expand Up @@ -178,11 +183,9 @@ func (r *WorkspaceReconciler) actOnStatus(ctx context.Context, workspace *worksp
return ctrl.Result{}, err
}

log.Info("creating workspace Pod for Workspace")
err = r.Create(ctx, pod)
if errors.IsAlreadyExists(err) {
// pod exists, we're good
log.Info("Workspace Pod already exists")
} else if err != nil {
log.Error(err, "unable to create Pod for Workspace", "pod", pod)
return ctrl.Result{Requeue: true}, err
Expand Down Expand Up @@ -390,9 +393,6 @@ func (r *WorkspaceReconciler) emitPhaseEvents(ctx context.Context, ws *workspace
}

func (r *WorkspaceReconciler) deleteWorkspacePod(ctx context.Context, pod *corev1.Pod, reason string) (ctrl.Result, error) {
log := log.FromContext(ctx).WithValues("pod", pod.Name, "reason", reason)
log.Info("deleting workspace pod")

// Workspace was requested to be deleted, propagate by deleting the Pod.
// The Pod deletion will then trigger workspace disposal steps.
err := r.Client.Delete(ctx, pod)
Expand Down Expand Up @@ -469,7 +469,6 @@ func (r *WorkspaceReconciler) deleteSecret(ctx context.Context, name, namespace
// behaviour as returning an error.
func errorResultLogConflict(log logr.Logger, err error) (ctrl.Result, error) {
if errors.IsConflict(err) {
log.Info("conflict error, requeuing", "error", err.Error())
return ctrl.Result{RequeueAfter: 100 * time.Millisecond}, nil
} else {
return ctrl.Result{}, err
Expand Down

0 comments on commit 7909192

Please sign in to comment.