Skip to content

Create metadata db object#1582

Merged
stevvooe merged 5 commits intocontainerd:masterfrom
dmcgowan:metadata-db-object
Oct 5, 2017
Merged

Create metadata db object#1582
stevvooe merged 5 commits intocontainerd:masterfrom
dmcgowan:metadata-db-object

Conversation

@dmcgowan
Copy link
Copy Markdown
Member

@dmcgowan dmcgowan commented Oct 3, 2017

Creates a metadata database object for abstracting the database file from users of the metadata store. This new database object provides the same transaction functions which bolt db has. This is needed in the future to provide locking around the transactions and provides a shared object to target for metadata garbage collection.

Additionally fixes snapshot remove relying on backend deletion in order to check for child relationships. Added the child relationships to the metadata store. Immediate backend deletion should not occur since the metadata store must not prevent sharing snapshots across namespaces. Note we currently don't have an interface exposed to shared snapshots, but it is a planned feature and should not be made impossible by the database.

@stevvooe stevvooe added this to the 1.0.0 milestone Oct 3, 2017
@dmcgowan dmcgowan force-pushed the metadata-db-object branch from f482e21 to a6c528b Compare October 3, 2017 03:14
@codecov-io
Copy link
Copy Markdown

codecov-io commented Oct 3, 2017

Codecov Report

Merging #1582 into master will increase coverage by 0.03%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1582      +/-   ##
==========================================
+ Coverage   46.29%   46.33%   +0.03%     
==========================================
  Files          24       26       +2     
  Lines        3378     3535     +157     
==========================================
+ Hits         1564     1638      +74     
- Misses       1456     1519      +63     
- Partials      358      378      +20
Impacted Files Coverage Δ
metadata/buckets.go 56% <ø> (ø) ⬆️
metadata/content.go 27.4% <100%> (ø) ⬆️
snapshot/storage/bolt.go 61.55% <100%> (ø) ⬆️
metadata/bolt.go 56.25% <100%> (ø) ⬆️
metadata/snapshot.go 44.1% <39.58%> (-0.66%) ⬇️
metadata/migrations.go 46.66% <46.66%> (ø)
metadata/db.go 51.89% <51.89%> (ø)
metadata/images.go 57.27% <75%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c4bca5...7f657ce. Read the comment docs.

Comment thread metadata/snapshot.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for lint, just return here

Comment thread metadata/db.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this data get stale or out of sync?

Copy link
Copy Markdown
Member Author

@dmcgowan dmcgowan Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now no, but the model is wrong and I am fixing it. Afterwards services will only need to load the metadata plugin and will get the snapshotter and content store from that single instance. That will prevent the dynamic registration model that it is using today, even though the registration only occurs during initialization.

@crosbymichael
Copy link
Copy Markdown
Member

LGTM

1 similar comment
@stevvooe
Copy link
Copy Markdown
Member

stevvooe commented Oct 3, 2017

LGTM

@dmcgowan
Copy link
Copy Markdown
Member Author

dmcgowan commented Oct 4, 2017

Before I update this, I am thinking we should add some migration and tighter versioning logic to the database. It would not be too difficult to add. In this case it is not extremely important but it could be useful and would be nice to have in before 1.0.

Signed-off-by: Derek McGowan <[email protected]>
Adds back links from parent to children in order to prevent
deletion of a referenced snapshot in a namespace.
Avoid removing snapshot during metadata delete to
prevent shared namespaces from being mistakenly deleted.

Signed-off-by: Derek McGowan <[email protected]>
Update database object to hold reference to the
data stores.

Signed-off-by: Derek McGowan <[email protected]>
Updates metadata plugin to require content and
snapshotter plugins be loaded and initializes with
those plugins, keeping the metadata database structure
static after initialization. Service plugins now only
require metadata plugin access snapshotter or content
stores through metadata, which was already required
behavior of the services.

Signed-off-by: Derek McGowan <[email protected]>
Signed-off-by: Derek McGowan <[email protected]>
@dmcgowan dmcgowan force-pushed the metadata-db-object branch from 4a2c131 to 7f657ce Compare October 5, 2017 23:43
Comment thread metadata/migrations.go
migrate func(*bolt.Tx) error
}

var migrations = []migration{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's document the addition of migrations.

Comment thread metadata/db.go
version = 0
)

i := len(migrations)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put the migrations components into a separate function/method?

@stevvooe
Copy link
Copy Markdown
Member

stevvooe commented Oct 5, 2017

LGTM on the migrations component.

@stevvooe stevvooe merged commit 8558b98 into containerd:master Oct 5, 2017
@dmcgowan dmcgowan deleted the metadata-db-object branch September 10, 2019 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants