Skip to content

Commit 7ab5e02

Browse files
authored
Merge pull request #288 from WaberZhuang/main
convertor: option to disable sparse file
2 parents d41d4ce + f91b366 commit 7ab5e02

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

.github/workflows/ci-basic.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ jobs:
7878
- name: CI - record trace
7979
shell: bash
8080
run: |
81+
set -x
8182
/opt/overlaybd/snapshotter/ctr rpull registry.hub.docker.com/overlaybd/redis:6.2.1_obdconv
8283
echo "[ by record-trace ]"
8384
/opt/overlaybd/snapshotter/ctr record-trace --runtime "io.containerd.runc.v2" --disable-network-isolation --time 15 registry.hub.docker.com/overlaybd/redis:6.2.1_obdconv registry.hub.docker.com/overlaybd/redis:6.2.1_obdconv_trace
8485
ctr i ls | grep 6.2.1_obdconv_trace
86+
sleep 10s # wait for tcmu device to be removed
8587
echo "[ by label ]"
8688
touch /tmp/trace_file
8789
ctr run -d --snapshotter=overlaybd --snapshotter-label containerd.io/snapshot/overlaybd/record-trace=yes --snapshotter-label containerd.io/snapshot/overlaybd/record-trace-path=/tmp/trace_file registry.hub.docker.com/overlaybd/redis:6.2.1_obdconv demo

cmd/convertor/builder/builder.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ type BuilderOptions struct {
6666
// ConcurrencyLimit limits the number of manifests that can be built at once
6767
// 0 means no limit
6868
ConcurrencyLimit int
69+
70+
// disable sparse file when converting overlaybd
71+
DisableSparse bool
6972
}
7073

7174
type graphBuilder struct {
@@ -248,6 +251,7 @@ func (b *graphBuilder) buildOne(ctx context.Context, src v1.Descriptor, tag bool
248251
switch b.Engine {
249252
case Overlaybd:
250253
engine = NewOverlayBDBuilderEngine(engineBase)
254+
engine.(*overlaybdBuilderEngine).disableSparse = b.DisableSparse
251255
case TurboOCI:
252256
engine = NewTurboOCIBuilderEngine(engineBase)
253257
}

cmd/convertor/builder/overlaybd_builder.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type overlaybdConvertResult struct {
5151

5252
type overlaybdBuilderEngine struct {
5353
*builderEngineBase
54+
disableSparse bool
5455
overlaybdConfig *sn.OverlayBDBSConfig
5556
overlaybdLayers []overlaybdConvertResult
5657
}
@@ -427,7 +428,10 @@ func (e *overlaybdBuilderEngine) getLayerDir(idx int) string {
427428
}
428429

429430
func (e *overlaybdBuilderEngine) create(ctx context.Context, dir string, mkfs bool, vsizeGB int) error {
430-
opts := []string{"-s", fmt.Sprintf("%d", vsizeGB)}
431+
opts := []string{fmt.Sprintf("%d", vsizeGB)}
432+
if !e.disableSparse {
433+
opts = append(opts, "-s")
434+
}
431435
if mkfs {
432436
opts = append(opts, "--mkfs")
433437
logrus.Infof("mkfs for baselayer, vsize: %d GB", vsizeGB)

cmd/convertor/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ var (
4848
dbstr string
4949
dbType string
5050
concurrencyLimit int
51+
disableSparse bool
5152

5253
// certification
5354
certDirs []string
@@ -104,6 +105,7 @@ Version: ` + commitID,
104105
NoUpload: noUpload,
105106
DumpManifest: dumpManifest,
106107
ConcurrencyLimit: concurrencyLimit,
108+
DisableSparse: disableSparse,
107109
}
108110
if overlaybd != "" {
109111
logrus.Info("building [Overlaybd - Native] image...")
@@ -165,6 +167,7 @@ func init() {
165167
rootCmd.Flags().StringVar(&dbstr, "db-str", "", "db str for overlaybd conversion")
166168
rootCmd.Flags().StringVar(&dbType, "db-type", "", "type of db to use for conversion deduplication. Available: mysql. Default none")
167169
rootCmd.Flags().IntVar(&concurrencyLimit, "concurrency-limit", 4, "the number of manifests that can be built at the same time, used for multi-arch images, 0 means no limit")
170+
rootCmd.Flags().BoolVar(&disableSparse, "disable-sparse", false, "disable sparse file for overlaybd")
168171

169172
// certification
170173
rootCmd.Flags().StringArrayVar(&certDirs, "cert-dir", nil, "In these directories, root CA should be named as *.crt and client cert should be named as *.cert, *.key")

0 commit comments

Comments
 (0)