Skip to content

Commit

Permalink
fix(gc): Use the status of the sandbox to determine whether the conta…
Browse files Browse the repository at this point in the history
…iner exists
  • Loading branch information
00pf00 committed Jan 10, 2024
1 parent b37f521 commit 6787bd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pkg/api/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ func (d *DockerInterface) DockerInspectContainer(id string) (*dockertypes.Contai
return &containerJSON, nil
}

func (d *DockerInterface) ContainedInspectContainer(id string) (*criapi.ContainerStatus, error) {
func (d *DockerInterface) ContainedInspectContainer(id string) (*criapi.PodSandboxStatus, error) {
ctx, cancel := getTimeoutContext()
defer cancel()
if os.Getenv("CONTAINERD_HOST") != "" {
request := &criapi.ContainerStatusRequest{
ContainerId: id,
Verbose: true,
request := &criapi.PodSandboxStatusRequest{
PodSandboxId: id,
Verbose: true,
}
resp, err := d.containerdClient.ContainerStatus(ctx, request)
resp, err := d.containerdClient.PodSandboxStatus(ctx, request)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/gc/flannel_gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (gc *flannelGC) shouldCleanup(cid string) bool {
glog.Warningf("Error inspect container %s: %v", cid, err)
}
} else {
if c != nil && (c.State == criapi.ContainerState_CONTAINER_EXITED || c.State == criapi.ContainerState_CONTAINER_UNKNOWN) {
if c != nil && (c.State == criapi.PodSandboxState_SANDBOX_NOTREADY) {
glog.Infof("container %s exited %s", c.Id, c.State.String())
return true
}
Expand Down

0 comments on commit 6787bd6

Please sign in to comment.