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

More debug output #190

Merged
merged 3 commits into from
Jun 24, 2021
Merged

More debug output #190

merged 3 commits into from
Jun 24, 2021

Conversation

squaremo
Copy link
Member

This adds trace-level messages to the log, in particular for

  • which setters are created from policies, and which are invoked on the repo
  • which files are scanned as YAMLs
  • which files are added to the commit, and which are ignored

It's useful to be able to run with debug logging, which you can do now
with:

    make run LOG_LEVEL=debug

As a companion change, logging from `make run` is now explicitly set
to console format, since the expectation is it will be run from a
console.

Signed-off-by: Michael Bridgen <[email protected]>
This commit finesses the use of the debug log a little, and introduces
a trace log. The trace log gets threaded through calls to utility
procedures -- it's a little awkward putting loggers into func
parameters and structs, but it always is.

Signed-off-by: Michael Bridgen <[email protected]>
@@ -229,7 +239,7 @@ func (r *ImageUpdateAutomationReconciler) Reconcile(ctx context.Context, req ctr
}
}

log.V(debug).Info("cloned git repository", "gitrepository", originName, "ref", ref, "working", tmp)
debuglog.Info("cloned git repository", "gitrepository", originName, "ref", ref, "working", tmp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to log this before the attempt, so that it automatically adds context to any error that may happen during the attempt?

Reason I think this is a better approach, is because reconcilers generally do 3 things while performing operations for a resource:

  1. Logging (to tell what is about to happen, or highlight important information during an action).
  2. Events, to make certain things that have happened easily accessible to users and machines for observation.
  3. Conditions, to advertise observed state. Most often recorded after a reconciler has run an action that changed state, or when it inspected it.

There is some overlap in 1 and 2, but what distinguishes it for me is that 2 in all scenarios I have seen thus far, it never happens before something has taken place, which means that it would be a better task for logging.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it would, and that is a well-reasoned insight 👍

 - trace different code paths, e.g., how the push branch is chosen
 - move debug output so it records things not already covered by e.g.,
   errors, events

Signed-off-by: Michael Bridgen <[email protected]>
@squaremo squaremo mentioned this pull request Jun 23, 2021
Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines that have been added and/or changed look like they adhere to the guidelines I had in mind.

Thank you @squaremo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants