[release/1.6 backport] log: cleanups and improvements to decouple more from logrus#9002
Conversation
|
Build is complaining |
|
oh! it's because we're still testing on go1.17 🤔 I guess I could change it to |
This sounds reasonable, we need to continue rolling go versions forward on 1.6 and move away from the end of life versions |
|
Yup, sounds reasonable; I'll open a PR to update the minimum version in CI to 1.19, which is still fairly conservative (giving those that really cannot use "current" versions some slack). |
|
I always hesitant to backport features/refactorings to release branches. Do we really want this in 1.6? logrus migration is planned in 2.0. |
2a71cd3 to
c9b5f37
Compare
I'm considering looking at moving the logs package to a separate module; this module can be versioned separately from containerd, which would cut down some circular dependencies between containerd <---> plugins <---> containerd. Having these changes in allows plugins to start replacing direct uses of logrus (but currently still use it as the underlying implementation), with the potential to swap that implementation for something else, depending on what version of that module is used in containerd itself. |
|
Moving to draft; it looks like dbbe28b caused an issue for some users of the module. Whether it was intentional for external consumers to be able to overwrite the implementation is "TBD" (it was at least not clear), but it's a change in either case, so I'll revert that one commit for the time being. |
gotest.tools was only used for a basic assertion. Remove the dependency, in preparation of (potentially) moving this package to a separate module. similar to 6fe7e03, but adjusted for the 1.6 release branch Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 40ee5fb) Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 4a36022) Signed-off-by: Sebastiaan van Stijn <[email protected]>
Also updated the level descriptions with their documentation from logrus. Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 0b6333a) Signed-off-by: Sebastiaan van Stijn <[email protected]>
While other log-levels are not currently used in containerd itself, they can be returned by `GetLevel()`, and are accepted (no error) by `SetLevel()`. We should either accept those values, or produce an error (in `SetLevel()`), but given that there's other ways to set the log-level, we should probably acknowledge that this package is a transitional package, and still closely tied to logrus (for the time being). Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 81ac648) Signed-off-by: Sebastiaan van Stijn <[email protected]>
The `G` variable is exported, and not expected to be overwritten externally. Defining it as a function also documents it as a function on https://pkg.go.dev, instead of a variable; https://pkg.go.dev/github.com/containerd/[email protected]/log#pkg-variables Note that (while the godoc suggests otherwise) I made `GetLogger` an alias for `G`, as `G` is the most commonly used function (not the other way round), although I don't think there's a performance gain in doing so. Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 778ac30) Signed-off-by: Sebastiaan van Stijn <[email protected]>
Strong-type the format. Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit dd67240) Signed-off-by: Sebastiaan van Stijn <[email protected]>
Don't return logrus types from exported functions. Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 634a4a1) Signed-off-by: Sebastiaan van Stijn <[email protected]>
Decouple it from logrus, but with the same type. Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 238da2c) Signed-off-by: Sebastiaan van Stijn <[email protected]>
Add a package doc to (try to) describe the purpose of this package, and to describe the purpose (and expectations) of aliases provided by the package. > Package log provides types and functions related to logging, passing > loggers through a context, and attaching context to the logger. > > # Transitional types > > This package contains various types that are aliases for types in [logrus]. > These aliases are intended for transitioning away from hard-coding logrus > as logging implementation. Consumers of this package are encouraged to use > the type-aliases from this package instead of directly using their logrus > equivalent. > > The intent is to replace these aliases with locally defined types and > interfaces once all consumers are no longer directly importing logrus > types. > > IMPORTANT: due to the transitional purpose of this package, it is not > guaranteed for the full logrus API to be provided in the future. As > outlined, these aliases are provided as a step to transition away from > a specific implementation which, as a result, exposes the full logrus API. > While no decisions have been made on the ultimate design and interface > provided by this package, we do not expect carrying "less common" features. Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 6baff16) Signed-off-by: Sebastiaan van Stijn <[email protected]>
[`logrus.SetLevel()`][1], [`logrus.GetLevel()`][2] and [`logrus.SetFormatter()`][3] are all convenience functions to configure logrus' standardlogger, which is the logger to which we hold a reference in the Entry configured on [`log.L`][4]. This patch: - swaps calls to `logrus.SetLevel`, `logrus.GetLevel` and `logrus.SetFormatter` for their equivalents on `log.L`. This makes it clearer what `SetLevel` does, and makes sure that we set the log-level of the logger / entry we define in our package (even if that would be swapped with a different instance). - removes the use of `logrus.NewEntry` with directly constructing a `Entry`, using the local `Entry` alias (anticipating we can swap that type in future). [1]: https://github.com/sirupsen/logrus/blob/dd1b4c2e81afc5c255f216a722b012ed26be57df/exported.go#L34C1-L37 [2]: https://github.com/sirupsen/logrus/blob/dd1b4c2e81afc5c255f216a722b012ed26be57df/exported.go#L39-L42 [3]: https://github.com/sirupsen/logrus/blob/dd1b4c2e81afc5c255f216a722b012ed26be57df/exported.go#L23-L26 [4]: https://github.com/sirupsen/logrus/blob/dd1b4c2e81afc5c255f216a722b012ed26be57df/exported.go#L9-L16 Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 85a2c9a) Signed-off-by: Sebastiaan van Stijn <[email protected]>
This reverts commit 778ac30. (slightly modified, due to changes that were merged after that). The reverted commit had two elements; - Make `G` an actual function to improve the documentation - Prevent `G` from being overwritten externally From the commit that's reverted: > The `G` variable is exported, and not expected to be overwritten > externally. Defining it as a function also documents it as a function > on https://pkg.go.dev, instead of a variable; https://pkg.go.dev/github.com/containerd/[email protected]/log#pkg-variables While it's unclear if the ability to replace the implementation was _intentional_, it's this part that some external consumers were (ab)using. We should look into that part in a follow-up, and design for this, for example by providing a utility to replace the logger, and properly document that. In the meantime, let's revert the change. Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit 19d6c37) Signed-off-by: Sebastiaan van Stijn <[email protected]>
c9b5f37 to
33c2d88
Compare
|
Updated to include #9031 |
akhilerm
left a comment
There was a problem hiding this comment.
Are we backporting the other log package changes also into this branch? If thats the case, can we backport them in a single PR. because all the changes seem related.
|
We can merge this one first, it has no effect on importers. The one after this might and we may want to have that in its own release. |
|
containerd 1.6.24 Welcome to the v1.6.24 release of containerd! The twenty-fourth patch release for containerd 1.6 contains various fixes and updates. * **CRI: fix leaked shim caused by high IO pressure** ([containerd#9004](containerd#9004)) * **Update to go1.20.8** ([containerd#9073](containerd#9073)) * **Update runc to v1.1.9** ([containerd#8966](containerd#8966)) * **Backport: add configurable mount options to overlay snapshotter** ([containerd#8961](containerd#8961)) * **log: cleanups and improvements to decouple more from logrus** ([containerd#9002](containerd#9002)) See the changelog for complete list of changes Please try out the release binaries and report any issues at https://github.com/containerd/containerd/issues. * Sebastiaan van Stijn * Akihiro Suda * Wei Fu * Derek McGowan * Akhil Mohan * Cardy.Tang * Danny Canter * Kazuyoshi Kato * Mike Brown * Phil Estes * Samuel Karp <details><summary>45 commits</summary> <p> * [release/1.6] Prepare release notes for v1.6.24 ([containerd#9087](containerd#9087)) * [`cdd59290d`](containerd@cdd5929) Prepare release notes for v1.6.24 * [release/1.6 backport] log: cleanups and improvements to decouple more from logrus ([containerd#9002](containerd#9002)) * [`33c2d88e7`](containerd@33c2d88) Revert "log: define G() as a function instead of a variable" * [`0a7f2975e`](containerd@0a7f297) log: swap logrus functions with their equivalent on default logger * [`9d175a19b`](containerd@9d175a1) log: add package documentation and summary of package's purpose * [`96fb65529`](containerd@96fb655) log: make Fields type a generic map[string]any * [`bace17e2e`](containerd@bace17e) log: add log.Entry type * [`dd127885f`](containerd@dd12788) log: define OutputFormat type * [`5b4cf2329`](containerd@5b4cf23) log: define G() as a function instead of a variable * [`ee1b4a1e2`](containerd@ee1b4a1) log: add all log-levels that are accepted * [`d563a411f`](containerd@d563a41) log: group "enum" consts and touch-up docs * [`6e8f4555b`](containerd@6e8f455) log: WithLogger: remove redundant intermediate var * [`c19325559`](containerd@c193255) log: SetFormat: include returns in switch * [`c3c22f8cb`](containerd@c3c22f8) log: remove gotest.tools dependency * [release/1.6] update to go1.20.8 ([containerd#9073](containerd#9073)) * [`a2c294800`](containerd@a2c2948) [release/1.6] update to go1.20.8 * [release/1.6 backport] make repositories of install dependencies configurable ([containerd#9024](containerd#9024)) * [`0da8dcaa7`](containerd@0da8dca) make repositories of install dependencies configurable * [release/1.6 backport] update Golang to go1.20.7, minimum version go1.19 ([containerd#9020](containerd#9020)) * [`8e6a9de5b`](containerd@8e6a9de) update to go1.20.7, go1.19.12 * [`8b2eb371f`](containerd@8b2eb37) Update Go to 1.20.6,1.19.11 * [`cff669c7a`](containerd@cff669c) update go to go1.20.5, go1.19.10 * [`f34a22de9`](containerd@f34a22d) update go to go1.20.4, go1.19.9 * [`e8e73065e`](containerd@e8e7306) update go to go1.20.3, go1.19.8 * [`9b3f950d6`](containerd@9b3f950) Go 1.20.2 * [`17d03ac68`](containerd@17d03ac) Go 1.20.1 * [`861f65447`](containerd@861f654) go.mod: go 1.19 * [`81fa93784`](containerd@81fa937) Stop using math/rand.Read and rand.Seed (deprecated in Go 1.20) * [`70dc11a6c`](containerd@70dc11a) lint: remove `//nolint:dupword` that are no longer needed * [`fec784a06`](containerd@fec784a) lint: silence "SA1019: tar.TypeRegA has been deprecated... (staticheck)" * [`6648df1ad`](containerd@6648df1) lint: silence "type `HostFileConfig` is unused (unused)" * [`e6b268bc7`](containerd@e6b268b) golangci-lint v1.51.1 * [`c552ccf67`](containerd@c552ccf) go.mod: golang.org/x/sync v0.1.0 * [releases/1.6] *: fix leaked shim caused by high IO pressure ([containerd#9004](containerd#9004)) * [`d00af5c3e`](containerd@d00af5c) integration: issue7496 case should work for runc.v2 only * [`583696e4e`](containerd@583696e) Vagrantfile: add strace tool * [`ab21d60d2`](containerd@ab21d60) pkg/cri/server: add criService as argument when handle exit event * [`a229883cb`](containerd@a229883) pkg/cri/server: fix leaked shim issue * [`d8f824200`](containerd@d8f8242) integration: add case to reproduce containerd#7496 * [release/1.6] Cherry-pick: [overlay] add configurable mount options to overlay snapshotter ([containerd#8961](containerd#8961)) * [`8cd40e1d0`](containerd@8cd40e1) Add configurable mount options to overlay * [`453fa397a`](containerd@453fa39) feat: make overlay sync removal configurable * [release/1.6 backport] update runc binary to v1.1.9 ([containerd#8966](containerd#8966)) * [`4cb7764df`](containerd@4cb7764) update runc binary to v1.1.9 </p> </details> * **golang.org/x/sync** 036812b2e83c -> v0.1.0 Previous release can be found at [v1.6.23](https://github.com/containerd/containerd/releases/tag/v1.6.23)
containerd 1.6.24 Welcome to the v1.6.24 release of containerd! The twenty-fourth patch release for containerd 1.6 contains various fixes and updates. * **CRI: fix leaked shim caused by high IO pressure** ([containerd#9004](containerd#9004)) * **Update to go1.20.8** ([containerd#9073](containerd#9073)) * **Update runc to v1.1.9** ([containerd#8966](containerd#8966)) * **Backport: add configurable mount options to overlay snapshotter** ([containerd#8961](containerd#8961)) * **log: cleanups and improvements to decouple more from logrus** ([containerd#9002](containerd#9002)) See the changelog for complete list of changes Please try out the release binaries and report any issues at https://github.com/containerd/containerd/issues. * Sebastiaan van Stijn * Akihiro Suda * Wei Fu * Derek McGowan * Akhil Mohan * Cardy.Tang * Danny Canter * Kazuyoshi Kato * Mike Brown * Phil Estes * Samuel Karp <details><summary>45 commits</summary> <p> * [release/1.6] Prepare release notes for v1.6.24 ([containerd#9087](containerd#9087)) * [`cdd59290d`](containerd@cdd5929) Prepare release notes for v1.6.24 * [release/1.6 backport] log: cleanups and improvements to decouple more from logrus ([containerd#9002](containerd#9002)) * [`33c2d88e7`](containerd@33c2d88) Revert "log: define G() as a function instead of a variable" * [`0a7f2975e`](containerd@0a7f297) log: swap logrus functions with their equivalent on default logger * [`9d175a19b`](containerd@9d175a1) log: add package documentation and summary of package's purpose * [`96fb65529`](containerd@96fb655) log: make Fields type a generic map[string]any * [`bace17e2e`](containerd@bace17e) log: add log.Entry type * [`dd127885f`](containerd@dd12788) log: define OutputFormat type * [`5b4cf2329`](containerd@5b4cf23) log: define G() as a function instead of a variable * [`ee1b4a1e2`](containerd@ee1b4a1) log: add all log-levels that are accepted * [`d563a411f`](containerd@d563a41) log: group "enum" consts and touch-up docs * [`6e8f4555b`](containerd@6e8f455) log: WithLogger: remove redundant intermediate var * [`c19325559`](containerd@c193255) log: SetFormat: include returns in switch * [`c3c22f8cb`](containerd@c3c22f8) log: remove gotest.tools dependency * [release/1.6] update to go1.20.8 ([containerd#9073](containerd#9073)) * [`a2c294800`](containerd@a2c2948) [release/1.6] update to go1.20.8 * [release/1.6 backport] make repositories of install dependencies configurable ([containerd#9024](containerd#9024)) * [`0da8dcaa7`](containerd@0da8dca) make repositories of install dependencies configurable * [release/1.6 backport] update Golang to go1.20.7, minimum version go1.19 ([containerd#9020](containerd#9020)) * [`8e6a9de5b`](containerd@8e6a9de) update to go1.20.7, go1.19.12 * [`8b2eb371f`](containerd@8b2eb37) Update Go to 1.20.6,1.19.11 * [`cff669c7a`](containerd@cff669c) update go to go1.20.5, go1.19.10 * [`f34a22de9`](containerd@f34a22d) update go to go1.20.4, go1.19.9 * [`e8e73065e`](containerd@e8e7306) update go to go1.20.3, go1.19.8 * [`9b3f950d6`](containerd@9b3f950) Go 1.20.2 * [`17d03ac68`](containerd@17d03ac) Go 1.20.1 * [`861f65447`](containerd@861f654) go.mod: go 1.19 * [`81fa93784`](containerd@81fa937) Stop using math/rand.Read and rand.Seed (deprecated in Go 1.20) * [`70dc11a6c`](containerd@70dc11a) lint: remove `//nolint:dupword` that are no longer needed * [`fec784a06`](containerd@fec784a) lint: silence "SA1019: tar.TypeRegA has been deprecated... (staticheck)" * [`6648df1ad`](containerd@6648df1) lint: silence "type `HostFileConfig` is unused (unused)" * [`e6b268bc7`](containerd@e6b268b) golangci-lint v1.51.1 * [`c552ccf67`](containerd@c552ccf) go.mod: golang.org/x/sync v0.1.0 * [releases/1.6] *: fix leaked shim caused by high IO pressure ([containerd#9004](containerd#9004)) * [`d00af5c3e`](containerd@d00af5c) integration: issue7496 case should work for runc.v2 only * [`583696e4e`](containerd@583696e) Vagrantfile: add strace tool * [`ab21d60d2`](containerd@ab21d60) pkg/cri/server: add criService as argument when handle exit event * [`a229883cb`](containerd@a229883) pkg/cri/server: fix leaked shim issue * [`d8f824200`](containerd@d8f8242) integration: add case to reproduce containerd#7496 * [release/1.6] Cherry-pick: [overlay] add configurable mount options to overlay snapshotter ([containerd#8961](containerd#8961)) * [`8cd40e1d0`](containerd@8cd40e1) Add configurable mount options to overlay * [`453fa397a`](containerd@453fa39) feat: make overlay sync removal configurable * [release/1.6 backport] update runc binary to v1.1.9 ([containerd#8966](containerd#8966)) * [`4cb7764df`](containerd@4cb7764) update runc binary to v1.1.9 </p> </details> * **golang.org/x/sync** 036812b2e83c -> v0.1.0 Previous release can be found at [v1.6.23](https://github.com/containerd/containerd/releases/tag/v1.6.23)
containerd 1.6.24 Welcome to the v1.6.24 release of containerd! The twenty-fourth patch release for containerd 1.6 contains various fixes and updates. * **CRI: fix leaked shim caused by high IO pressure** ([containerd#9004](containerd#9004)) * **Update to go1.20.8** ([containerd#9073](containerd#9073)) * **Update runc to v1.1.9** ([containerd#8966](containerd#8966)) * **Backport: add configurable mount options to overlay snapshotter** ([containerd#8961](containerd#8961)) * **log: cleanups and improvements to decouple more from logrus** ([containerd#9002](containerd#9002)) See the changelog for complete list of changes Please try out the release binaries and report any issues at https://github.com/containerd/containerd/issues. * Sebastiaan van Stijn * Akihiro Suda * Wei Fu * Derek McGowan * Akhil Mohan * Cardy.Tang * Danny Canter * Kazuyoshi Kato * Mike Brown * Phil Estes * Samuel Karp <details><summary>45 commits</summary> <p> * [release/1.6] Prepare release notes for v1.6.24 ([containerd#9087](containerd#9087)) * [`cdd59290d`](containerd@cdd5929) Prepare release notes for v1.6.24 * [release/1.6 backport] log: cleanups and improvements to decouple more from logrus ([containerd#9002](containerd#9002)) * [`33c2d88e7`](containerd@33c2d88) Revert "log: define G() as a function instead of a variable" * [`0a7f2975e`](containerd@0a7f297) log: swap logrus functions with their equivalent on default logger * [`9d175a19b`](containerd@9d175a1) log: add package documentation and summary of package's purpose * [`96fb65529`](containerd@96fb655) log: make Fields type a generic map[string]any * [`bace17e2e`](containerd@bace17e) log: add log.Entry type * [`dd127885f`](containerd@dd12788) log: define OutputFormat type * [`5b4cf2329`](containerd@5b4cf23) log: define G() as a function instead of a variable * [`ee1b4a1e2`](containerd@ee1b4a1) log: add all log-levels that are accepted * [`d563a411f`](containerd@d563a41) log: group "enum" consts and touch-up docs * [`6e8f4555b`](containerd@6e8f455) log: WithLogger: remove redundant intermediate var * [`c19325559`](containerd@c193255) log: SetFormat: include returns in switch * [`c3c22f8cb`](containerd@c3c22f8) log: remove gotest.tools dependency * [release/1.6] update to go1.20.8 ([containerd#9073](containerd#9073)) * [`a2c294800`](containerd@a2c2948) [release/1.6] update to go1.20.8 * [release/1.6 backport] make repositories of install dependencies configurable ([containerd#9024](containerd#9024)) * [`0da8dcaa7`](containerd@0da8dca) make repositories of install dependencies configurable * [release/1.6 backport] update Golang to go1.20.7, minimum version go1.19 ([containerd#9020](containerd#9020)) * [`8e6a9de5b`](containerd@8e6a9de) update to go1.20.7, go1.19.12 * [`8b2eb371f`](containerd@8b2eb37) Update Go to 1.20.6,1.19.11 * [`cff669c7a`](containerd@cff669c) update go to go1.20.5, go1.19.10 * [`f34a22de9`](containerd@f34a22d) update go to go1.20.4, go1.19.9 * [`e8e73065e`](containerd@e8e7306) update go to go1.20.3, go1.19.8 * [`9b3f950d6`](containerd@9b3f950) Go 1.20.2 * [`17d03ac68`](containerd@17d03ac) Go 1.20.1 * [`861f65447`](containerd@861f654) go.mod: go 1.19 * [`81fa93784`](containerd@81fa937) Stop using math/rand.Read and rand.Seed (deprecated in Go 1.20) * [`70dc11a6c`](containerd@70dc11a) lint: remove `//nolint:dupword` that are no longer needed * [`fec784a06`](containerd@fec784a) lint: silence "SA1019: tar.TypeRegA has been deprecated... (staticheck)" * [`6648df1ad`](containerd@6648df1) lint: silence "type `HostFileConfig` is unused (unused)" * [`e6b268bc7`](containerd@e6b268b) golangci-lint v1.51.1 * [`c552ccf67`](containerd@c552ccf) go.mod: golang.org/x/sync v0.1.0 * [releases/1.6] *: fix leaked shim caused by high IO pressure ([containerd#9004](containerd#9004)) * [`d00af5c3e`](containerd@d00af5c) integration: issue7496 case should work for runc.v2 only * [`583696e4e`](containerd@583696e) Vagrantfile: add strace tool * [`ab21d60d2`](containerd@ab21d60) pkg/cri/server: add criService as argument when handle exit event * [`a229883cb`](containerd@a229883) pkg/cri/server: fix leaked shim issue * [`d8f824200`](containerd@d8f8242) integration: add case to reproduce containerd#7496 * [release/1.6] Cherry-pick: [overlay] add configurable mount options to overlay snapshotter ([containerd#8961](containerd#8961)) * [`8cd40e1d0`](containerd@8cd40e1) Add configurable mount options to overlay * [`453fa397a`](containerd@453fa39) feat: make overlay sync removal configurable * [release/1.6 backport] update runc binary to v1.1.9 ([containerd#8966](containerd#8966)) * [`4cb7764df`](containerd@4cb7764) update runc binary to v1.1.9 </p> </details> * **golang.org/x/sync** 036812b2e83c -> v0.1.0 Previous release can be found at [v1.6.23](https://github.com/containerd/containerd/releases/tag/v1.6.23)
backport of