Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The database schema for metadata is inaccurate, and the namespace name cannot be version #6944

Closed
Iceber opened this issue May 14, 2022 · 4 comments

Comments

@Iceber
Copy link
Member

Iceber commented May 14, 2022

Description

The version key should actually be in the v1 buckets.

// Below is the current database schema. This should be updated each time
// the structure is changed in addition to adding a migration and incrementing
// the database version. Note that `╘══*...*` refers to maps with arbitrary
// keys.
// ├──version : <varint> - Latest version, see migrations
// └──v1 - Schema version bucket
// ╘══*namespace*
// ├──labels
// │  ╘══*key* : <string> - Label value
// ├──image
// │  ╘══*image name*

code:

containerd/metadata/db.go

Lines 194 to 204 in b9bffd1

bkt, err := tx.CreateBucketIfNotExists(bucketKeyVersion)
if err != nil {
return err
}
versionEncoded, err := encodeInt(dbVersion)
if err != nil {
return err
}
return bkt.Put(bucketKeyDBVersion, versionEncoded)

use bbolt cmd

root@iceber-master:~# ./bbolt keys  /var/lib/containerd/io.containerd.metadata.v1.bolt/meta.db v1
default
k8s.io
moby
stress
version

And the namespace name cannot be version.

root@iceber-master:~# ctr namespaces create version
ctr: incompatible value: unknown

Describe the results you received and expected

Could we change the database schema to

// Below is the current database schema. This should be updated each time
// the structure is changed in addition to adding a migration and incrementing
// the database version. Note that `╘══*...*` refers to maps with arbitrary
// keys.
//  └──v1                                        - Schema version bucket
//     ├──version : <varint>                     - Latest version, see migrations
//     ╘══*namespace*
//        ├──labels
//        │  ╘══*key* : <string>                 - Label value
//        ├──image

and verify that it is equal to version when creating the namespace?

What version of containerd are you using?

containerd github.com/containerd/containerd 1.5.2-0ubuntu1~20.04.2

Any other relevant information

No response

Show configuration if it is related to CRI plugin.

No response

@Iceber Iceber changed the title The database schema for metadata is inaccurate, and the namespace name cannot be *version* The database schema for metadata is inaccurate, and the namespace name cannot be version May 14, 2022
@AkihiroSuda
Copy link
Member

It might be difficult to change the schema without breaking existing data. I'd suggest just mark this wontfix and add a document to explain that a namespace cannot be named "version".

@Iceber
Copy link
Member Author

Iceber commented May 18, 2022

Yes, it is difficult to change the schema used in the metadata, but the metadata schema comment is inaccurate and does the schema comment need to be changed to be consistent with the current implementation?

Or is it just necessary to explain in the namespace doc that namespce cannot be named ”version“.

@AkihiroSuda
Copy link
Member

Yes, the comment has to be updated

@fuweid
Copy link
Member

fuweid commented May 29, 2022

fixed by #6955

@fuweid fuweid closed this as completed May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants