From 5365f4b29e1014db473b2b796e5c8331309e608a Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 29 Sep 2023 23:00:28 +0900 Subject: [PATCH] cri: call RegisterReadiness after NewCRIService `NewCRIService()` may easily fail and its error has to be ignored unless the CRI plugin is in the `required_plugins` list. Now this has to be called before `RegisterReadiness()`, as PR 9153 "Require plugins to succeed after registering readiness" was merged on 2023-09-29. Fix issue 9163: `[Regression in main (2023-09-29)]: containerd-rootless.sh doesn't start up` Signed-off-by: Akihiro Suda --- pkg/cri/cri.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/cri/cri.go b/pkg/cri/cri.go index 4597b37a8..a81fc43c9 100644 --- a/pkg/cri/cri.go +++ b/pkg/cri/cri.go @@ -54,7 +54,6 @@ func init() { } func initCRIService(ic *plugin.InitContext) (interface{}, error) { - ready := ic.RegisterReadiness() ic.Meta.Platforms = []imagespec.Platform{platforms.DefaultSpec()} ic.Meta.Exports = map[string]string{"CRIVersion": constants.CRIVersion} ctx := ic.Context @@ -99,6 +98,8 @@ func initCRIService(ic *plugin.InitContext) (interface{}, error) { return nil, fmt.Errorf("failed to create CRI service: %w", err) } + // RegisterReadiness() must be called after NewCRIService(): https://github.com/containerd/containerd/issues/9163 + ready := ic.RegisterReadiness() go func() { if err := s.Run(ready); err != nil { log.G(ctx).WithError(err).Fatal("Failed to run CRI service")