Commit Graph

43 Commits

Author SHA1 Message Date
haoyun
bbe46b8c43 feat: replace github.com/pkg/errors to errors
Signed-off-by: haoyun <yun.hao@daocloud.io>
Co-authored-by: zounengren <zouyee1989@gmail.com>
2022-01-07 10:27:03 +08:00
zounengren
46be069379 close Writer after use which may leak mem
Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
2021-10-12 17:25:08 +08:00
Eng Zer Jun
50da673592
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-09-21 09:50:38 +08:00
Shiming Zhang
b890f056e8 Fix content.ReaderAt close
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2021-05-08 12:39:09 +08:00
Sebastiaan van Stijn
f2edc6f164
vendor: update gotest.tools v3.0.2
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-28 17:47:20 +01:00
Derek McGowan
63ceaf877d
Add testing log context
Enables showing debug logs in testing output.
For integration tests the client log output will show
in addition to daemon output, with timestamps for better
correlation.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-07-16 10:31:43 -07:00
Michael Crosby
4f6ba8286d Ensure close in content test
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-06-04 19:26:34 +00:00
Derek McGowan
8706a355dd
Merge pull request #2889 from linxiulei/isolated_content
metadata: define content sharing policy
2019-01-14 13:15:38 -08:00
JoeWrightss
17b77aeb0e Fix annotation typo errors
Signed-off-by: JoeWrightss <zhoulin.xie@daocloud.io>
2018-12-31 22:40:06 +08:00
Eric Lin
4247f2684d metadata: define content sharing policy
This changeset modifies the metadata store to allow one to set a
"content sharing policy" that defines how blobs are shared between
namespaces in the content store.

The default mode "shared" will make blobs available in all namespaces
once it is pulled into any namespace.  The blob will be pulled into
the namespace if a writer is opened with the "Expected" digest that
is already present in the backend.

The alternative mode, "isolated" requires that clients prove they have
access to the content by providing all of the content to the ingest
before the blob is added to the namespace.

Both modes share backing data, while "shared" will reduce total
bandwidth across namespaces, at the cost of allowing access to any
blob just by knowing its digest.

Note: Most functional codes and changelog of this commit originate from
Stephen J Day <stephen.day@docker.com>, see
40455aade8

Fixes #1713 Fixes #2865

Signed-off-by: Eric Lin <linxiulei@gmail.com>
2018-12-21 15:02:21 +08:00
Derek McGowan
0f756495a9
Fix writer deadlock in local store
The local store could end up in a state where the writer is
closed but the reference is locked after a commit on an
existing object.
Cleans up Commit logic to always close the writer even after
an error occurs, guaranteeing the reference is unlocked after commit.
Adds a test to the content test suite to verify this behavior.
Updates the content store interface definitions to clarify the behavior.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-10-15 16:33:45 -07:00
Derek McGowan
c0cb2f2568
Add testcase for commit already exist
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-09-13 17:38:28 -07:00
Sebastiaan van Stijn
383d750d4f
Workaround for gofmt change in Go 1.11
Go 1.11 uses a different formatting for maps, and now
aligns values; running `gofmt -s -w` on this file resulted
in this diff;

```patch
 content/testsuite/testsuite.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/content/testsuite/testsuite.go b/content/testsuite/testsuite.go
index 974c7cb8ed..d9ae9dc160 100644
--- a/content/testsuite/testsuite.go
+++ b/content/testsuite/testsuite.go
@@ -365,8 +365,8 @@ func checkLabels(ctx context.Context, t *testing.T, cs content.Store) {

 	rootTime := time.Now().UTC().Format(time.RFC3339)
 	labels := map[string]string{
-		"k1": "v1",
-		"k2": "v2",
+		"k1":                    "v1",
+		"k2":                    "v2",
 		"containerd.io/gc.root": rootTime,
 	}

@@ -402,7 +402,7 @@ func checkLabels(ctx context.Context, t *testing.T, cs content.Store) {
 	}

 	info.Labels = map[string]string{
-		"k1": "v1",
+		"k1":                    "v1",
 		"containerd.io/gc.root": rootTime,
 	}
 	preUpdate = time.Now()
```

Adding a whitespace before the long key to make it format the same
on both Go 1.11 and older versions of Go.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-07-05 11:05:30 +02:00
Vincent Demeester
832b05ae67
Update tests to use gotest.tools angel
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-08 21:02:01 +02:00
Akihiro Suda
d88de4a34f content: change Writer/ReaderAt to take OCI
This change allows implementations to resolve the location of the actual data
using OCI descriptor fields such as MediaType.

No OCI descriptor field is written to the store.

No change on gRPC API.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-06-01 11:51:43 +09:00
Michael Crosby
009ba4d797 Move testutils to pkg
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-05-22 17:08:38 -04:00
Derek McGowan
ad6d02b881
Merge pull request #2221 from AkihiroSuda/content-small-blob
services/content: fix reading a blob which is smaller than the read buffer
2018-03-26 10:43:23 -07:00
Stephen J Day
a76f230984
content/testsuite: include small blob test in standard suite
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-03-26 08:39:39 -07:00
Akihiro Suda
7b323b1402 services/content: fix reading a blob which is smaller than the read buffer.
The newly added test fails without this fix in services/content/service.go:

    $ go test -c . && sudo ./containerd.test -test.v -test.root -test.run TestContentClient
    ...
        --- FAIL: TestContentClient/SmallBlob (0.02s)
            provideringester.go:62: rpc error: code = OutOfRange desc = read
    past object length 6 bytes
            helpers.go:67: drwx------       4096
    /tmp/content-suite-ContentClient-286788688
    FAIL

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-03-23 12:51:28 +09:00
Derek McGowan
43d0a5cb60
Pass in context to lease done function in client
Allows the client to choose the context to finish the lease.
This allows the client to switch contexts when the main context
used to the create the lease may have been cancelled.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-03-22 14:09:24 -07:00
Stephen Day
b3b95c0a2a
Merge pull request #2154 from dmcgowan/shared-content-ingests
content: shared content across namespaces
2018-03-12 16:11:32 -07:00
Derek McGowan
a1a67899f8
Shared content across namespaces
Update content ingests to use content from another namespace.
Ingests must be committed to make content available and the
client will see the sharing as an ingest which has already
been fully written to, but not completed.

Updated the database version to change the ingest record in
the database from a link key to an object with a link and
expected value. This expected value is used to indicate that
the content already exists and an underlying writer may
not yet exist.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-02-22 14:45:10 -08:00
Derek McGowan
b3aeba7062
Allow test runners to wrap contexts
Let the test runners choose the namespaces and
wrap the contexts. This allows the test suite to create
multiple contexts without worrying about namespacing
or leasing in the contexts.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-02-22 14:45:10 -08:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00
Daniel Nephin
ef48a0268e Migrate to gotestyourself/assert
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2018-02-12 12:26:26 -05:00
Kunal Kushwaha
1d6047aa71 Testcase name corrected
checkUploadStatus actaully verifys contents on Updating already written buffers,
hence should be called as checkUpdateStatus

Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-05 11:12:12 +09:00
Stephen J Day
3295bca5bf
content/testsuite: pass context to hold lease
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-01-29 16:29:51 -08:00
Stephen J Day
c517a005b5
content/testsuite: ensure unique content per test
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-01-29 15:29:38 -08:00
Derek McGowan
a12f493bd3
Update copy to discard over truncate
Prevents the copy method from calling discard on the
writer when the reader is not seekable. Instead,
the copy method will discard up to the offset.
Truncate is a more expensive operation since any
bytes that are truncated already have their hash calculated
and are stored on disk in the backend. Re-writing bytes
which were truncated requires transfering the data over
GRPC again and re-computing the hash up to the point of
truncation.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-01-26 11:44:50 -08:00
Derek McGowan
02d737f967
Add resume content test cases
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-01-26 11:44:50 -08:00
Daniel Nephin
49fffe8ec7 Less verbose tests
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-12-14 11:00:40 -05:00
Derek McGowan
72fb8f8f40
Add gc labels to content tests
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-11-20 16:57:40 -08:00
Michael Crosby
4192f99cf0 Only compare times on non-windows
There is a bug in the windows CI that causes a time difference between
the host and the container.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-11-16 16:25:18 -05:00
Stephen J Day
3e5e2ecc0a content/local: consistent handling of data and locks
The locks now retry on the backend side to prevent clients from having
to round trip on locks that might be momentarily held. This exposed some
timing errors in the updated_at fields for content ingest, so we've had
to move that to a separate file to export the monotonic go runtime
timestamps.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-16 16:13:19 -05:00
Stephen J Day
a9308e174d content/local: ensure that resumption is properly supported
While early PoCs had download resumption working, we didn't have tests
and had not verified the behavior. With this test suite, we now are able
to show that download resumption is properly supported in the content
store. In particular, there was a bug where resuming a download would
not issue the writes to the correct offset in the file. A Seek was added
to ensure we are writing from the current ingest offset.

In this investigation, it was also discovered that using the OS/Disk
created time on files was skewed from the monotonic clock in Go's
runtime. The startedat values are now taken from the Go runtime and
written to a separate file.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-16 16:12:59 -05:00
Daniel Nephin
a72279e53d Skip some tests on windows where the implementation is missing
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-15 14:52:00 -05:00
Derek McGowan
7b08bcdb65
Add support for label storage in local content store
Allows running tests which require labels on the content store

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-10-31 12:59:52 -07:00
Derek McGowan
9613acb2ed
Add context to content commit
Content commit is updated to take in a context, allowing
content to be committed within the same context the writer
was in. This is useful when commit may be able to use more
context to complete the action rather than creating its own.
An example of this being useful is for the metadata implementation
of content, having a context allows tests to fully create
content in one database transaction by making use of the context.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-09-06 10:19:12 -07:00
Derek McGowan
42119539be
Close writers in content test suite
Ensure all writers are closed at end of test for content
test suite. Prevents test from leaving lingering connections
to the content store.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-08-18 12:06:38 -07:00
Derek McGowan
dee8dc2cda
Add support for content labels on commit
Add commit options which allow for setting labels on commit.
Prevents potential race between garbage collector reading labels
after commit and labels getting set.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-08-11 14:15:20 -07:00
Derek McGowan
c4387a159e
Add content test suite run to client
Fix bugs in content deletion and upload status

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-08-11 14:08:34 -07:00
Derek McGowan
8e1591bd8b
Call upload status tests
Fix metadata status not returning correct reference string

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-24 10:11:35 -07:00
Derek McGowan
938f3185bd
Add content test suite
Add content test suite with test for writer.
Update fs and metadata implementations to use test suite.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-24 10:11:34 -07:00