File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ package server
1818
1919import (
2020 "context"
21+ "errors"
2122 "fmt"
2223 "os"
2324 "path/filepath"
@@ -106,6 +107,16 @@ func (c *criService) recover(ctx context.Context) error {
106107 metadata := sandboxstore.Metadata {}
107108 err := sbx .GetExtension (podsandbox .MetadataKey , & metadata )
108109 if err != nil {
110+ if errors .Is (err , errdefs .ErrNotFound ) {
111+ log .G (ctx ).WithError (err ).Errorf ("failed to get metadata for stored sandbox %q" , sbx .ID )
112+ // Since commit https://github.com/containerd/containerd/pull/11612 has been merged metadata may not be nil.
113+ // Before 1162 we should delete leaked sandbox from sandbox store to make sure containerd can start successfully.
114+ err = c .client .SandboxStore ().Delete (ctx , sbx .ID )
115+ if err != nil {
116+ log .G (ctx ).WithError (err ).Errorf ("failed to delete sandbox %q, in response to failure to retrieve metadata for sandbox" , sbx .ID )
117+ }
118+ continue
119+ }
109120 return fmt .Errorf ("failed to get metadata for stored sandbox %q: %w" , sbx .ID , err )
110121 }
111122
You can’t perform that action at this time.
0 commit comments