MCPcopy Index your code
hub / github.com/containerd/containerd / waitForStart

Method waitForStart

integration/client/daemon.go:60–104  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

58}
59
60func (d *daemon) waitForStart(ctx context.Context) (*client.Client, error) {
61 var (
62 clientInstance *client.Client
63 serving bool
64 err error
65 ticker = time.NewTicker(500 * time.Millisecond)
66 )
67 defer ticker.Stop()
68
69 for {
70 select {
71 case <-ticker.C:
72 clientInstance, err = client.New(d.addr)
73 if err != nil {
74 continue
75 }
76 serving, err = clientInstance.IsServing(ctx)
77 if !serving {
78 clientInstance.Close()
79 if err == nil {
80 err = errors.New("connection was successful but service is not available")
81 }
82 continue
83 }
84 resp, perr := clientInstance.IntrospectionService().Plugins(ctx)
85 if perr != nil {
86 return nil, fmt.Errorf("failed to get plugin list: %w", perr)
87 }
88 var loadErr error
89 for _, p := range resp.Plugins {
90 if p.InitErr != nil && !strings.Contains(p.InitErr.Message, plugin.ErrSkipPlugin.Error()) {
91 pluginErr := fmt.Errorf("failed to load %s.%s: %s", p.Type, p.ID, p.InitErr.Message)
92 loadErr = errors.Join(loadErr, pluginErr)
93 }
94 }
95 if loadErr != nil {
96 return nil, loadErr
97 }
98
99 return clientInstance, err
100 case <-ctx.Done():
101 return nil, fmt.Errorf("context deadline exceeded: %w", err)
102 }
103 }
104}
105
106func (d *daemon) Stop() error {
107 d.Lock()

Callers 4

startDaemonFunction · 0.80
newDaemonWithConfigFunction · 0.80
TestMainFunction · 0.80

Calls 8

NewFunction · 0.92
IsServingMethod · 0.80
IntrospectionServiceMethod · 0.80
StopMethod · 0.65
CloseMethod · 0.65
PluginsMethod · 0.65
DoneMethod · 0.65
ErrorMethod · 0.45

Tested by 4

startDaemonFunction · 0.64
newDaemonWithConfigFunction · 0.64
TestMainFunction · 0.64