-
Notifications
You must be signed in to change notification settings - Fork 204
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
nydusify: add fs-version annotation #497
Conversation
ae23437
to
8a7c54a
Compare
contrib/nydusify/pkg/cache/cache.go
Outdated
@@ -129,6 +129,7 @@ func (cache *Cache) recordToLayer(record *Record) (*ocispec.Descriptor, *ocispec | |||
Size: record.NydusBootstrapDesc.Size, | |||
Annotations: map[string]string{ | |||
utils.LayerAnnotationNydusBootstrap: "true", | |||
utils.LayerAnnotationNydusFsVersion: cache.opt.Version, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be cache.opt.FsVersion
, how this option be passed to the cache image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked, it is cache.opt.Version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Opt configures Nydus cache
type Opt struct {
// Maximum records(bootstrap layer + blob layer) in cache image.
MaxRecords uint
Version string
// Make cache image manifest compatible with the docker v2 media
// type defined in github.com/containerd/containerd/images.
DockerV2Format bool
// The blob layer record will not be written to cache image if
// the backend be specified, because the blob layer will be uploaded
// to backend.
Backend backend.Backend
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested on converting alpine:latest with nydusify for both v5 and v6, and checked their manifests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yawqi This Version
field is used to indicate the version of cache image (not fs version), nydusify will use cache records depending on the version. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add some comments to distinguish these two fields:
// Opt configures Nydus cache
type Opt struct {
...
// Version of cache image, we need to discard cache layers when
// the required version (specified by `--build-cache-version`)
// is unmatched with the cache image version, for example nydus
// bootstrap format has a minor upgrade.
Version string
// Bootstrap's RAFS version of cache image, we need to discard cache
// layers when the required version (specified by `--fs-version`) is
// unmatched with the fs version recorded in cache image, for example
// we can't use rafs v5 cache layers for rafs v6 image.
FsVersion string
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
96f4878
to
1999069
Compare
contrib/nydusify/pkg/cache/cache.go
Outdated
// Discard the cache if mismatched RAFS FsVersion | ||
if manifest.Annotations[utils.LayerAnnotationNydusFsVersion] != cache.opt.FsVersion { | ||
return fmt.Errorf( | ||
"unmatched cache image version %s, required to be %s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe unmatched fs version %s of cache image, required to be %s
.
contrib/nydusify/pkg/cache/cache.go
Outdated
if manifest.Annotations[utils.ManifestNydusCache] != cache.opt.Version { | ||
return fmt.Errorf( | ||
"unmatched cache image version %s, required to be %s", | ||
manifest.Annotations[utils.ManifestNydusCache], cache.opt.Version, | ||
) | ||
} | ||
|
||
// Discard the cache if mismatched RAFS FsVersion | ||
if manifest.Annotations[utils.LayerAnnotationNydusFsVersion] != cache.opt.FsVersion { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For manifest.Annotations[utils.LayerAnnotationNydusFsVersion] == ""
(e.g. old cache image), we should consider it as 5
.
Add an annotation to the image manifest for detecting the bootstrap fs version without reading the magic number from bootstrap. fix dragonflyoss#496 Signed-off-by: Qi Wang <wangqi@linux.alibaba.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Add an annotation to the image manifest for detecting the bootstrap fs
version without reading the magic number from bootstrap.
fix #496
Signed-off-by: Qi Wang wangqi@linux.alibaba.com