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

Migrate to controller-runtime logger #2048

Open
tenzen-y opened this issue Apr 10, 2024 · 4 comments
Open

Migrate to controller-runtime logger #2048

tenzen-y opened this issue Apr 10, 2024 · 4 comments
Assignees

Comments

@tenzen-y
Copy link
Member

Currently, the training-operator uses some types of logger like this:

So, based on this discussion, I'd like to suggest using the controller-runtime logger everywhere to increase maintainability and consistency.

@champon1020
Copy link
Contributor

champon1020 commented Apr 18, 2024

Could I work on this task?

@tenzen-y
Copy link
Member Author

@champon1020 Sure, Feel free to assign yourself with a /assign comment.

@champon1020
Copy link
Contributor

/assign

@champon1020
Copy link
Contributor

Sorry for the late action but I'm going to tackle this issue.
Then, I have two questions about design of implementation.

The logger, which is initialized by calling ctrl.SetLogger, can be referred by "sigs.k8s.io/controller-runtime/pkg/log".Log and each k8s controller has the logger reference in their structure.

So, I think we should pass the logger and attach key-values instead of returning new logger in the LoggerForXXX functions of commonutil pacakge.

func LoggerForUnstructured(logger logr.Logger, *metav1unstructured.Unstructured, kind string) logr.Logger {
  return logger.WithValues(...)
}

Also, Warning method of logrus.Logger is used sometimes but logr.Logger only has Info and Error methods.
While it could be possible to distinguish the log-level by using V method of logr.Logger, I think it is better to set rules for log-level numbers. (Alternatively, it would be possible to unify Info and Warning logs into Info)

Please let me know your opinions. (cc: @tenzen-y)

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

No branches or pull requests

2 participants