Skip to content

Comments

daemon/graphdriver: split, internalize packages to separate snapshotters and graphdrivers#48092

Merged
thaJeztah merged 4 commits intomoby:masterfrom
thaJeztah:fsmagic_internal
Jul 8, 2024
Merged

daemon/graphdriver: split, internalize packages to separate snapshotters and graphdrivers#48092
thaJeztah merged 4 commits intomoby:masterfrom
thaJeztah:fsmagic_internal

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Jun 29, 2024

daemon/graphdriver: move FsMagic utilities to an internal package

These utilities were used in both graphdrivers and snapshotters. Move them
to a separate package, to help decoupling snapshotters and graphdrivers,
and make it internal, as it's not intended to be used as a generic utility
package (we can still make it public if there would be a need).

daemon/internal/fstype: make FsMagic values not platform-dependent

While detection of filesystem-types may not be supported on all platforms,
it should be ok to define the types; this would allow for these types to
be used to print names (e.g.) in cross-platform situations.

daemon/graphdriver: simplify Checker, remove NewFsChecker, NewDefaultChecker

The Checker interface was introduced in 1ba05cd
as an optimization to allow passing a simplified check for situations that
don't require mountinfo.Mounted to be executed (as that may result in parsing
/proc/self/mountinfo).

The Checker was defined as an interface with a single IsMounted method,
possibly with the intent to allow for additional kind of checks to be added.
No new additions were made since its inception 9 Years ago, and if a need would
arrive, could probably be implemented as part of the check.

This patch simplifies the definition to a function, removing the need to
implement a wrapper struct just to satisfy the interface. The Checker
type definition is somewhat redundant, but is kept to have a place to
provide GoDoc.

The NewFsChecker and NewDefaultChecker utilities are removed as part
of this change, favoring a local definition for storage-drivers that
used them.

daemon/graphdriver: move RefCounter to an internal package

The RefCounter is used in both graphdrivers and snapshotters. Move it
to a separate package to help decoupling snapshotters and graphdrivers,
and make it internal, as it's not intended to be used as a generic utility
package (we can still make it public if there would be a need).

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

@thaJeztah thaJeztah added area/storage Image Storage status/2-code-review area/daemon Core Engine kind/refactor PR's that refactor, or clean-up code area/go-sdk labels Jun 29, 2024
@thaJeztah thaJeztah force-pushed the fsmagic_internal branch 2 times, most recently from 63b9d18 to a11a386 Compare June 30, 2024 11:49
@thaJeztah thaJeztah changed the title daemon/graphdriver: move FsMagic utilties to internal daemon/graphdriver: split packages to separate snapshotters and graphdrivers Jun 30, 2024
@thaJeztah thaJeztah changed the title daemon/graphdriver: split packages to separate snapshotters and graphdrivers daemon/graphdriver: split, internalize packages to separate snapshotters and graphdrivers Jun 30, 2024
@thaJeztah thaJeztah force-pushed the fsmagic_internal branch 3 times, most recently from 5bdc9c5 to 32d7a70 Compare June 30, 2024 12:31
@thaJeztah thaJeztah self-assigned this Jun 30, 2024
@thaJeztah thaJeztah added this to the 28.0.0 milestone Jun 30, 2024
@thaJeztah thaJeztah marked this pull request as ready for review June 30, 2024 16:03
@thaJeztah thaJeztah requested a review from johnstep as a code owner June 30, 2024 16:03
@thaJeztah thaJeztah requested review from laurazard and vvoland June 30, 2024 16:04
@thaJeztah thaJeztah added the containerd-integration Issues and PRs related to containerd integration label Jun 30, 2024
@thaJeztah thaJeztah mentioned this pull request Jun 30, 2024
79 tasks
Copy link
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

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

LGTM

thaJeztah added 3 commits July 1, 2024 19:15
These utilities were used in both graphdrivers and snapshotters. Move them
to a separate package, to help decoupling snapshotters and graphdrivers,
and make it internal, as it's not intended to be used as a generic utility
package (we can still make it public if there would be a need).

Signed-off-by: Sebastiaan van Stijn <[email protected]>
While detection of filesystem-types may not be supported on all platforms,
it should be ok to define the types; this would allow for these types to
be used to print names (e.g.) in cross-platform situations.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
…Checker

The Checker interface was introduced in 1ba05cd
as an optimization to allow passing a simplified check for situations that
don't require mountinfo.Mounted to be executed (as that may result in parsing
 `/proc/self/mountinfo`).

The Checker was defined as an interface with a single `IsMounted` method,
possibly with the intent to allow for additional kind of checks to be added.
No new additions were made since its inception 9 Years ago, and if a need would
arrive, could probably be implemented as part of the check.

This patch simplifies the definition to a function, removing the need to
implement a wrapper struct just to satisfy the interface. The `Checker`
type definition is somewhat redundant, but is kept to have a place to
provide GoDoc.

The `NewFsChecker` and `NewDefaultChecker` utilities are removed as part
of this change, favoring a local definition for storage-drivers that
used them.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Member Author

@cpuguy83 this one LGTY?

@@ -1,4 +1,4 @@
package graphdriver // import "github.com/docker/docker/daemon/graphdriver"
package refcounter
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this should be called mountref with a type called Counter

Copy link
Member

Choose a reason for hiding this comment

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

Or we can have something like fstype and the refcounter thing in one package.

Copy link
Member Author

Choose a reason for hiding this comment

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

Mountref works for me; I tried to find a proper name for it, but was indeed considering if it should include "mount" in the name.

Let me try updating and see how that looks.

I prefer keeping the FSType bits separate; I think they're somewhat separate concerns, and it's nice to have a small focussed package.

The RefCounter is used in both graphdrivers and snapshotters. Move it
to a separate package to help decoupling snapshotters and graphdrivers,
and make it internal, as it's not intended to be used as a generic utility
package (we can still make it public if there would be a need).

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Member Author

@cpuguy83 updated; PTAL

@thaJeztah
Copy link
Member Author

@cpuguy83 ptal 🤗

@thaJeztah thaJeztah requested a review from cpuguy83 July 8, 2024 20:04
@thaJeztah thaJeztah merged commit c4dcaa0 into moby:master Jul 8, 2024
@thaJeztah thaJeztah deleted the fsmagic_internal branch July 8, 2024 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/daemon Core Engine area/go-sdk area/storage Image Storage containerd-integration Issues and PRs related to containerd integration kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

Development

Successfully merging this pull request may close these issues.

3 participants