Skip to content

pkg/sysinfo: move MemInfo and ReadMemInfo to a separate package#44949

Merged
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:remove_system_meminfo_alias
Mar 15, 2023
Merged

pkg/sysinfo: move MemInfo and ReadMemInfo to a separate package#44949
thaJeztah merged 1 commit intomoby:masterfrom
thaJeztah:remove_system_meminfo_alias

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah commented Feb 7, 2023

Commit 6a516ac (#44663) moved the MemInfo type and ReadMemInfo() function into the pkg/sysinfo package. In an attempt to assist consumers of these to migrate to the new location, an alias was added.

Unfortunately, the side effect of this alias is that pkg/system now depends on pkg/sysinfo, which means that consumers of this (such as docker/cli) now get all (indirect) dependencies of that package as dependency, which includes many dependencies that should only be needed for the daemon / runtime;

  • github.com/cilium/ebpf
  • github.com/containerd/cgroups
  • github.com/coreos/go-systemd/v22
  • github.com/godbus/dbus/v5
  • github.com/moby/sys/mountinfo
  • github.com/opencontainers/runtime-spec

This patch moves the MemInfo related code to its own package. As the previous move
was not yet part of a release, we're not adding new aliases in pkg/sysinfo.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah
Copy link
Copy Markdown
Member Author

@thaJeztah thaJeztah marked this pull request as ready for review February 7, 2023 19:18
Comment thread pkg/system/meminfo_deprecated.go Outdated
//
// Deprecated: use [sysinfo.Memory].
type MemInfo = sysinfo.Memory
type MemInfo = struct{}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we just remove this function, and add "Memory was previously available as [system.MemInfo]" to the comment lines of sysinfo.Memory?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@corhere @cpuguy83 any thoughts? Do you think we should remove it altogether, or "some attempt on creating stub (but compile-time error)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

but then consumers would have no guidance at all where it went.

I expect them to run git grep MemInfo and find the guidance comment (Memory was previously available as [system.MemInfo]).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I prefer option C: solve the dependency-graph problem without breaking any users. Move the MemInfo and ReadMemInfo implementations into a new pkg/meminfo package and update both pkg/system and pkg/sysinfo to have deprecated aliases.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm a bit on the fence doing so. These functions were dropped in pkg/system as it was already a bit of a grab-bag of functions, but were only actually meant for internal use (most notably, together with sysinfo, which provided the other info about the system.

If we would, I would not update the aliases in pkg/sysinfo, as that location has never been released (only on master).

@thaJeztah thaJeztah force-pushed the remove_system_meminfo_alias branch from f880c4f to 5dfda68 Compare March 14, 2023 22:27
@thaJeztah thaJeztah changed the title pkg/system: remove aliases for deprecated MemInfo and ReadMemInfo pkg/sysinfo: move MemInfo and ReadMemInfo to a separate package Mar 14, 2023
Comment thread pkg/system/meminfo_deprecated.go Outdated
@thaJeztah thaJeztah force-pushed the remove_system_meminfo_alias branch from 5dfda68 to 22686cb Compare March 15, 2023 00:50
Copy link
Copy Markdown
Contributor

@corhere corhere left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment thread pkg/meminfo/meminfo_windows.go Outdated
}

// ReadMemInfo retrieves memory statistics of the host system and returns a
// Read retrieves memory statistics of the host system and returns a
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Read retrieves memory statistics of the host system and returns a
// readMemInfo retrieves memory statistics of the host system and returns a

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, dang! Looks like my IDE was trying to be smart there. Fixed 👍

Commit 6a516ac moved the MemInfo type and
ReadMemInfo() function into the pkg/sysinfo package. In an attempt to assist
consumers of these to migrate to the new location, an alias was added.

Unfortunately, the side effect of this alias is that pkg/system now depends
on pkg/sysinfo, which means that consumers of this (such as docker/cli) now
get all (indirect) dependencies of that package as dependency, which includes
many dependencies that should only be needed for the daemon / runtime;

- github.com/cilium/ebpf
- github.com/containerd/cgroups
- github.com/coreos/go-systemd/v22
- github.com/godbus/dbus/v5
- github.com/moby/sys/mountinfo
- github.com/opencontainers/runtime-spec

This patch moves the MemInfo related code to its own package. As the previous move
was not yet part of a release, we're not adding new aliases in pkg/sysinfo.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the remove_system_meminfo_alias branch from 22686cb to 2d49080 Compare March 15, 2023 16:53
@thaJeztah thaJeztah merged commit e828895 into moby:master Mar 15, 2023
@thaJeztah thaJeztah deleted the remove_system_meminfo_alias branch March 15, 2023 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact/changelog kind/refactor PR's that refactor, or clean-up code status/4-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants