From 688301caf4a8a97d71a333ac2918932bfbf2f78e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 8 Jul 2024 18:05:44 -0500 Subject: [PATCH] daemon/graphdriver: remove Capabilities, CapabilityDriver Capabilities were implemented in aa96c3176bf9dc6e14c6bbcf065ceb3a3870886a, as part of work on an external graphdriver-plugin. Given that none of the builtin graphdrivers use this option, and support for graphdriver- plugins has been removed in 555dac5e14ad4925e020f1a72e8c39b7a316b0dc, we can remove this functionality. This patch: - removes the CapabilityDriver interface, which has no implementations - removes the Capabilities type - layer: remove layerStore.useTarSplit. This field was previously set through the driver's Capabilities, but always enabled for the builtin graphdrivers, Signed-off-by: Sebastiaan van Stijn --- daemon/graphdriver/driver.go | 17 ----------- layer/layer_store.go | 57 ++++++++++++------------------------ 2 files changed, 19 insertions(+), 55 deletions(-) diff --git a/daemon/graphdriver/driver.go b/daemon/graphdriver/driver.go index 440030c3378fc..009a613186b36 100644 --- a/daemon/graphdriver/driver.go +++ b/daemon/graphdriver/driver.go @@ -94,23 +94,6 @@ type Driver interface { DiffDriver } -// Capabilities defines a list of capabilities a driver may implement. -// These capabilities are not required; however, they do determine how a -// graphdriver can be used. -type Capabilities struct { - // Flags that this driver is capable of reproducing exactly equivalent - // diffs for read-only layers. If set, clients can rely on the driver - // for consistent tar streams, and avoid extra processing to account - // for potential differences (eg: the layer store's use of tar-split). - ReproducesExactDiffs bool -} - -// CapabilityDriver is the interface for layered file system drivers that -// can report on their Capabilities. -type CapabilityDriver interface { - Capabilities() Capabilities -} - // DiffGetterDriver is the interface for layered file system drivers that // provide a specialized function for getting file contents for tar-split. type DiffGetterDriver interface { diff --git a/layer/layer_store.go b/layer/layer_store.go index 9a0df11277778..2ecb3b4925317 100644 --- a/layer/layer_store.go +++ b/layer/layer_store.go @@ -28,9 +28,8 @@ import ( const maxLayerDepth = 125 type layerStore struct { - store *fileMetadataStore - driver graphdriver.Driver - useTarSplit bool + store *fileMetadataStore + driver graphdriver.Driver layerMap map[ChainID]*roLayer layerL sync.Mutex @@ -77,23 +76,17 @@ func NewStoreFromOptions(options StoreOptions) (Store, error) { // metadata store and graph driver. The metadata store will be used to restore // the Store. func newStoreFromGraphDriver(root string, driver graphdriver.Driver) (Store, error) { - caps := graphdriver.Capabilities{} - if capDriver, ok := driver.(graphdriver.CapabilityDriver); ok { - caps = capDriver.Capabilities() - } - ms, err := newFSMetadataStore(root) if err != nil { return nil, err } ls := &layerStore{ - store: ms, - driver: driver, - layerMap: map[ChainID]*roLayer{}, - mounts: map[string]*mountedLayer{}, - locker: locker.New(), - useTarSplit: !caps.ReproducesExactDiffs, + store: ms, + driver: driver, + layerMap: map[ChainID]*roLayer{}, + mounts: map[string]*mountedLayer{}, + locker: locker.New(), } ids, mounts, err := ms.List() @@ -225,24 +218,21 @@ func (ls *layerStore) loadMount(mount string) error { } func (ls *layerStore) applyTar(tx *fileMetadataTransaction, ts io.Reader, parent string, layer *roLayer) error { + tsw, err := tx.TarSplitWriter(true) + if err != nil { + return err + } + metaPacker := storage.NewJSONPacker(tsw) + defer tsw.Close() + digester := digest.Canonical.Digester() tr := io.TeeReader(ts, digester.Hash()) - rdr := tr - if ls.useTarSplit { - tsw, err := tx.TarSplitWriter(true) - if err != nil { - return err - } - metaPacker := storage.NewJSONPacker(tsw) - defer tsw.Close() - - // we're passing nil here for the file putter, because the ApplyDiff will - // handle the extraction of the archive - rdr, err = asm.NewInputTarStream(tr, metaPacker, nil) - if err != nil { - return err - } + // we're passing nil here for the file putter, because the ApplyDiff will + // handle the extraction of the archive + rdr, err := asm.NewInputTarStream(tr, metaPacker, nil) + if err != nil { + return err } applySize, err := ls.driver.ApplyDiff(layer.cacheID, parent, rdr) @@ -690,15 +680,6 @@ func (ls *layerStore) initMount(graphID, parent, mountLabel string, initFunc Mou } func (ls *layerStore) getTarStream(rl *roLayer) (io.ReadCloser, error) { - if !ls.useTarSplit { - var parentCacheID string - if rl.parent != nil { - parentCacheID = rl.parent.cacheID - } - - return ls.driver.Diff(rl.cacheID, parentCacheID) - } - r, err := ls.store.TarSplitReader(rl.chainID) if err != nil { return nil, err