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

Clabverter : ensure deletion of the old clabverter logging instance before creating a new one #148

Merged
merged 2 commits into from
May 23, 2024

Conversation

outout14
Copy link

Hi,

When using Clabverter as a Golang module, we need to use the MustNewClabverter() function to create a new clabverter instance.
The functions calls MustRegisterAndGetLogger() that panics if a logging instance of clabverter already exists.

This PR patches the MustNewClabverter by checking if the logging instance already exists. If so, it get destroyed and recreated.

@@ -54,6 +54,11 @@ func MustNewClabverter(

logManager := claberneteslogging.GetManager()

oldClabverterLogger, _ := logManager.GetLogger(clabernetesconstants.Clabverter)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it exists we should just return it instead? That way other stuff won’t end up with some deleted/nil logger?

Copy link
Author

Choose a reason for hiding this comment

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

Is the logger always have the same configuration at the end ? If it's different and comes from an old, destroyed Clabverter instance, that might cause issues.
If not I can change my PR to use the old one 😃

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, sorry ignore me anyway hah. I looked on my phone and didn't see where this was happening. this works for me :p

@carlmontanari
Copy link
Contributor

lgtm, thanks @outout14 😎

@carlmontanari carlmontanari merged commit 8d18530 into srl-labs:main May 23, 2024
4 checks passed
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