-
Notifications
You must be signed in to change notification settings - Fork 347
Conversation
63b2d67 to
761131c
Compare
48c960d to
d6fa504
Compare
d6fa504 to
18baa35
Compare
abhi
left a comment
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.
Initial comments.
| } | ||
|
|
||
| // Load network namespace. | ||
| netNS, err := sandboxstore.LoadNetNS(meta.NetNSPath) |
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.
NetNSPath is not set if its in host network namespace. Should we be checking for the network namespace before loading it ?
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.
Good catch. We should.
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.
pkg/server/restart.go
Outdated
| } | ||
| id := d.Name() | ||
| found := false | ||
| for _, c := range cntrs { |
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.
can we use a map to track the loaded containers/sandboxes from the caller. Just thinking, looping over containers for every directory may not be a faster method.
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.
or may be keep a track of containerDirs in a map once loadContainer succeeds. So we can just loop around the dirs here and check if its in the containerDirs map , if not then clean it up.
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.
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.
pkg/server/restart.go
Outdated
| } | ||
| id := d.Name() | ||
| found := false | ||
| for _, c := range cntrs { |
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.
same as mentioned for sandboxes
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.
18baa35 to
ed6d11d
Compare
|
@abhinandanpb Addressed comments. |
abhi
left a comment
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.
Did a first pass now. Looks good overall. Minor comments.
pkg/store/sandbox/netns.go
Outdated
| } | ||
|
|
||
| // LoadNetNS loads existing network namespace. It returns ErrClosedNetNS | ||
| // is the network namespace has already been closed. |
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: if the network namespace
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
| // LoadNetNS loads existing network namespace. It returns ErrClosedNetNS | ||
| // is the network namespace has already been closed. | ||
| func LoadNetNS(path string) (*NetNS, error) { | ||
| if err := cnins.IsNSorErr(path); err != nil { |
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 check is already done by GetNS(path) and would return an error if it is closed.
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 need to distinguish whether it's ErrClosedNetNS or not in restart.go.
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.
GetNS would return cnins.NSPathNotExistErr so you can always check for that error if the nspath doesnt exist. Unless I am missing something. This is fine. If we can avoid an if condition even better.
pkg/store/sandbox/netns.go
Outdated
| return fmt.Errorf("failed to stat netns: %v", err) | ||
| } | ||
| // Follow possible /var/run -> /run symlink. | ||
| path, err := symlink.FollowSymlinkInScope(path, "/") |
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 dont create symlink currently right ? Should we explicitly follow the symlink ? kernel takes care of delinking the implicit ones ?
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.
Copied from cri-o. Yeah, it seems that we don't need this even /var/run -> /run is a symlink.
pkg/server/restart.go
Outdated
| return container, fmt.Errorf("failed to load task: %v", err) | ||
| } | ||
| var s containerd.Status | ||
| notFound := false |
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.
var notFound bool
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.
| if err != nil { | ||
| return fmt.Errorf("failed to list sandbox containers: %v", err) | ||
| } | ||
| for _, sandbox := range sandboxes { |
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 think you can create a sandboxmap[string]bool here and pass it to cleanuporphansandboxdir instead of creating one 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.
Doesn't make too much difference to me, because we won't use the map here. Given so I prefer move the code into cleanuporphansandboxdir which is the place where the map will be used. :)
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 meant instead of passing sandbox list and container list , pass a map for comparison. Not a blocker though
| if err != nil { | ||
| return fmt.Errorf("failed to list containers: %v", err) | ||
| } | ||
| for _, container := range containers { |
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.
same as sandbox
ed6d11d to
b28a549
Compare
b28a549 to
8e11861
Compare
abhi
left a comment
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 otherwise
| // LoadNetNS loads existing network namespace. It returns ErrClosedNetNS | ||
| // is the network namespace has already been closed. | ||
| func LoadNetNS(path string) (*NetNS, error) { | ||
| if err := cnins.IsNSorErr(path); err != nil { |
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.
GetNS would return cnins.NSPathNotExistErr so you can always check for that error if the nspath doesnt exist. Unless I am missing something. This is fine. If we can avoid an if condition even better.
@abhinandanpb I read their code. You are right. We should use Good catch! |
Signed-off-by: Lantao Liu <[email protected]>
8e11861 to
cc1b0b6
Compare
|
@abhinandanpb Addressed comments. I still keeps the |
|
@abhinandanpb Thanks for reviewing! Will merge after test passes. |
|
/LGTM |
Fixes #120.
Add recovery logic during restart. I've manually tested this, it's working even better than I thought. :)
Based on #206 and #179.
@kubernetes-incubator/maintainers-cri-containerd Please review this carefully, especially
pkg/server/restart.go. This is really important to the production quality.I'll send another PR to add our own integration test framework, and will add restart test.