Skip to content

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

@Iceber

Description

@Iceber

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions