Commit Graph

176 Commits

Author SHA1 Message Date
Iceber Gu
e37ddafab4 metadata: modify NewLeaseManager to return leases.Manager
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-05-07 21:26:17 +08:00
Kazuyoshi Kato
cb1580937a metadata: improve deleting a non-empty namespace's error message
Deleting a non-empty namespace fails with

> namespace must be empty: failed precondition

This change improves the error message by listing the types of
the objects in the namespace that prevent deletion.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-04-15 15:49:44 -07:00
Maksym Pavlenko
bb6c0c2de7 Add more bolt utils
This PR extracts out a few more bolt utils from the codebase for easier management.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-04-11 19:32:46 -07:00
Kazuyoshi Kato
e74ace9ad8 content: support filters on local.store#Walk()
While Walk() has been taking filter strings, it was not using the parameter.
This change actually makes the filtering work.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2020-11-11 11:17:48 -08:00
Hajime Tazaki
f4741fb8c5 fix make test failure of missing sha256 package
Fixes: c50ff694 ("refactor(native): separate init from implementation")

Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
2020-09-10 18:50:49 +09:00
Sebastiaan van Stijn
dc92ad6520
Replace errors.Cause() with errors.Is()
Dependencies may be switching to use the new `%w` formatting
option to wrap errors; switching to use `errors.Is()` makes
sure that we are still able to unwrap the error and detect the
underlying cause.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-05-08 14:36:45 +02:00
Derek McGowan
123af61c0b
Add Cleanup to snapshot API
Cleanup is an optional method a snapshotter may implement.
Cleanup can be used to cleanup resources after a snapshot
has been removed. This function allows a snapshotter to defer
longer resource cleanup until after snapshot removals are
completed. Adding this to the API allows proxy snapshotters
to leverage this enhancement.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2020-01-07 14:59:20 -08:00
ktock
493a36de95 Move label filter to snapshots package
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2019-12-25 12:13:08 +09:00
Derek McGowan
526c0db693
Support target snapshot references on prepare
Allows backend snapshots to bring existing snapshots into
a namespace without requiring clients to fully snapshots
when the target reference is known. Backend snapshots must
explicitly implement this functionality, it is equivalent
to sharing across namespaces and is up to the backend to
use the label when it is given or ignore it.

This enables remote snapshot functionality for a backend to
query for a target snapshot before a client has performed
any work to create that snapshot.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-11-25 10:07:25 -08:00
Derek McGowan
d1261b5087
Update snapshot parent filter property to always exist
The parent property may be empty but always exists.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-11-25 10:07:25 -08:00
Phil Estes
76aa4e546e
Use common identifiers package with less restrictive regex
Regular expressions in the namespaces package are redundant with the
pre-existing validator in the "identifiers" package; replace this custom
usage with the validator in "identifiers"

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2019-11-04 21:22:01 -05:00
Derek McGowan
66aa1d3ef6
Add snapshot walk implementations
Temporarily remove zfs and aufs until interface update

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-10-24 11:11:22 -07:00
bpopovschi
e8c14c07c6
Added filters to snapshots API
Signed-off-by: bpopovschi <zyqsempai@mail.ru>
2019-10-24 11:11:22 -07:00
yuxiaobo
62c2eea78d fix-up typo
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
2019-09-26 13:02:03 +08:00
yuxiaobo
5ea9363624 Perfect documentation
Signed-off-by: yuxiaobo <yuxiaobogo@163.com>
2019-09-25 16:59:31 +08:00
Derek McGowan
0b224ac7d6
Update metadata interfaces for containers and leases
Add more thorough dirty checking across all types which
may be deleted and hold references.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-09-23 15:27:39 -07:00
Guangming Wang
6d0e355c6d
cleanup code typos in leases.go
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-08-17 00:27:08 +08:00
Maksym Pavlenko
98ead46d1a Call Update of snapshotter plugin
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
2019-07-26 15:56:07 -07:00
Derek McGowan
dd0a45dfe0
Add flat GC label for leases
Provide a flag which configures a lease to only hold
reference to its given references and ignore label references
during garbage collection rooted from the lease.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-07-18 11:16:46 -07: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
Edgar Lee
7d21172453 Fix metadata content store to call writer digest after commit
Signed-off-by: Edgar Lee <edgarl@netflix.com>
2019-07-08 07:26:49 -07:00
Michael Crosby
844c58102e Add cgroup delete opt for ns deletion
Closes #3305

This adds an opt and a `--cgroup,-c` flag to `ctr namespaces rm` to
remove the cgroup that is commonly created with runtimes.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-07-01 15:01:02 -04:00
Eric Hotinger
75f183887a Allow opts to flow to the backend snapshotter during snapshot creation.
Signed-off-by: Eric Hotinger <ehotinger@gmail.com>
2019-06-19 11:00:22 -07:00
Wei Fu
8a388d6238 leases: support resource management
Add three methods for lease service so that the client can use it to
manage the resource by lease, not just gc.root label. With the following
methods, it is easy for client to maintain their own cache system.

```
 - AddResource(context.Context, Lease, Resource) error
 - RemoveResource(context.Context, Lease, Resource) error
 - ListResources(context.Context, Lease) ([]Resource, error)
```

And the resource is to be

```golang
type Resource {
  ID   string
  Type string
}
```

For the snapshots, the Type field will be formatted by
snapshots/%{type}, like snapshots/overlayfs.

fix: #3295

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-05-29 11:00:32 +08:00
Derek McGowan
41b7b0e0dc
Ensure namespaced writer commit has correct namespace
The namespaced writer Commit method must always have a
namespace in the context as checked by the removeIngestLease
function, resulting in a panic when not provided.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-05-21 11:08:55 -07:00
Davor Kapsa
cfc36388b3 Remove redundant error checks
Signed-off-by: Davor Kapsa <davor.kapsa@gmail.com>
2019-04-30 21:28:51 +02:00
Derek McGowan
68c44f8cc8
Merge pull request #3122 from stefanberger/descriptor_annotations.pr
Extend adaptImage function with annotations case
2019-03-22 14:28:15 -07:00
Stefan Berger
5d50b9c2bb Extend adaptImage function with annotations case
Extend the adaptImage function with a case for handling the annotations
so they can be used in the filter adaptors for fieldpaths.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-22 14:56:26 -04:00
Michael Crosby
9b882c44f8
Merge pull request #3000 from stefanberger/descriptor_annotations.pr
Add missing annotations map to Descriptor for gRPC transfer
2019-03-22 14:05:44 -04:00
Stefan Berger
09cf2a629b Extend metadata images test with fieldpaths for Annotations
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-07 14:20:56 -05:00
Stefan Berger
5124f9ee54 Write the Annotations map into the bolt db
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-07 13:55:58 -05:00
Stefan Berger
02cc1485df Prepare boltutil for reading and writing another map
Refactor the code so that another function can also read and write maps
into the bolt db.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2019-03-07 13:55:22 -05:00
Derek McGowan
7cfb99ab9d
Add content gc ref labels from containers, images, and snapshots
Currently the objects which can retain content from labels
are limited. This limitation has required clients to work
around this and and in some cases add outside reference
counting (e.g. buildkit keeping content for snapshots).
Updated the logic to treat content and snapshot labels equally
and simplified the code in the process.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-03-04 14:51:07 -08:00
Wei Fu
4b3e0a8aaa metadata: merge snapshot labels with metadata's labels
fix the no-op issue.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-02-18 16:11:12 +08:00
Derek McGowan
d25007e548
Add structure documentation for metadata
Adds comment showing the structure of the buckets
as stored in boltdb. Includes all bucket names, key names
and descriptions of the stored values.

Moves the metadata comment to package level to be exposed
in the godoc overview.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-02-05 14:45:29 -08:00
Wei Fu
34672d483d metadata/gc: remove the noop-loop for snapshot reference
The noop-loop does nothing.

The containerd doesn't have any snapshotter buckets at the beginning.
If user uses specific dir as rootfs to create container, and sets
`snapshotter` key to the container, like `overlayfs` by mistake,
the gc scheduler will try to scan the snapshotter and panic.

In order to avoid this case, remove the noop-loop here.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-01-29 19:11:28 +08:00
Wei Fu
132ee9b826 fix: linter issue
megacheck, gosimple and unused has been deprecated and subsumed by
staticcheck. And staticcheck also has been upgraded. we need to update
code for the linter issue.

close: #2945

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-01-23 22:54:51 +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
John Starks
6daf8b7782 Eliminate misuses of errors.Wrapf
In many cases code is calling errors.Wrapf with an arbitrary string
instead of a format string. This causes confusing errors when the
wrapped error message contains '%' characters.

This change replaces such calls with calls to errors.Wrap.

Signed-off-by: John Starks <jostarks@microsoft.com>
2018-11-29 14:26:53 -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
440c7ed249
Fix commit already exists not leasing
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-10-02 14:16:57 -07:00
Phil Estes
05984a966d
Merge pull request #2642 from dmcgowan/fix-commit-already-exists
Fix content store bug when already exists
2018-09-14 09:09:22 -04:00
Derek McGowan
6875d3df3a
Always check exists on commit error
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-09-14 01:26:03 -07:00
Michael Crosby
c95bb88fa3
Merge pull request #2634 from jhowardmsft/boltdb
Move to supported boltdb
2018-09-13 20:42:00 -04:00
liaojian
0120dec799 fix typo
fix typo
Signed-off-by: jian liao <jliao@alauda.io>
2018-09-13 10:51:07 +08:00
John Howard
8e44270723 Adds a no-op migration for metadata v3
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-09-12 15:33:42 -07:00
John Howard
2586f3fbb9 boltdb/bolt --> go.etcd.io/bbolt
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-09-12 15:23:57 -07:00
Samuel Karp
9665a2650a *: replace 3600 seconds with 1 hour
Signed-off-by: Samuel Karp <skarp@amazon.com>
2018-08-02 11:40:03 -07:00
Phil Estes
4249f44d81
Merge pull request #2493 from dmcgowan/sync-lease-removal
Add sync option to lease removal
2018-07-31 11:31:55 -04:00
Derek McGowan
dfc9991135
Add content ingests to lease and gc
Allow content ingests to be cleaned up during gc.
Use a default expiration on content ingests or make
use of the lease expiration when provided.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-07-25 16:54:14 -07:00