MCPcopy
hub / github.com/containerd/containerd / OpenWriter

Function OpenWriter

core/content/helpers.go:149–182  ·  view source on GitHub ↗

OpenWriter opens a new writer for the given reference, retrying if the writer is locked until the reference is available or returns an error.

(ctx context.Context, cs Ingester, opts ...WriterOpt)

Source from the content-addressed store, hash-verified

147// OpenWriter opens a new writer for the given reference, retrying if the writer
148// is locked until the reference is available or returns an error.
149func OpenWriter(ctx context.Context, cs Ingester, opts ...WriterOpt) (Writer, error) {
150 var (
151 cw Writer
152 err error
153 retry = 16
154 )
155 for {
156 cw, err = cs.Writer(ctx, opts...)
157 if err != nil {
158 if !errdefs.IsUnavailable(err) {
159 return nil, err
160 }
161
162 // TODO: Check status to determine if the writer is active,
163 // continue waiting while active, otherwise return lock
164 // error or abort. Requires asserting for an ingest manager
165
166 select {
167 case <-time.After(time.Millisecond * time.Duration(randutil.Intn(retry))):
168 if retry < 2048 {
169 retry = retry << 1
170 }
171 continue
172 case <-ctx.Done():
173 // Propagate lock error
174 return nil, err
175 }
176
177 }
178 break
179 }
180
181 return cw, err
182}
183
184// Copy copies data with the expected digest from the reader into the
185// provided content store writer. This copy commits the writer.

Callers 15

FetchFunction · 0.92
pushFunction · 0.92
PushMethod · 0.92
checkContentStoreWriterFunction · 0.92
checkResumeWriterFunction · 0.92
checkCommitExistsFunction · 0.92
checkCommitErrorStateFunction · 0.92
checkUpdateStatusFunction · 0.92
checkLabelsFunction · 0.92
checkResumeFunction · 0.92
checkCrossNSShareFunction · 0.92

Calls 3

IntnFunction · 0.92
WriterMethod · 0.65
DoneMethod · 0.65

Used in the wild real call sites across dependent graphs

searching dependent graphs…