This repository was archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 347
Fix removing state recover. #371
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ import ( | |
| ) | ||
|
|
||
| // RemoveContainer removes the container. | ||
| // TODO(random-liu): Forcibly stop container if it's running. | ||
| func (c *criContainerdService) RemoveContainer(ctx context.Context, r *runtime.RemoveContainerRequest) (_ *runtime.RemoveContainerResponse, retErr error) { | ||
| container, err := c.containerStore.Get(r.GetContainerId()) | ||
| if err != nil { | ||
|
|
@@ -52,7 +53,6 @@ func (c *criContainerdService) RemoveContainer(ctx context.Context, r *runtime.R | |
| if retErr != nil { | ||
| // Reset removing if remove failed. | ||
| if err := resetContainerRemoving(container); err != nil { | ||
| // TODO(random-liu): Do not checkpoint `Removing` state. | ||
| glog.Errorf("failed to reset removing state for container %q: %v", id, err) | ||
| } | ||
| } | ||
|
|
@@ -63,23 +63,23 @@ func (c *criContainerdService) RemoveContainer(ctx context.Context, r *runtime.R | |
| // kubelet implementation, we'll never start a container once we decide to remove it, | ||
| // so we don't need the "Dead" state for now. | ||
|
|
||
| containerRootDir := getContainerRootDir(c.config.RootDir, id) | ||
| if err := system.EnsureRemoveAll(containerRootDir); err != nil { | ||
| return nil, fmt.Errorf("failed to remove container root directory %q: %v", | ||
| containerRootDir, err) | ||
| // Delete containerd container. | ||
| if err := container.Container.Delete(ctx, containerd.WithSnapshotCleanup); err != nil { | ||
| if !errdefs.IsNotFound(err) { | ||
| return nil, fmt.Errorf("failed to delete containerd container %q: %v", id, err) | ||
| } | ||
| glog.V(5).Infof("Remove called for containerd container %q that does not exist", id, err) | ||
| } | ||
|
|
||
| // Delete container checkpoint. | ||
| if err := container.Delete(); err != nil { | ||
| return nil, fmt.Errorf("failed to delete container checkpoint for %q: %v", id, err) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If we fail to do that, we may not want to remove container root directory, because that removal is not atomic. |
||
| } | ||
|
|
||
| // Delete containerd container. | ||
| if err := container.Container.Delete(ctx, containerd.WithSnapshotCleanup); err != nil { | ||
| if !errdefs.IsNotFound(err) { | ||
| return nil, fmt.Errorf("failed to delete containerd container %q: %v", id, err) | ||
| } | ||
| glog.V(5).Infof("Remove called for containerd container %q that does not exist", id, err) | ||
| containerRootDir := getContainerRootDir(c.config.RootDir, id) | ||
| if err := system.EnsureRemoveAll(containerRootDir); err != nil { | ||
| return nil, fmt.Errorf("failed to remove container root directory %q: %v", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| containerRootDir, err) | ||
| } | ||
|
|
||
| c.containerStore.Delete(id) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what if we just pop out warnings and continue instead of returning early then return the error after we attempt to delete all the parts, best can do model?
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 if we fail to delete container, we want to keep its status and root directory so that we could still retrieve information about this container.
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.
ok per discussion, let's add a todo / issue regarding forcibly removing / killing on the remove request. Or getting guidance from the CRI sig-node team on remove expectations.