Skip to content

add controller id to the logger correctly #699

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

demonCoder95
Copy link
Member

The controller field in the logs currently has a hardcoded string stackset. This isn't helpful when we define the optional controller-id CLI parameter and run multiple controllers in a cluster for development/testing.

This populates the field correctly with the controllerID if defined, and falls back to stackset as the value when none is provided.

return &StackSetController{
logger: log.WithFields(log.Fields{"controller": "stackset"}),
logger: log.WithFields(log.Fields{"controller": controllerID}),
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's the right field (controller should be kept as "stackset"). But we could add a second tag for the ID to solve your case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, makes sense. Will make it easier to differentiate it from other controllers running. I'll add another field.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a second field conditionally, to avoid having to have controller_id="" in the logs.

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

Successfully merging this pull request may close these issues.

2 participants