cri:fix containerd panic when can't find sandbox extension
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn> Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
parent
1a43cb6a10
commit
2879c0790c
@ -18,6 +18,7 @@ package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -107,6 +108,14 @@ func (c *criService) recover(ctx context.Context) error {
|
||||
metadata := sandboxstore.Metadata{}
|
||||
err := sbx.GetExtension(podsandbox.MetadataKey, &metadata)
|
||||
if err != nil {
|
||||
if errors.Is(err, errdefs.ErrNotFound) {
|
||||
err = c.client.SandboxStore().Delete(ctx, sbx.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete sandbox in response to missing metadata for sandbox %q: %w", sbx.ID, err)
|
||||
}
|
||||
// TODO: cleanup network namespace
|
||||
continue
|
||||
}
|
||||
return fmt.Errorf("failed to get metadata for stored sandbox %q: %w", sbx.ID, err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user