-
Notifications
You must be signed in to change notification settings - Fork 348
Support symlink layer in image import. #727
Conversation
pkg/containerd/importer/importer.go
Outdated
@@ -60,6 +60,15 @@ func isLayerTar(name string) bool { | |||
return slashes == 2 && strings.HasSuffix(name, "/layer.tar") | |||
} | |||
|
|||
// followSymlinkLayer returns actual layer name of the symlink layer. | |||
func followSymlinkLayer(name string) (string, error) { |
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.
This is not robust, although it is ok as the workaround.
Can we verify the expected name
with regexp?
\.\./[a-z0-9]+/layer\.tar
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.
How about this?
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.
SGTM but please add a comment about this to the source?
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 already check with isLayerTar in line 126, maybe remove the check there?
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.
That is check for the initial layer name, here it is checking the symlink target.
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.
@AkihiroSuda will do.
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
63f2737
to
ff9827b
Compare
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.
see nit comments
pkg/containerd/importer/importer.go
Outdated
@@ -60,6 +60,22 @@ func isLayerTar(name string) bool { | |||
return slashes == 2 && strings.HasSuffix(name, "/layer.tar") | |||
} | |||
|
|||
// followSymlinkLayer returns actual layer name of the symlink layer. | |||
// It returns "deadbeeddeadbeef/layer.tar" if the name is like |
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.
nit.. the comments sometimes say deadbeeddeadbeef and sometimes say deadbeefdeadbeef replacing these with foo would take less space and hold the same meaning.
0xDEADBEEF holds historical significance as a marker for freed memory in a heap... if you are pointing to deadbeaf it means you have a bad pointer. This was important back in the early c and asm days when we used kernel debuggers to debug our operating systems. When an object was allocated we'd always memset the block to zero.
pkg/containerd/importer/importer.go
Outdated
// followSymlinkLayer returns actual layer name of the symlink layer. | ||
// It returns "deadbeeddeadbeef/layer.tar" if the name is like | ||
// "../deadbeeddeadbeef/layer.tar", and returns error if the name | ||
// is not in "../xxxx/layer.tar" format. |
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.
../foo/layer.tar not xxxx unless you want to use xxxx as the replacement for deadbeeddeadbeef & deadbeefdeadbeef strings...
ff9827b
to
2ef2782
Compare
@mikebrow Done. |
Signed-off-by: Lantao Liu <[email protected]>
2ef2782
to
9f85c48
Compare
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
Fixes #638.
This PR added support for symlink layers. @AkihiroSuda Does this make sense to you?
Now
ctr cri load
works fork8s.gcr.io/pause-amd64:3.0
:/cc @hmtai @qiujian16
Signed-off-by: Lantao Liu [email protected]