Skip to content

Commit

Permalink
Document the logging fields that are commonly used in the operator lo…
Browse files Browse the repository at this point in the history
…gging statements (#1898)
  • Loading branch information
johscheuer authored Dec 5, 2023
1 parent 26600ea commit 149ab80
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 2 additions & 4 deletions controllers/add_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ func (a addPods) reconcile(ctx context.Context, r *FoundationDBClusterReconciler
}

// Ignore the is not found error, as we are checking here if we should create Pods.
if err != nil {
if !k8serrors.IsNotFound(err) {
return &requeue{curError: err}
}
if err != nil && !k8serrors.IsNotFound(err) {
return &requeue{curError: err}
}

// If this process group is marked for removal, we normally don't want to spin it back up
Expand Down
2 changes: 1 addition & 1 deletion controllers/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (r *FoundationDBClusterReconciler) Reconcile(ctx context.Context, request c

if requeue.delayedRequeue {
clusterLog.Info("Delaying requeue for sub-reconciler",
"subReconciler", fmt.Sprintf("%T", subReconciler),
"reconciler", fmt.Sprintf("%T", subReconciler),
"message", requeue.message,
"error", requeue.curError)
delayedRequeue = true
Expand Down
2 changes: 1 addition & 1 deletion controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type requeue struct {

// processRequeue interprets a requeue result from a subreconciler.
func processRequeue(requeue *requeue, subReconciler interface{}, object runtime.Object, recorder record.EventRecorder, logger logr.Logger) (ctrl.Result, error) {
curLog := logger.WithValues("subReconciler", fmt.Sprintf("%T", subReconciler), "requeueAfter", requeue.delay)
curLog := logger.WithValues("reconciler", fmt.Sprintf("%T", subReconciler), "requeueAfter", requeue.delay)
if requeue.message == "" && requeue.curError != nil {
requeue.message = requeue.curError.Error()
}
Expand Down
12 changes: 12 additions & 0 deletions docs/manual/debugging.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Debugging

## Logging

The operator supports json-structured logging and will emit those logs to stdout and if configured to a file.
The operator sets different log keys for easier log filtering in different contexts.
All cluster related logs will contain the following fields:

- `namespace`: Namespace of the `FoundationDBCluster` resource that is currently processed.
- `cluster`: The name of the `FoundationDBCluster` resource that is currently processed.

In addition the operator will set the `reconciler` field to the current sub-reconciler.
If the operator iterates over all or a subset of `ProcessGroups`, the operator will set `processGroupID` to the current process group ID.

## Kubectl FDB Plugin

You can use the [kubectl-fdb](/kubectl-fdb) plugin when investigating issues and running imperative commands.
Expand Down

0 comments on commit 149ab80

Please sign in to comment.