Browse code

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 <github@gone.nl>

Sebastiaan van Stijn authored on 2024/07/09 08:05:44
Showing 2 changed files
... ...
@@ -94,23 +94,6 @@ type Driver interface {
94 94
 	DiffDriver
95 95
 }
96 96
 
97
-// Capabilities defines a list of capabilities a driver may implement.
98
-// These capabilities are not required; however, they do determine how a
99
-// graphdriver can be used.
100
-type Capabilities struct {
101
-	// Flags that this driver is capable of reproducing exactly equivalent
102
-	// diffs for read-only layers. If set, clients can rely on the driver
103
-	// for consistent tar streams, and avoid extra processing to account
104
-	// for potential differences (eg: the layer store's use of tar-split).
105
-	ReproducesExactDiffs bool
106
-}
107
-
108
-// CapabilityDriver is the interface for layered file system drivers that
109
-// can report on their Capabilities.
110
-type CapabilityDriver interface {
111
-	Capabilities() Capabilities
112
-}
113
-
114 97
 // DiffGetterDriver is the interface for layered file system drivers that
115 98
 // provide a specialized function for getting file contents for tar-split.
116 99
 type DiffGetterDriver interface {
... ...
@@ -28,9 +28,8 @@ import (
28 28
 const maxLayerDepth = 125
29 29
 
30 30
 type layerStore struct {
31
-	store       *fileMetadataStore
32
-	driver      graphdriver.Driver
33
-	useTarSplit bool
31
+	store  *fileMetadataStore
32
+	driver graphdriver.Driver
34 33
 
35 34
 	layerMap map[ChainID]*roLayer
36 35
 	layerL   sync.Mutex
... ...
@@ -77,23 +76,17 @@ func NewStoreFromOptions(options StoreOptions) (Store, error) {
77 77
 // metadata store and graph driver. The metadata store will be used to restore
78 78
 // the Store.
79 79
 func newStoreFromGraphDriver(root string, driver graphdriver.Driver) (Store, error) {
80
-	caps := graphdriver.Capabilities{}
81
-	if capDriver, ok := driver.(graphdriver.CapabilityDriver); ok {
82
-		caps = capDriver.Capabilities()
83
-	}
84
-
85 80
 	ms, err := newFSMetadataStore(root)
86 81
 	if err != nil {
87 82
 		return nil, err
88 83
 	}
89 84
 
90 85
 	ls := &layerStore{
91
-		store:       ms,
92
-		driver:      driver,
93
-		layerMap:    map[ChainID]*roLayer{},
94
-		mounts:      map[string]*mountedLayer{},
95
-		locker:      locker.New(),
96
-		useTarSplit: !caps.ReproducesExactDiffs,
86
+		store:    ms,
87
+		driver:   driver,
88
+		layerMap: map[ChainID]*roLayer{},
89
+		mounts:   map[string]*mountedLayer{},
90
+		locker:   locker.New(),
97 91
 	}
98 92
 
99 93
 	ids, mounts, err := ms.List()
... ...
@@ -225,24 +218,21 @@ func (ls *layerStore) loadMount(mount string) error {
225 225
 }
226 226
 
227 227
 func (ls *layerStore) applyTar(tx *fileMetadataTransaction, ts io.Reader, parent string, layer *roLayer) error {
228
+	tsw, err := tx.TarSplitWriter(true)
229
+	if err != nil {
230
+		return err
231
+	}
232
+	metaPacker := storage.NewJSONPacker(tsw)
233
+	defer tsw.Close()
234
+
228 235
 	digester := digest.Canonical.Digester()
229 236
 	tr := io.TeeReader(ts, digester.Hash())
230 237
 
231
-	rdr := tr
232
-	if ls.useTarSplit {
233
-		tsw, err := tx.TarSplitWriter(true)
234
-		if err != nil {
235
-			return err
236
-		}
237
-		metaPacker := storage.NewJSONPacker(tsw)
238
-		defer tsw.Close()
239
-
240
-		// we're passing nil here for the file putter, because the ApplyDiff will
241
-		// handle the extraction of the archive
242
-		rdr, err = asm.NewInputTarStream(tr, metaPacker, nil)
243
-		if err != nil {
244
-			return err
245
-		}
238
+	// we're passing nil here for the file putter, because the ApplyDiff will
239
+	// handle the extraction of the archive
240
+	rdr, err := asm.NewInputTarStream(tr, metaPacker, nil)
241
+	if err != nil {
242
+		return err
246 243
 	}
247 244
 
248 245
 	applySize, err := ls.driver.ApplyDiff(layer.cacheID, parent, rdr)
... ...
@@ -690,15 +680,6 @@ func (ls *layerStore) initMount(graphID, parent, mountLabel string, initFunc Mou
690 690
 }
691 691
 
692 692
 func (ls *layerStore) getTarStream(rl *roLayer) (io.ReadCloser, error) {
693
-	if !ls.useTarSplit {
694
-		var parentCacheID string
695
-		if rl.parent != nil {
696
-			parentCacheID = rl.parent.cacheID
697
-		}
698
-
699
-		return ls.driver.Diff(rl.cacheID, parentCacheID)
700
-	}
701
-
702 693
 	r, err := ls.store.TarSplitReader(rl.chainID)
703 694
 	if err != nil {
704 695
 		return nil, err