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

packer: log plugins used and their version/path #12567

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lbajolet-hashicorp
Copy link
Collaborator

As maintainers of Packer and plugins, we ask our users to provide us with the versions of Packer and the plugins they use when they open an issue for us to review.

This is often misunderstood, and may be hidden in the logs, making it harder for all of us to understand where to look.

This commit adds a log statement that reports the list of plugins used, their version, and the path they've been loaded from.

@lbajolet-hashicorp lbajolet-hashicorp requested a review from a team as a code owner August 10, 2023 14:59
Copy link
Member

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

This is cool to see with in the logs and see how it can be helpful for external plugins. I left a few comments on the approach of bundled plugins and handling of errors.

"golang.org/x/mod/modfile"
)

//go:embed go.mod
Copy link
Member

@nywilken nywilken Aug 10, 2023

Choose a reason for hiding this comment

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

It's nice to see how simple this turned out to be but it feels like a short lived change given that their versions haven't changed in the past 4 releases and that we will be removing bundle plugins soon. But I do think logging the versions for external plugins makes sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In principle I agree with you, so that leaves us with a couple alternatives:

  1. We don't show bundled plugin usage: this is relatively straightforward, as we can remove this code. What I don't like is that it doesn't reflect the true plugin usage (though we do see the warning for bundled plugins which may lead us on which plugin is used, but isn't perfect, especially for JSON).
  2. We track bundled plugins, without the version info: doing so means that we need to infer which plugins are loaded, and track their version as bundled. This may not result in code that is as separated as this one though, as we'll probably need to hack something elsewhere in the codebase.
  3. This solution.

Given those alternatives, I know I would prefer option 3 since the work is already done, the code is straightforward, and concentrated (besides the call to this in main), so when we remove bundled plugins, this will be equally easy to cleanup (at least compared to solution 2).
Let me know what you think on that, I would have liked to include this in 1.9.3, but we can push it to a later version if there are reservations on this implementation.


tmpl := c.Template
if tmpl == nil {
panic("No template parsed. This is a Packer bug which should be reported, please open an issue on the project's issue tracker.")
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a pattern but I think throwing a panic for failures that are not critical to the execution of Packer can be more a blocker to the user than helpful. Especially, if there are unknown cases that cause an expected failure. For example the panics happening in the tests runs.

If we can't get this information for logging or displaying a warning to a user we should log the failure and not stop the build.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree with you, but at this time, if the template isn't properly parsed, this means that we've changed something in the logic, and we should be made aware ASAP, not later when we investigate why we don't see a warning/error anymore, and we notice this log.
At least that's my reasoning, and why I think some sanity-check panics like these are still relevant.
That being said, I'm not against the idea of changing this to a log/UI.Error, let me know which makes sense in your opinion.

As maintainers of Packer and plugins, we ask our users to provide us
with the versions of Packer and the plugins they use when they open an
issue for us to review.

This is often misunderstood, and may be hidden in the logs, making it
harder for all of us to understand where to look.

This commit adds a log statement that reports the list of plugins used,
their version, and the path they've been loaded from.
@nywilken
Copy link
Member

Converting this to a draft for now as we discussed bundled plugin removal and plugin loading changes.

@nywilken nywilken added stage/thinking Flagged for internal discussions about possible enhancements stage/needs-investigation and removed stage/thinking Flagged for internal discussions about possible enhancements labels Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants