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

Set runtime debug mode #2360

Merged
merged 3 commits into from
Sep 15, 2022

Conversation

carolynvs
Copy link
Member

What does this change

This fixes the bundle output when a bundle is run in debug mode with --debug. It initializes RuntimeConfig.DebugMode (used by the mixins) with the value of the PORTER_DEBUG environment variable. It also configures a logger and puts it on the go context, so that when mixins use tracing.StartSpan or tracing.LoggerFromContext it gets a configured logger that understands the verbosity that was set on the Porter client side.

We are now setting PORTER_VERBOSITY on the bundle's invocation image when run so that --verbosity set on the client is also used in the bundle. When the bundle is run in debug mode (i.e. porter install --debug), we also pass PORTER_VERBOSITY=debug so that a dev can see everything that is happening.

What issue does it fix

Closes #2358

Notes for the reviewer

I am copy/pasting a lot of boilerplate code from porter's main into the exec mixin. In order for the other mixins to get debug mode and verbosity working, they too will need to do this. Long term I would like to use the pkg/cli package to share a common main implementation but @VinozzZ and I agreed this was the more conservative fix since we are in a release candidate.

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

Reviewer Checklist

  • Comment with /azp run test-porter-release if a magefile or build script was modified
  • Comment with /azp run porter-integration if it's a non-trivial PR

When we load our runtime configuration inside the bundle, we won't have a --debug flag, or a config file to load the configuraiton value. We ne
ed to instead handle applying configuration ourselves with the PORTER_DEBUG environment variable which is set by all porter bundles.

Signed-off-by: Carolyn Van Slyck <[email protected]>
In the main function for exex, I have copied some of the standard main "boilerplate" functionality around initializing a logger, and registering it with the go context. This enables other mixin functions to be able to grab a logger from the context when they call tracing.StartSpan or tracing.LoggerFromContext.

We do not have telemetry properly configured from inside a bundle yet, but this fixes debug logging from runtime libraries called by the mixins. Later on we can complete setting up the mixins so that they can particpate in telemetry/tracing too.

Signed-off-by: Carolyn Van Slyck <[email protected]>
When we run a bundle, we need to pass select porter configuration into the bundle using environment variables. This allows us to have the --verbosity flag, or --debug flag, to be used from inside the bundle.

Verbosity affects the log level of what is printed to the console.
DebugMode is used by the mixins to change their behavior when debugging a bundle (such as running slightly different commands).

Signed-off-by: Carolyn Van Slyck <[email protected]>
@carolynvs carolynvs marked this pull request as ready for review September 15, 2022 13:30
Copy link
Contributor

@VinozzZ VinozzZ left a comment

Choose a reason for hiding this comment

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

lgtm

@carolynvs carolynvs merged commit a787eef into getporter:release/v1 Sep 15, 2022
@carolynvs carolynvs deleted the set-runtime-debug-mode branch September 15, 2022 16:16
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.

Debug mode is not being picked up by the bundle runtime
2 participants